Optimize xid/subxid searches in XidInMVCCSnapshot().
authorJohn Naylor <john.naylor@postgresql.org>
Wed, 3 Aug 2022 16:59:28 +0000 (09:59 -0700)
committerJohn Naylor <john.naylor@postgresql.org>
Thu, 11 Aug 2022 02:17:42 +0000 (09:17 +0700)
commit37a6e5df3713498a21942dae2ed3122bba5b9f50
treebbcf0b95eb0a86aa9b49cf8ef23bbfcac6d0843f
parenta8c012869763c711abc9085f54b2a100b60a85fa
Optimize xid/subxid searches in XidInMVCCSnapshot().

As reported by Yura Sokolov, scanning the snapshot->xip array has
noticeable impact on scalability when there are a large number of
concurrent writers. Use the optimized (on x86-64) routine from b6ef16756
to speed up searches through the [sub]xip arrays. One benchmark showed
a 5% increase in transaction throughput with 128 concurrent writers,
and a 50% increase in a pathological case of 1024 writers. While a hash
table would have scaled even better, it was ultimately rejected because
of concerns around code complexity and memory allocation. Credit to Andres
Freund for the idea to optimize linear search using SIMD instructions.

Nathan Bossart

Reviewed by: Andres Freund, John Naylor, Bharath Rupireddy, Masahiko Sawada
Discussion: https://postgr.es/m/20220713170950.GA3116318%40nathanxps13
src/backend/utils/time/snapmgr.c