Record chart startup and metadata-cache follow-ups

Preserve the cold-start dependency analysis and a bounded planning
assignment for earlier TSDB history display and chart readiness
indicators. Distinguish storage reads, SHM publication, Flume
delivery, first paint and interactive readiness; measure warm
reopen separately, including power-profile and throttle effects.

Link provider-owned cache-first resolution to that startup work:
- pass normalized/native metadata into quote startup once;
- separate Binance client construction from eager exchange-info
  fetching so disk-cache hits can actually avoid network startup;
- define shared refresh, miss retry, freshness and alias invalidation
  without pinning continuous requests in the canonical feed registry.

Retain source references, proof boundaries and offline verification
criteria. The live AC comparison found no noticeable regression,
not a measured speedup. Preserve existing task/checklist states;
these additions record follow-up work, not implementation acceptance.

(this plan was generated in some part by `opencode` using
`openai/gpt-6-astra` (`openai`))
wkt/federated_project_stores
Gud Boi 2026-11-02 18:52:26 -05:00
parent 5e27b06870
commit eca2c481d7
1 changed files with 216 additions and 0 deletions

View File

@ -1866,3 +1866,219 @@ Return retention traces, ledger-correlation findings, links to any
offline dark-order storage assignment, lifecycle tests and proposed offline dark-order storage assignment, lifecycle tests and proposed
policy to this task. Preserve human-owned task and checkbox states. policy to this task. Preserve human-owned task and checkbox states.
* TODO Measure chart startup gates and publish history readiness early
:PROPERTIES:
:ID: piker-chart-startup-latency-readiness
:CREATED: [2026-11-01]
:CARRIED: 0
:REPO: /home/goodboy/repos/piker
:CATEGORY: piker.data
:TAKEN_APPEND_OP: piker-chart-startup-latency-20261101
:TAKEN_APPEND_REQUEST: 3902f8d4a87be19a5723e59de23af43dc4686e79673e3ed47f9477aa2aca49b3
:END:
Reduce time from Qt-process startup to visible TSDB history, without
waiting unnecessarily for live quotes, current bars or remote gap
repair. Expose separate readiness indicators in the chart.
Next action: instrument cold boot and warm chart reopen independently
on the selected runtime/feed branch. Capture a timeline before
choosing changes. Finish the current canonical-feed allocation fix
first; this task is follow-up investigation/planning, not acceptance
of that patch or authorization for live Gateway operations.
Evidence and limits:
The human reports slow initial history display and confirms that
Binance warm reopen also feels slow. The earlier claim that skipping
cold-feed gates explains the whole difference was incomplete: warm
reopen skips allocation only when a healthy matching feed exists,
and does not skip Qt/import/IPC/SHM/graphics/FSP/order-mode work.
No startup latency benchmark has yet been collected here.
The analysis below is a source-path observation from
wkts/ib_downstream_pin_eval, not measured attribution. That checkout
contains ongoing human-reviewed feed and sampler edits; re-read the
current definitions before implementing or pinning line numbers.
Observed startup sequence and gates:
1. `display_symbol_data()` awaits `open_feed()` before constructing
the history plot. `open_feed()` starts/finds datad actors, awaits
all provider contexts, attaches SHM and opens streams before
yielding. `open_feed_bus()` allocates requested symbols serially;
a slow endpoint can delay presentation of other requested data.
2. The feed allocator resolves metadata, then awaits the quote-task
startup handshake before starting `manage_history()`. For an open
IB venue, `stream_quotes()` gets a snapshot and enters the quote
subscription before reporting startup. `Client.get_quote()` can
wait for ticker updates (defaults: 100 attempts, 1s timeout each).
These are potential bounds, not observed normal boot latency.
3. `manage_history()` opens storage, waits up to 0.5s for the live
flag, then opens/starts samplerd before the history loaders.
It starts the 60s and 1s `tsdb_backfill()` tasks with sequential
awaited `.start()` calls. Both handshakes gate its SHM-handle
delivery, and therefore delivery of the `Flume` to the chart.
4. `tsdb_backfill()` opens the provider history client before its
storage read. It then reads TSDB history concurrently with the
latest provider-frame request, but joins both before publishing.
`publish_latest_frame()` persists that remote frame to storage
before pushing it into SHM and reporting initial readiness.
5. Older TSDB rows are not published merely because the read is done.
The reverse `start_backfill()` nursery first finishes bridging
the remote-history gap, then `_prepend_tsdb_history()` places the
cached rows beside the resulting provider boundary. Slow remote
retrieval/pacing recovery can thus delay showing already-read
local history. Distinguish initial Flume delivery from actual
publication of the cached history the user wants to see.
6. In `display_symbol_data()`, history-plot construction and graphics
update-task startup precede `open_order_mode()`. Brokerd/account
setup is not an explicit prerequisite for plot construction on
this path, but does gate later input-handler setup. Measure actual
first paint and interactivity rather than inferring them from
construction order alone.
Source references:
[[file:../../ib_downstream_pin_eval/piker/data/feed.py::async def maybe_allocate_persistent_feed][Endpoint resolution/reuse and allocation ownership]]
[[file:../../ib_downstream_pin_eval/piker/data/feed.py::async def open_feed_bus][Per-symbol initialization and Flume delivery]]
[[file:../../ib_downstream_pin_eval/piker/data/feed.py::async def open_feed(][Client-side provider/context/stream gather gates]]
[[file:../../ib_downstream_pin_eval/piker/brokers/ib/feed.py::async def stream_quotes][IB first-quote startup handshake]]
[[file:../../ib_downstream_pin_eval/piker/brokers/ib/api.py::async def get_quote][Snapshot wait/retry behavior]]
[[file:../../ib_downstream_pin_eval/piker/tsp/_history.py::async def manage_history][Sampler and sequential timeframe startup]]
[[file:../../ib_downstream_pin_eval/piker/tsp/_history.py::async def tsdb_backfill][Storage/provider join and delayed TSDB publication]]
[[file:../../ib_downstream_pin_eval/piker/tsp/_history.py::async def publish_latest_frame][Persist-before-SHM publication]]
[[file:../../ib_downstream_pin_eval/piker/ui/_display.py::async def display_symbol_data][Plot construction and order-mode sequencing]]
Measurement and diagnosis:
- [ ] Use the existing profiler conventions to correlate milestones
across processes: Qt/import start, datad lookup/spawn, metadata
lookup/cache hit, quote-ready, storage-read start/end, samplerd
readiness, provider frame response, persistence, Flume delivery,
cached-history SHM publication, FSP readiness, first history paint
and interactive readiness.
- [ ] Compare fresh datad versus warm datad/restarted chart, single
versus multiple symbols, IB versus Binance, and local-storage hit
versus missing history. Record actual feed-registry reuse.
- [ ] Investigate synchronous disk/CPU work and scheduler stalls
separately from explicit awaited startup dependencies. Backfill
and live quote processing must not inadvertently block each other.
- [ ] For Binance warm reopen, trace client/UI work and remaining
feed handshakes instead of assuming remote cold-start gates apply.
Proposed design direction, to validate before implementation:
- [ ] Separate history-display readiness from live-sampling readiness.
Resolve endpoint identity, allocate buffers, publish usable local
TSDB data and allow the chart to draw independently of live quotes.
- [ ] Bring up quotes/current bars and remote gap repair concurrently
where provider contracts permit it; make required ordering explicit.
- [ ] Define reconciliation/index ownership before publishing TSDB
first. Current placement intentionally waits for provider boundaries;
merely moving `.started()` can break SHM indices and FSP/graphics
consumers. Preserve real/synthetic sample provenance and notify
consumers of relevant revisions.
- [ ] Define chart-visible states for cached history ready, refreshing
history, live quotes/current bars ready, delayed/disconnected, and
failed/unavailable. Do not equate history-ready with live trading.
Related work:
[[id:piker-feed-delayed-event][Explicit feed-delay events and chart consumers]]
[[id:piker-fsp-backfill-sync-review-and-commit][FSP/history synchronization contracts]]
These are dependencies/related contracts, not duplicate assignments
or evidence that startup-readiness indicators already exist.
Verification and handback:
- [ ] Add deterministic barrier-driven tests proving cached history
can be drawn while provider quote/history responses are withheld.
- [ ] Verify live quote progress during backfill, stable writer
ownership, cancellation/teardown, overlap reconciliation, no data
loss/duplicate samples, and correct FSP/graphics refresh.
- [ ] Preserve warm-reopen reuse and compare before/after milestone
distributions under the same environment. Avoid unsupported latency
guarantees or arbitrary sleep-based correctness assertions.
- [ ] Return measured critical paths, proposed API/readiness states,
index/reconciliation design, regression evidence and unresolved
provider/UI costs to this task before implementation is accepted.
Use disposable storage and private actors for automated checks.
Do not reset farms, place orders or modify production TSDB data as
part of this follow-up without separate human authorization.
* TODO Resolve feed metadata once using provider-owned symcache
:PROPERTIES:
:ID: piker-feed-cache-first-resolution
:CREATED: [2026-11-02]
:CARRIED: 0
:REPO: /home/goodboy/repos/piker
:CATEGORY: piker.data
:TAKEN_APPEND_OP: piker-cache-first-resolution-20261102
:TAKEN_APPEND_REQUEST: cfbc7cd8ecf3b45ad90976cee80d14ed7c690069b62f0fe25be1979e19eedb30
:END:
Define a cache-first resolution contract owned by each provider,
invoked by the data layer before canonical feed lookup, and pass
both normalized and native metadata into quote startup.
Next action: inspect current SymbologyCache/provider contracts and
measure cold/warm metadata costs before changing backend startup.
Coordinate with [[id:piker-chart-startup-latency-readiness][Chart startup and readiness]].
Context:
The canonical-feed fix resolves get_mkt_info() before allocation,
but discards the provider-specific second return value. Backends
then resolve again inside stream_quotes(). IB and Binance currently
use process-local async_lifo_cache(), keyed by request spelling, so
same-spelling calls normally reuse results without network I/O.
This is distinct from persistent symbology caching.
Binance Client construction currently fetches exchange information
for spot and USD-margined futures before yielding. A disk lookup
after that initialization would not remove this cold-start gate.
Its websocket startup also waits for L1 and trade data before
reporting readiness; metadata caching alone does not remove that
independent gate.
SymbologyCache already pairs canonical mktmaps with backend-native
pairs and serialization namespace paths. Its load() checks the
relationship between get_mkt_pairs() and get_mkt_info() results.
Audit those contracts before inventing a new representation.
[[file:../../ib_downstream_pin_eval/piker/data/_symcache.py][SymbologyCache tables, loading and serialization]]
[[file:../../ib_downstream_pin_eval/piker/brokers/binance/api.py::async def get_client][Binance eager exchange-info initialization]]
[[file:../../ib_downstream_pin_eval/piker/brokers/binance/feed.py::async def stream_quotes][Binance metadata and live-data startup gates]]
[[file:../../ib_downstream_pin_eval/piker/brokers/ib/symbols.py::async def get_mkt_info][IB metadata resolution/cache boundary]]
Proposed contract to investigate:
- [ ] Keep _FeedsBus.feeds canonical-only. Explicit endpoint requests
retain the direct lookup; unresolved aliases use provider-owned
resolution, not data-layer guesses about front contracts.
- [ ] Return usable cached MktPair/native metadata together, before
remote refresh when policy permits. The data layer inspects the
normalized identity and carries native metadata opaquely.
- [ ] Pass the resolved result into stream_quotes(); require no
further market-info query on the persistent-feed startup path.
Audit standalone callers before making that input required.
- [ ] Separate Binance client construction from eager metadata
fetching so persisted cache hits actually avoid network startup.
- [ ] Own one shared background refresh per provider service, with
miss-triggered awaited refresh/retry and explicit failure/freshness
reporting. Avoid one refresh per chart or request.
- [ ] Publish normalized/native metadata coherently; distinguish
stable dated contracts from time-sensitive continuous aliases.
Define invalidation without changing an already-running endpoint.
Verification and performance evidence:
- [ ] Test persisted-cache hits without network access, concurrent
miss refresh sharing, failed refresh preserving usable data,
consistent pair identity and explicit alias/roll invalidation.
- [ ] Assert quote startup consumes resolved metadata without another
resolver/details query; preserve canonical Flume/SHM reuse.
- [ ] Compare cold process versus warm chart reopen and record AC or
battery, power profile and effective chart/quote throttle settings.
Separate Flume receipt from first history paint/interactivity.
The human reports full Binance boots with the feed changes stashed
feel comparable to patched boots on AC. Earlier warm-reopen slowness
may have been affected by battery throttling; neither observation
is a latency benchmark or proof of backend causation.
Handback:
Return measured costs, provider capability/typing findings, proposed
cache ownership and refresh policy, startup API migration boundaries,
and deterministic regression evidence to this task. Use disposable
cache/storage and private actors; live broker operations require
separate authorization. Preserve human-owned task states.