Skip to content

Either optimize yield_briefly or de-optimize yield_briefly_no_cancel #70

@njsmith

Description

@njsmith

Right now yield_briefly_no_cancel has a special-case implementation in the run loop, while yield_briefly is implemented like (schematically):

with open_cancel_scope(deadline=-inf):
    await yield_indefinitely(lambda _: Abort.SUCCEEDED)

It was done this way because at the time I wrote them, yield_briefly_no_cancel couldn't be implemented any other way. But in the mean time we gained shielding, so now it could be

with open_cancel_scope(deadline=-inf, shield=True):
    await yield_indefinitely(lambda _: Abort.SUCCEEDED)

This is kinda weird and awkward. I'm not sure which way to standardize, though. yield_briefly_no_cancel is currently much faster than yield_briefly, because setting up and tearing down a cancel scope with a non-trivial deadline has non-trivial costs (at least compared to the other costs for these tiny operations). But the implementation is definitely more complicated. So we should decide whether we want to optimize yield_briefly, or de-optimize yield_briefly_no_cancel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions