Skip to content

Make ProgressThread::remove_function less blocking #265

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

Draft
wants to merge 3 commits into
base: branch-25.06
Choose a base branch
from

Conversation

pentschev
Copy link
Member

@pentschev pentschev commented May 8, 2025

Track completed functions to make ProgressThread::remove_function less blocking.

@pentschev pentschev changed the title Make ProgressThread::remove_function non-blocking Make ProgressThread::remove_function less blocking May 8, 2025
@pentschev
Copy link
Member Author

@nirandaperera just to follow-up on our brief offline discussion, this is a way we could make the existing ProgressThread::remove_function less blocking. However, it doesn't make the idea around implementation much different than yours, and if we were to make add_function less blocking as well we would end up with a staging structure here as well. I don't believe also what's in this PR is necessarily the right approach for us nor that it implies being superior to your implementation, just pushed this to have a counterpoint to the discussion. Also note that I didn't cleanup other things that now have become unnecessary, but we can do that if our discussion leads for us to keep on working on the current implementation instead of going with your reimplementation of ProgressThread.

Comment on lines 104 to 111
std::lock_guard<std::mutex> lock(mutex_);
for (auto& [id, function] : functions_) {
function();
if (function.is_done) {
completed_functions.push_back(id);
completion_tracker_.mark_completed(id);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@pentschev do you think we could traverse the functions_ map without holding the lock? I think that is the bottleneck in the current impl. And suspect that's why @madsbk 's PR of adding a small sleep helped.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is in essence what you've implemented as well, done in 5956475 . (Again, not cleaned up for any resources that are now redundant)

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me go through this

@nirandaperera
Copy link
Contributor

@pentschev I think we are on the same page here. I also sent a PR #266 which I think is a little more simpler. LMK what you think

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