Skip to content
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

Eliminate lock in ConcurrencyLimitingRequestThrottler #2025

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

jasonk000
Copy link
Contributor

Following up from #1957 this moves to a complete lock-free implementation.

(cc @tolbertam who reviewed the previous PR, and @akhaku and @clohfink who have reviewed internally).

Commits are broken to smaller steps in case it's helpful in review. I will do a squash/rebase when OK.

@akhaku
Copy link
Contributor

akhaku commented Mar 3, 2025

reviewed internally, LGTM

@tolbertam tolbertam self-requested a review March 4, 2025 03:41
@tolbertam
Copy link
Contributor

nice @jasonk000! Looking forward to reviewing this, will try to give it a look this week.

Copy link
Contributor

@tolbertam tolbertam left a comment

Choose a reason for hiding this comment

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

apologies that this took me a bit to get around to, this look great @jasonk000, 👍

@GuardedBy("lock")
private boolean closed;
private final AtomicInteger concurrentRequests = new AtomicInteger(0);
// CLQ is not O(1) for size(), as it forces a full iteration of the queue. So, we track
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks, notable comment as would have questioned this otherwise 😛

@jasonk000 jasonk000 force-pushed the concurrency-limit-throttler-unblock-redux branch from c9b8e35 to 70bc953 Compare March 17, 2025 16:56
@jasonk000
Copy link
Contributor Author

Thanks, @tolbertam, I've squashed it now. Ready to go!

Copy link
Contributor

@adutra adutra left a comment

Choose a reason for hiding this comment

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

Great work! You may want to update the following documentation page:

* `ConcurrencyLimitingRequestThrottler`

Following from 6d3ba47 this changes the throttler to a complete
lock-free implementation. Update the related comments and README now
that it is lock-free.
@jasonk000 jasonk000 force-pushed the concurrency-limit-throttler-unblock-redux branch from 70bc953 to bf694bd Compare March 17, 2025 17:59
@jasonk000
Copy link
Contributor Author

Good catch, I've updated related comment & javadocs.

Separately, @adutra, we do not internally use the RateLimitingRequestThrottler. If there are other users, I would be happy to put some code together to do the same change, but would need some support to test and verify. Let me know if that would be useful.

@adutra
Copy link
Contributor

adutra commented Mar 17, 2025

If there are other users, I would be happy to put some code together to do the same change, but would need some support to test and verify. Let me know if that would be useful.

I'd say, let's wait until there is demand for that, but thanks for the initiative!

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.

4 participants