Skip to content

Use shared_ptr<Snapshot> to avoid deep-copy per request #18

@mark-e-deyoung

Description

@mark-e-deyoung

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions