fix(py): compress replica writes that carry their own credentials - #3448
Open
Emil F (emil-lc) wants to merge 1 commit into
Open
fix(py): compress replica writes that carry their own credentials#3448Emil F (emil-lc) wants to merge 1 commit into
Emil F (emil-lc) wants to merge 1 commit into
Conversation
Merging this PR will improve performance by 10.89%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Memory | test_bench[create_10_000_run_trees] |
17.7 MB | 16 MB | +10.89% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing emil/multi-replica-memory-3 (0940dc2) with main (1228e5b)
4 tasks
Emil F (emil-lc)
marked this pull request as ready for review
August 26, 2026 19:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
_create_runand_update_runtook the compressed (zstd) path only when all sixper-call auth arguments were
None. Any replica carrying e.g.api_url/authfell through tothe uncompressed
tracing_queue, silently. UsingLANGSMITH_RUNS_ENDPOINTSalways produces that shape, so the whole documented multi-endpoint configuration paid the
uncompressed cost.
This was no accident - a zstd frame had nowhere to record where it should be POSTed.
With this PR the frame now carries the missing field.
CompressedTraces.destinationsrecords where aframe goes,
accepts()admits only ops bound for the same place, and the sender routes byit (
Nonekeeps the old_write_api_urlsbehaviour). The check, the commit and the writehappen in one hold of the existing lock.
There is still one frame per client, so when a client has several destination sets only one is
compressed: the first to write owns it, and
reset()deliberately does not cleardestinations, so ownership is decided once instead of re-raced after every flush. Therest use the plaintext queue, exactly as today - nothing is worse than before. A one-time warning
replaces the silence.
create_feedbackis the third writer into that frame and gets the same check.Release Note
Replicas hitting the same destination URL now use compressed trace ingestion instead of silently falling back to plaintext. Payloads sent to different projects are bundled in the same zstd Multipart frame, greatly reducing the memory footprint (e.g 8 replicas go from ~90MB -> ~2MB)
Test Plan
python/tests/unit_tests/test_replica_compression.py(new, 25 tests): no cross-destination bleed with decompressed frame bodies, stable ownership across flushes, feedback kept out of a replica-owned frame, concurrent admission vs. drainNone-key andservice_key-only casesapi_urls={A,B}still replays one frame to both; project-only replicas unchanged; existingtest_multiple_endpoints.py/test_replica_endpoints.pyuntouched and passingLANGSMITH_ENDPOINT; passes when cleared)