Reduce transport allocation and client hot-path overhead#196
Conversation
Merging this PR will improve performance by 32.74%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_first_payload_area_core_2d |
9.5 ms | 7.2 ms | +32.74% |
| 🆕 | test_datetime_seconds_fused_one_copy_ingest |
N/A | 3.1 ms | N/A |
| 🆕 | test_first_payload_scatter_direct_rgba |
N/A | 12.1 ms | N/A |
| 🆕 | test_first_payload_stacked_bar_reuses_category_geometry |
N/A | 430.7 ms | N/A |
| 🆕 | test_hexbin_payload_reuses_precomputed_center_bounds |
N/A | 960.3 µs | N/A |
| 🆕 | test_memory_report_counts_without_payload_blob |
N/A | 7.4 ms | N/A |
| 🆕 | test_notebook_repr_line_streams_escaped_document |
N/A | 11.9 ms | N/A |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing agent/transport-quick-wins (6e96a70) with main (2a7d898)
Footnotes
-
1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩
Greptile SummaryThis PR reduces transport and rendering hot-path allocations. The main changes are:
Confidence Score: 5/5This looks safe to merge. No blocking issues found in the changed code.
What T-Rex did
Important Files Changed
Reviews (1): Last reviewed commit: "Optimize client transport hot paths" | Re-trigger Greptile |
Closes #176
Summary
Completes the transport-audit grab-bag with measured, independently reviewed changes across Python encoding, host framing, browser upload/draw paths, and reporting. The two proposed alternatives that did not preserve behavior or latency are retained as documented non-wins rather than shipped optimizations.
Disposition of every audit item
ship_u8padding copydirect_rgbafull-size temporariesship; a regression makes any fallbackmin_maxscan fail.memory_reportfull payload buildpayload_assetdouble joinsbufferSubDataupdates same-byte-size buffers; size changes keep the safebufferDatapath.toPrecision(12)stringsMath.fround, and f32-bit candidates changed identity boundaries or collided; parsed-decimal numeric keys retained string allocation and were slower. Production semantics remain unchanged, with counterexamples committed as oracles.Draft PR #194 separately handles client hexbin fan instancing; it complements, but does not substitute for, item 5 here.
Performance evidence
Fresh reproducible local measurements, optimized versus the prior path:
Rejected append-key alternatives
On 200,000 offset-encoded epoch values (base
1700000000000, step 1024, differing offsets), bothMath.froundand reusable f32-bit keys collapsed 200,000 legacy identities into only 1,563 keys, produced 198,437 collisions, and mapped only 1,563 rows to the correct old index. Even the base and base+1024 collided. Legacy decimal keys remained 200,000/200,000 unique and correct. Parsing the same decimal strings into numeric Map keys preserved identity but was slower (41.5 vs 36.6 ms), so no production change is justified.Rejected asynchronous picking
A clean synchronous 1×1 read measured at or below 0.1 ms. Dirty cost came from the required point redraw: 23.0 ms at 250k and 98.7 ms at 1M. The PBO/fence prototype completed its first result in about 4.0 ms and was unavailable in the first task in 13/14 trials, which would add tooltip latency and cancellation complexity. The branch instead removes needless dirty frames and reuses the result allocation.
Verification
Final exact integrated tree:
node js/build.mjs --check: committed bundles freshtsc -p js/tsconfig.json --noEmit: passedgit diff --check: passedThe one deselection is
tests/reflex_adapter/test_assets.py::test_client_source_is_the_installed_bundle. This branch leaves that test byte-for-byte equal tomain; run alone, it reproduces the known stale assertion that searches minified Vite output for unmangled source spellings. Its semantic export-marker correction remains scoped to draft PR #189.Reproducible client profiling is committed as
benchmarks/bench_client_transport_quick_wins.py; backend microbench contracts are committed inbenchmarks/test_codspeed_kernels.py.