You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit de3cb06
Browse filesBrowse the repository at this point in the historyBrowse files
buffered_table: relocate init metadata to BoundStorage; remove process global (review §2)
Previously vgi/worker.py held a module-level dict
``_buffered_table_exec_cache: dict[execution_id, (func_cls, params)]``
populated at init (phase=BUFFERED_TABLE) and read by the three
buffered_table_{process,combine,finalize} handlers. The dict was never
popped — permanent memory leak per query for the worker's lifetime —
and forced the C++ Sink+Source operator to pin one worker per execution
because RPCs landing on a worker that didn't run init would raise
"execution not initialized."
This commit moves the bind/init metadata to FunctionStorage:
* At init (phase=BUFFERED_TABLE), persist the (InitRequest,
GlobalInitResponse) byte envelopes under namespace b"buf_init", key
pack_int_key(_BUFFERED_TABLE_INIT_KEY).
* Add ``_load_buffered_table_params`` helper that on every RPC resolves
the function class by name (registry-driven, available on every
worker), reads the persisted envelopes from FunctionStorage, and
rebuilds ProcessParams via the same construction the init handler
performs (args parsed via _parse_arguments, settings via
_batch_to_scalar_dict, secrets via SecretsAccessor).
* Drop ``_buffered_table_exec_cache`` entirely.
Workers are now stateless w.r.t. buffered_table executions. Any pool
worker can serve any RPC for any execution_id; the C++ side's sticky-
worker requirement is no longer load-bearing on the worker-side cache.
Cost: one extra ``state_get(b"buf_init", ...)`` per RPC. Negligible on
subprocess transport (SQLite via WAL is microseconds). On CfDo this is
one HTTP RTT per RPC — bench shows +10-15% on the heavy 100k×1024B
cells. If that surfaces as a real bottleneck in HTTP deployments, the
mitigation is to thread the metadata bytes through the request envelope
from C++ (out of scope here).
Tests: all 14 buffered_table integration tests pass. vgi-python suite:
31 failed / 1651 passed — baseline failure count unchanged.
The ``_buffered_table_finalize_iters`` dict is intentionally NOT
relocated: it holds generator stack frames, which are intrinsically
process-local. The destructor RPC (next commit) will pop orphaned
entries; steady-state finalize sequences self-clean on StopIteration.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments