Skip to content

Grab-bag of small copy/byte cleanups from the transport audit #176

Description

@Alek99

From a full data-transport audit at b0f8780. Individually small; batch when touching the files:

Python encode:

  • Split-mode ship_u8 pads via full-buffer np.concatenate (python/xy/_payload.py:82-90); padding is structurally unnecessary in split mode (each buffer starts at offset 0) — kept only for the byte-identical-repack invariant (tests/test_figure.py:90).
  • Constant-baseline area/error_band materialize + ship an N-length constant column (python/xy/marks.py:881, _emit_area); bars already have the value0_const scalar optimization (_payload.py:819-822) — mirror it.
  • direct_rgba packing makes 3 full-size f64 temporaries: np.rint(np.clip(v,0,1)*255).astype(u8) (python/xy/channels.py:540) — chain with out= or a native kernel.
  • Rect center column built with chained temporaries (python/xy/_figure.py:956); hexbin emitter re-scans min/max via ship_values instead of reusing its Columns' zone maps (_payload.py:501-502).
  • Datetime ingest pays 2 copies where a fused native i64→f64-ms kernel needs 1 (python/xy/columns.py:425-437; copy counts pinned in tests/test_figure.py:190-191).
  • memory_report runs a full payload build just to report first-paint bytes (python/xy/_figure.py:1771).

Transport / hosts:

  • Reflex serves a fresh build_payload_split() per subscriber (python/reflex-xy/reflex_xy/namespace.py:128-145) — cache on (figure version, px bucket).
  • payload_asset joins the packed blob and then encode_frame joins again (payload_asset.py:68_framing.py:200-208) — write encode_frame_parts sequentially, hash incrementally.
  • _repr_html_ html.escape doubles the doc (python/xy/_figure.py:1643-1645).

Client:

  • tier_update reallocates STATIC_DRAW buffers per refinement; bufferSubData when byteLength matches (js/src/54_kernel.ts:294-306).
  • Single style channel pads to vec4 per point (16 B/pt) in three copy-pasted loops (50_chartview.ts:2102, 45_lod.ts:289, 50_chartview.ts:2305) — scalar cases could be uniforms.
  • Append animation matching builds O(n) toPrecision(12) string keys (js/src/56_animation.ts:286-296) — numeric-key Map on fround bits.
  • Sync 1x1 readPixels per pointermove + pick re-render during density blend easing (50_chartview.ts:4437-4471) — async fence readback if it shows in profiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs investigateAudit finding awaiting validation/measurementperformanceReduces copies, bytes, or CPU on the data path

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions