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

Remove sync notifiers for a major speedup #714

Merged
merged 4 commits into from
Dec 11, 2024
Merged

Conversation

x42005e1f
Copy link
Contributor

Avoids creating new threads since the mutex is already held in the queue methods.

@x42005e1f
Copy link
Contributor Author

threading.Condition can be notified immediately without creating a new thread, since its notify() method is a very fast non-blocking operation, and the current implementation guarantees exclusive access to both _sync_not_empty and _sync_not_full. So synchronous notifiers were never really needed, and that is why they are removed in this PR. With this change, Janus became faster than the naive solution.

Copy link

codspeed-hq bot commented Dec 11, 2024

CodSpeed Performance Report

Merging #714 will not alter performance

Comparing x42005e1f:master (f058329) with master (e180116)

Summary

✅ 4 untouched benchmarks

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.49%. Comparing base (e180116) to head (f058329).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #714      +/-   ##
==========================================
- Coverage   94.54%   94.49%   -0.06%     
==========================================
  Files           5        5              
  Lines        1504     1490      -14     
  Branches      131      131              
==========================================
- Hits         1422     1408      -14     
  Misses         53       53              
  Partials       29       29              

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

@x42005e1f
Copy link
Contributor Author

x42005e1f commented Dec 11, 2024

It looks like benchmarks are hardware dependent. In the CodSpeed profiler, I do not see notifiers for the test_bench_async_put_sync_get() case even before this PR, so I can assume that the thread has time to put items into the queue without blocking, and therefore does not call the notification methods. On my hardware, that test speeds up by ~5x.

@asvetlov
Copy link
Member

asvetlov commented Dec 11, 2024

It looks like benchmarks are hardware dependent.

codspeed does the best. It normalizes the speed to mitigate different performance of test boxes, and it also removes syscalls times.
The latest could be the reason of non-measurable changes in benchmarks.
There is walltime mode: https://docs.codspeed.io/instruments/walltime/ but I never tried it yet.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

Good finding, thanks!

@asvetlov asvetlov merged commit f90a38a into aio-libs:master Dec 11, 2024
13 checks passed
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