Skip to content

python: debounce snapshot persistence and encode outside the client lock #77

Done

Description

@akosidencio

With offline storage configured, the Python SDK persists its flag cache by re-encoding the whole cache while holding the client lock, then fsyncing. Deltas processed in one task are already coalesced (_persist_pending). Even so, a burst of updates costs a full encode and fsync per batch, and evaluations wait on the lock while the encode runs. This is a performance issue, not a security one. It was rated low and accepted for 0.2.0.

Acceptance criteria

  • Persistence is debounced (documented interval, e.g. 250 ms to 1 s) and encodes a snapshot taken under the lock, not while holding it.
  • Test: 1,000 deltas applied within 1 s produce at most 1 + duration ÷ interval writes.
  • While persisting a 10,000-flag cache, lock hold time per evaluation stays at or below 1 ms at p99 (measured in a test or benchmark).
  • Crash safety is retained: writes stay atomic (temp file + rename). The last write after a burst is not lost when close() is called (flush on close).

Activity

  1. added this to the v0.2.1 milestone on Nov 22, 2026
  2. added
    enhancement
    on Nov 22, 2026
  3. added a commit that references this issue on Nov 30, 2026
  4. akosidencio commented on Nov 30, 2026

    @akosidencio
    MemberAuthor

    Fixed in 0.2.1 by #96 (merged to dev; part of the 0.2.1 release).

    Verification: Python SDK tests in CI; lock hold time p99 at or below 0.41 ms during snapshot writes; atomic writes and flush on close() tested.

    Details are in the 0.2.1 changelog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions