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

Fix the throttle oversupply counting #124

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

mhutchinson
Copy link
Contributor

The previous implementation had false positives for oversupply when the
limit was increased at runtime due to the channel not being drained than
the for loop could put 2N tokens in N pigeonholes.

The new implementation uses a timeout for each episode of the throttle
that will terminate the for loop early if the tokens can't all be sent
down the channel. I considered using the next tick of the main ticker as
the timeout, but this would have caused the next episode of the throttle
to be skipped without more complexity being added.

The previous implementation had false positives for oversupply when the
limit was increased at runtime due to the channel not being drained than
the for loop could put 2N tokens in N pigeonholes.

The new implementation uses a timeout for each episode of the throttle
that will terminate the for loop early if the tokens can't all be sent
down the channel. I considered using the next tick of the main ticker as
the timeout, but this would have caused the next episode of the throttle
to be skipped without more complexity being added.
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 29.23%. Comparing base (07aa77d) to head (66cfaf9).
Report is 38 commits behind head on main.

Files Patch % Lines
hammer/hammer.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #124       +/-   ##
===========================================
- Coverage   55.99%   29.23%   -26.77%     
===========================================
  Files           8       15        +7     
  Lines         759     1406      +647     
===========================================
- Hits          425      411       -14     
- Misses        265      916      +651     
- Partials       69       79       +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mhutchinson mhutchinson merged commit 3f61737 into transparency-dev:main Apr 24, 2024
9 checks passed
@mhutchinson mhutchinson deleted the fixthrottle branch April 24, 2024 10:52
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.

3 participants