8000 Compute residuals with threadpool for model_merger by clementinboittiaux · Pull Request #3401 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Compute residuals with threadpool for model_merger #3401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

clementinboittiaux
Copy link
@clementinboittiaux clementinboittiaux commented Jun 12, 2025

Hey @ahojnnes ,

We've recently had a computation bottleneck when trying to merge big reconstructions (2,500 to 35,000 common images). The heaviest step is computing the residuals for alignment. This PR simply computes the residuals with a threadpool.
On two models with 2,706 common images the alignment step drops from 646 s to 51 s with 64 threads.

N.B.: THROW_CHECK_EQ exceptions in threads are propagated in the main thread through future.get().

const Image& src_image = *src_images[i];
const Image& tgt_image = *tgt_images[i];
if (thread_pool_ && src_images.size() > 10) {
std::vector<std::future<void>> futures;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to accumulate the futures. You can just do thread_pool_->Wait(); to finish all tasks in the pool.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed but does not propagate THROW_CHECK_EQ exceptions. How could this be solved?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed THROW_CHECK_EQ from ComputeImageResidual, and only perform the checks once before computing the residuals.

@@ -33,13 +33,15 @@
#include "colmap/scene/image.h"
#include "colmap/scene/reconstruction.h"
#include "colmap/scene/track.h"
#include "colmap/util/threading.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's forward-decl threadpool here as well instead of including this header.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0