readysettech / readyset

Readyset is a MySQL and Postgres wire-compatible caching layer that sits in front of existing databases to speed up queries and horizontally scale read throughput. Under the hood, ReadySet caches the results of cached select statements and incrementally updates these results over time as the underlying data changes.
https://readyset.io
Other
4.54k stars 125 forks source link

mysql-srv: Optimize buffer use reading from the client socket #1254

Open jasobrown-rs opened 6 months ago

jasobrown-rs commented 6 months ago

Description

When looking at a flamegraph produced while running a system-benchmark, I discovered that we spend a lot of time in PacketReader::next() just resizing the backing Vec<u8>. There's more efficient ways to handle the buffer here. Naively, we should look at the bytes crate as it integrates with tokio natively.

This code in PacketReader is fairly self-contained so any optimization should be rather straight forward.

Change in user-visible behavior

N/A

Requires documentation change

N/A