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

Change how we locate the parent greenlet + perf improvements #26

Merged
merged 7 commits into from
Feb 8, 2024

Conversation

oremanj
Copy link
Owner

@oremanj oremanj commented Feb 7, 2024

  • Explicitly store the parent/portal greenlet for each portalized task, rather than relying on greenlet.getcurrent().parent. Along with some tweaks in the messaging between await_ and greenback_shim, this allows await_ to work inside other greenlets started by a portalized task, which allows us to interoperate with other similar approaches such as SQLAlchemy's async ORM. Fixes Isolated usage of greenlets #22.
  • Start one child greenlet per portalized task, rather than one per task step of a portalized task. This reduces the per-checkpoint overhead of being portalized by about 4x on the author's laptop, down to ~1usec overhead (versus ~13usec to execute the checkpoint without greenback involved).
  • Notice the case where a task bestowed a portal on itself, but the portal is not usable yet because the task hasn't executed any checkpoints since then. Tasks in this state will now see a false return from has_portal() and a better error message if they try to use await_().
  • Update docs and error messages to more prominently advertise with_portal_run[_sync], in addition to the original ensure_portal interface.
  • Update performance numbers in the docs.
  • Update README to be less pessimistic about the production applicability of greenback. It's been used in production for a long time.

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (134a865) 99.74% compared to head (e7134b7) 99.76%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #26      +/-   ##
==========================================
+ Coverage   99.74%   99.76%   +0.01%     
==========================================
  Files           7        7              
  Lines         788      839      +51     
  Branches      113      121       +8     
==========================================
+ Hits          786      837      +51     
  Misses          1        1              
  Partials        1        1              
Flag Coverage Δ
cpython 99.28% <99.11%> (+0.30%) ⬆️
pypy36release 92.13% <98.23%> (+1.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@oremanj oremanj merged commit 3945b6e into master Feb 8, 2024
30 checks passed
@oremanj oremanj deleted the reorg branch February 8, 2024 00:22
@zanieb
Copy link

zanieb commented Feb 8, 2024

Thank you so much! Exciting to see these improvements. Feel free to ping me if you ever want a reviewer.

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.

Isolated usage of greenlets
2 participants