pgcat
pgcat copied to clipboard
Reduce message cloning operations
This PR leverages client and server buffers to read messages onto and flush messages from.
This reduces the number of allocations performed by pgcat as seen by these stats after pgbench run on the main branch compared to this branch.
pgbench with new client per query results in a ~37% reduction in allocations
pgbench -t 1000 -c 16 -j 2 --protocol extended -C
Before:
Stats: Stats {
allocations: 5617437,
deallocations: 5614634,
reallocations: 130699,
bytes_allocated: 673340233,
bytes_deallocated: 672221777,
bytes_reallocated: 3760681,
}
After:
Stats: Stats {
allocations: 3505408,
deallocations: 3502605,
reallocations: 130702,
bytes_allocated: 628430295,
bytes_deallocated: 627311847,
bytes_reallocated: 3760728,
}
pgbench with same client for pgbench session results in a ~53% reduction in allocations:
pgbench -t 1000 -c 16 -j 2 --protocol extended
Before:
Stats: Stats {
allocations: 3874108,
deallocations: 3871232,
reallocations: 2880,
bytes_allocated: 158461974,
bytes_deallocated: 157277508,
bytes_reallocated: 797417,
}
After:
Stats: Stats {
allocations: 1792054,
deallocations: 1789265,
reallocations: 2804,
bytes_allocated: 113265426,
bytes_deallocated: 112172240,
bytes_reallocated: 780508,
}