Skip to content

Support for user-level flat combining #1612

Closed
@catern

Description

@catern

Flat combining is a name coined by the paper "Flat Combining and the Synchronization-Parallelism
Tradeoff"
for a synchronization technique where a single thread dynamically takes on the role of handling requests from other threads to perform mutations on a datastructure. This can provide performance improvements, and simplifies implementation of the datastructure - no need for fine-grained concurrency.

In trio, threads (tasks) are cheap, so it might seem pointless - just spawn a dedicated thread to service requests to mutate the datastructure. But spawning a thread requires a nursery for that thread, and complicates management for objects. It's much simpler for an object which is concurrently accessed to just pick one of the threads accessing it to perform mutations, as in flat combining.

I've implemented a lot of flat-combining manually in libraries using trio. It would be nice if there was a built-in way as part of trio to do this. This might combine nicely with support for kill-safe synchronization abstractions which I've also done a lot in trio, painfully manually.

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