ydb-platform / ydb

YDB is an open source Distributed SQL Database that combines high availability and scalability with strong consistency and ACID transactions
https://ydb.tech
Apache License 2.0
4.02k stars 582 forks source link

Tablets: directly connected pipes #11741

Open snaury opened 2 days ago

snaury commented 2 days ago

Currently tablet pipes are accepted by the "system" actor, which causes pipe servers to start in the System thread pool. However, these system pipes mostly just unpack and forward events to the "user" actor in the User thread pool. This forwarding is mostly unnecessary and spends a lot of cpu time jumping between threads. Ideally we would want events to arrive directly at the user actor, without any need for extra wrappers. Ideally we would want to bypass extra forwarding on the client side as well, but it may be more challenging.

I think I know how to remove these forwarding layers by introducing actor aliases (where the same IActor instance has multiple addresses). Pipe servers would then register a new address for the "user" tablet actor, and all events would arrive there directly at the target actor without any need for additional layers. Tablet's default handler would need a special handler for pipe server messages, but it shouldn't be a big deal. A happy coincidence would be ev->Recipient pointing to the server address, which would help shards identify which shards this message belongs. Using an alias would also help reject stray messages after the pipe has been closed.

Some challenges: