Skip to content

perf(appkit): collapse per-save typegen client churn in dev [F2]#424

Draft
atilafassina wants to merge 1 commit into
mainfrom
typegen-fix/perf-churn
Draft

perf(appkit): collapse per-save typegen client churn in dev [F2]#424
atilafassina wants to merge 1 commit into
mainfrom
typegen-fix/perf-churn

Conversation

@atilafassina

Copy link
Copy Markdown
Contributor

PR2 of the typegen review-fix stack. Independent of PR1 (branches off main).
Scope: make the dev hot path build one WorkspaceClient and issue one
warehouse status RPC per save (F2).

Changes

  • query-registry.ts — construct WorkspaceClient lazily via a memoized
    accessor, only on the blocking preflight / DESCRIBE paths. Non-blocking and
    all-cached runs build zero clients; the blocking path builds exactly one,
    shared by the preflight probe and the DESCRIBE batch.
  • vite-plugin.ts — one-waiter re-arm in armWarehouseWatch: rapid .sql
    saves coalesce onto the single in-flight watch (its trailing blocking
    regenerate re-reads the query folder) instead of each aborting + recreating a
    watch (which fanned out a client + probe per save). Sticky/escalate-only
    pendingMode so a coalesced non-blocking save can't downgrade a queued
    blocking describe (real types still land).

Acceptance criteria (all asserted by tests)

  • A single dev .sql save → exactly one WorkspaceClient + one warehouses.get.
  • Five rapid saves → no fan-out: one waiter, one client, one probe.
  • A non-blocking save during a background warm-up does not downgrade the pending
    blocking describe.
  • Non-blocking / all-cached runs construct zero WorkspaceClient.

Checks

pnpm test (type-generator + shared CLI), pnpm -r typecheck, pnpm check,
pnpm --filter @databricks/appkit build:package all green.

This pull request and its description were written by Isaac.

Hardens the non-blocking typegen redesign (PR2 of the review-fix stack):
make the dev hot path build one WorkspaceClient and issue one warehouse
status RPC per save, instead of one apiece for every rapid edit.

- query-registry.ts: construct WorkspaceClient lazily (memoized accessor)
  only on the blocking preflight / DESCRIBE paths. Non-blocking and
  all-cached runs now build zero clients.
- vite-plugin.ts: one-waiter re-arm in armWarehouseWatch — rapid .sql
  saves coalesce onto the single in-flight watch (whose trailing blocking
  regenerate re-reads the folder) rather than each aborting + recreating a
  watch (client + probe per save). Sticky/escalate-only pendingMode so a
  coalesced non-blocking save can't downgrade a queued blocking describe.

Tests: vite-plugin (single client+get per save, no fan-out on 5 saves,
latch release, sticky mode); generate-queries (lazy client: zero on
non-blocking/all-cached, exactly one shared across preflight+describe).

Co-authored-by: Isaac
Signed-off-by: Atila Fassina <atila@fassina.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant