Problem
Every request referencing a snapshot deep-copies the Snapshot struct (~40KB for a 5000-window desktop) via snap = it->second at server.cpp:221 and tcp_server.cpp:273. This adds measurable allocation pressure under concurrent load.
Proposed Solution
Change ServerState::snaps from std::map<std::string, Snapshot> to std::map<std::string, std::shared_ptr<Snapshot>>. Queries get a shared_ptr copy (16 bytes, no allocation). Pin/unpin operates on the shared_ptr reference count.
References
- Performance audit item 3
daemon/src/server.cpp:180, 221
daemon/src/server_state.hpp:19
Problem
Every request referencing a snapshot deep-copies the Snapshot struct (~40KB for a 5000-window desktop) via
snap = it->secondat server.cpp:221 and tcp_server.cpp:273. This adds measurable allocation pressure under concurrent load.Proposed Solution
Change
ServerState::snapsfromstd::map<std::string, Snapshot>tostd::map<std::string, std::shared_ptr<Snapshot>>. Queries get a shared_ptr copy (16 bytes, no allocation). Pin/unpin operates on the shared_ptr reference count.References
daemon/src/server.cpp:180, 221daemon/src/server_state.hpp:19