PATCH: speed improvements

Bug #1778802 reported by Vladimir Nadvornik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Hugin
Fix Released
Undecided
Unassigned

Bug Description

I tried to profile hugin on a large project with 500 images and 100000 control points. I identified and fixed some bottlenecks:

ImageVariable.patch - reimplemented ImageVariable with shared_ptr - reduces complexity from O(n) to O(1)

ImageVariableGroup.patch - move some method calls out of a loop

GreatCircles.patch - reduce number of segments for short lines

GreatCircles-image.patch - HuginBase::SrcPanoImage is expensive, initialize equirectangularImage only once

Revision history for this message
Vladimir Nadvornik (nadvornik-suse) wrote :
Revision history for this message
tmodes (tmodes) wrote :

Thanks you for your work.
Some comments:
ImageVariable.patch: This I need to check. This is a big change and I want to understand it before committing it.

ImageVariableGroup.patch: This code and similar one is used at several places. Would it also help to inline the getimage function to achieve the same/similar speed improvement?

GreatCircles.patch: Already pushed to repository.

GreatCircles-image.patch: Instead of the workaround (and the same or similar code is used at several places through the whole repository) we should fix the initialization of the SrcPanoImage class. I tried to rewrite the initialization of this class with modern C++. Could you please try if the attached patch brings the same effect?

Revision history for this message
tmodes (tmodes) wrote :
Revision history for this message
Vladimir Nadvornik (nadvornik-suse) wrote :

I found one problem with ImageVariable.patch: MaskPolygon::parsePolygonString creates MaskPolygon instance without initialized bounding box. Before it was fixed by operator=, with ImageVariable.patch the instance is shared or copied with default copy constructor so it never gets fixed and masks in nona do not work correctly.
The attached patch should fix it.

ImageVariableGroup.patch: actually I'd expect that getImage is inlined, but it is not for same reason. However I don't fully understand the code around.

GreatCircles-image.patch: I think this is not a workaround, equirectangularImage is still the same and it does not make sense to construct it again for each line. Your patch however seems to help.

Revision history for this message
tmodes (tmodes) wrote :

Thanks again. I committed most patches to repository (some were slightly modified).

For ImageVariableGroup.patch: I made Panorama::getImage inline. GetImage should only return the address of the SrcPanoImage class, nothing more is happen in this function. I don't know why this should be so expensive (or is the lookup in the std::vector so expensive?)

Changed in hugin:
milestone: none → 2018.2beta1
status: New → Fix Committed
tmodes (tmodes)
Changed in hugin:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.