mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-20 13:03:50 +00:00
A connection's two 16 KiB relay buffers lived inline in its slot, so every connection that had moved a byte kept those pages resident even while idle. They now come from one ObjectPool with two buffers per connection slot: a connection leases a buffer while bytes wait in it and returns it when it drains, and the LIFO free list hands the same warm pages to the next busy connection. The pool covers every direction of every slot, so a lease never fails and reads never wait on it. With 1,000 idle connections, ss-server drops from 35.4 to 27.2 KiB per connection on Linux (C: 26.2) and from 73.9 to 42.2 KiB on macOS. The slot shrinks from 104 to 68 KiB. FixedBuffer gains a user-provided constructor so that value-initialising one (a pool lease, a variant alternative) no longer zero-fills its storage.