Skip to content

SQL performance: measure the three unmeasured M0 items — per-request identity reads, sharing scope, roll-up recompute — then file what pays (epic #33631 R8/R9/R10) #33701

Closed

Description

@objectstack-fleet

domain:server#5 · os-elon-musk · session_016WV4cztR1A2CZoxSZyuoGP

Filing gate: ④ child of epic #33631 (SQL performance). Item R8–R10 of the M0 ranked list (#33633): #33631 (comment) (corrected 6889939163). Maintainer's pick (seat decision card, 2026-11-15T06:44Z): 「R1 R7 R12 各一张+测量卡」.

What is unmeasured

  • R8 per-request identity and permission resolution: a plain list is 10 statements, 2 of them data (cold ~21; resolve-authz-context.ts ~2406 reads the organization's member list up to 1000 rows a page). The grants cache exists and is OFF by default (OS_AUTHZ_GRANTS_CACHE_TTL_MS=0). Cheap on a local database; on a network database (Turso, managed PG) each is a round trip. Measure over a network.
  • R9 sharing read scope materializes sys_record_share.record_id (limit: 5000) into id IN (…) on every member read of a private object (sharing-service.ts ~747–764); hierarchy scopes expand owner ids in the app. Needs a share-seeding leg in the bench. Target shape: id IN (SELECT record_id FROM sys_record_share WHERE …).
  • R10 roll-up summary recompute: per distinct parent per summary field, one aggregate + one full engine update on every child write (engine-summaries-and-expansion.ts ~458–470). Needs summary fields in the fixture.

Output

Bench legs for all three on the M0 harness, numbers on both dialects (and over a network for R8), and a short ranked addendum on #33631. The seat files an M2 card for each item that pays. No product code in this card.

Reader

domain:server#5 area A3 (owner of the M0 bench), next account; size M.

Epic rules

Activity

  1. added
    enhancement
    priority:p2
    pm:queue
    domain:server
    on Nov 15, 2026
  2. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jRmmALkM1ftZxdVatQ

    Claim: PM loop round 1 (area S2, #33751 §2)
    Session: session_01QsR2jRmmALkM1ftZxdVatQ
    Account: zhuangjianguo
    Branch: claude/area-A3-33701
    Worktree: /home/claude/wt/area-A3-33701
    Domain: domain:server
    Seat: domain:server#5
    File surface: packages/qa/dogfood/bench/sql-perf/** (bench legs and fixture only; no product code) (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: TIER_DEFAULT (dispatch-gates --tier: no path-derived mandate), effort: high (M, epic #33631 measurement child)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: n/a — not a defect card
    Thread-read: none
    Premise: holds (R8/R9/R10 unmeasured per ranked list 6889544281; bench merged in PR #33662)
    Serial constraints cleared: #33652 (os-elon-musk) touches no bench file; #33664 / #33699 (this area, in flight) may run the bench but do not edit it

  3. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 15, 2026
  4. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jVPGBoi3MCGoKbW1Hv

    Input for the sharing-scope item (R9) · 2026-11-15T10:09Z · from the review of PR #33771 (#33683, review-a comment 6892781240)

    PR #33771 keeps one sys_record_share row per (rule, recipient), not one per (record, recipient). A user whom k rules reach on N records now holds k·N rows. The 5000-row read cap in buildReadFilter / buildWriteFilter is therefore reached sooner, and past it some access is dropped silently (N ≤ 5000 < k·N). When R9 measures the sharing scope, please count this per-rule row multiplier. The remedy the reviewer names is the in-database share semi-join, which removes the cap, rather than a bigger cap.

  5. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#5 · zhuangjianguo · session_01QsR2jRmmALkM1ftZxdVatQ
    os-dev-report

    {
      "issue": 33701,
      "status": "done",
      "branch": "claude/area-A3-33701",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/33783",
      "session": "session_01QsR2jRmmALkM1ftZxdVatQ",
      "premise_still_valid": true,
      "summary": "Bench legs for R8, R9 and R10 on the M0 harness (packages/qa/dogfood/bench/sql-perf only, no product code): bench.mjs gains --shares (sys_record_share grants to the member), --db-latency-ms (in-process TCP delay proxy in front of PostgreSQL), --grants-cache-ttl-ms and --sql-log (every statement of one warm request, member included), plus public_list_tiny and 15 roll-up write scenarios over three fixture pairs bench_roll0..2 (0/1/2 summary fields); micro.mjs gains I9 (share scope: id-list vs sys_record_share subquery) and I10 (roll-up recompute: 80 vs 11 statements), both checking answers. Measured on SQLite and a private PG 16 cluster (and through the proxy at 2 and 10 ms RTT for R8); the ranked addendum is comment 6893156419 on #33631, stamped with PR head ae8ecd623. Ranking: R10 (updateMany recomputes per child ROW per summary field: 358/558/758 statements for 0/1/2 summaries) > R9 (grants read twice per list; target 3x on the PG scope statements; carries H2) > R8 (identity 8 statements/request, pays only on a network DB; grants cache cuts it to 2). H2 reproduced on both dialects: past 5000 grants the rest are silently dropped (6000 grants: 6000 of 7000 accounts visible, GET of the 6000th granted account answers 404 RECORD_NOT_FOUND) - flagged under out_of_scope_findings for the seat to file, not fixed.",
      "tests": "No test files (bench not collected by vitest; no tested behaviour changed, so no ablation). Each leg proves its path by an in-harness control, all from this card's runs: R9 shares 0/900/5000/6000 -> member account total 100->1000 (100k), 1000->6000->6000 (1M, expected 7000 at 6000 grants: 'VISIBLE ROWS MISMATCH: the member reads 6000 accounts; it owns 1000 and holds 6000 read shares (expected 7000)'), by-id probe 'shared account ac00009998 read by the member by id: 404' at 6000 vs 200 at 5000, largest member statement 4 binds at 0 grants vs 902 at 900 (--sql-log). R10 0-summary control: createMany 50 rows 1 parent 209/213/217, 10 parents 209/249/289, updateMany 358/558/758, single insert 13/17/21 statements, identical on both dialects; captured SQL shows 'select sum(quantity) as value from bench_roll2_item where parent = ?', 2x 'select * from bench_roll2 where id = ? limit ?', 'update bench_roll2 set id = ?, total_quantity = ?, ...' only on N>=1. R8: 'select 1 direct 0.1 ms, through the proxy 2.4 ms (injected 2 ms)' / '10.6 ms (injected 10 ms)', 4394-5676 chunks forwarded; cache-on boot line '[authz-cache] grants cache ENABLED (ttl=60000ms)', public list 10 -> 4 statements. micro I9 (1M, 5000 grants, same answers): SQLite account scope 18.3 -> 12.1 ms, PG 21.6 -> 7.0 ms; at 6000 grants target answers 7000 vs today 6000. micro I10: SQLite 1.65 -> 0.20 ms, PG 15.83 -> 2.15 ms, 'same values'. Every bench run under os-verify-lock, each 'VERDICT command-exit 0'. Fixture type check: tsc --noEmit on the fixture via the dogfood tsconfig red first (TS2322 widened literals in the helper), exit 0 after typing it ServiceObject[] / Field. Final smoke on e1b0a1902: sqlite 10k --shares 50, rollup1_insert_p1 213 statements, rollup2_update_p1 758, both shared reads 200.",
      "gates": "On final head ae8ecd623: dispatch-gates --commands --repo objectstack-ai/objectstack -> 46 commands (4 paths, 8 whole-tree); 44 exit 0; 'pnpm check:dual-build-cjs-loads :: exit 3' (PREREQUISITE NOT MET, packages outside the CLI closure have no dist) NOT MEASURED; 'pnpm check:dts-closure :: exit 1' because the local closure was built with OS_SKIP_DTS=1 (missing .d.ts in every package, e.g. packages/adapters/hono/dist/index.d.ts) - not a reading of this diff, CI's run is. --ran reconciliation exit 0: '46 derived famil(ies) accounted for - 45 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)'. check-plugin-teardown-shape --self-test exit 0 after git fetch --depth=1 of its pinned fixture commit. PR body gates on the final body: check-changeset-no-major --base origin/main exit 0, check-adr-0087-registration exit 0, check-closing-keyword-parity exit 0, check-partof-closing-keyword exit 0. eslint on the 3 bench sources: 0 errors 0 warnings. check:nul-bytes exit 0. PR check-runs: in_progress at report time (not awaited, per contract).",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "3 — fleet-write relay dispatches (POST /repos/objectstack-ai/objectstack/dispatches): pr_create (#33783, labels skip-changeset, no assignees), post-stamped comment on #33631 (6893156419), post-stamped os-dev-report comment on #33701; git push is not a REST write",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "class: a · reach: public door GET /data/bench_account/ac00009998 as a member holding a read grant on it answers 404 RECORD_NOT_FOUND (and GET /data/bench_account lists total 6000 where 7000 are owned+granted) once the member holds more than 5000 user grants on the object; reproduced on SQLite and PostgreSQL 16 with bench.mjs --scale 1000000 --shares 6000 --only scoped_account_list (control --shares 5000: 6000/6000, both by-id reads 200); real producer of that many rows: sharing rules materialize one sys_record_share row per record per recipient · evidence: SharingService#buildReadFilter reads sys_record_share with limit 5000 ordered by id and binds only those record_ids (packages/plugins/plugin-sharing/src/sharing-service.ts, the grants read above grantedRecordIds); silent fail-closed, 200 with fewer rows · dedupe words: sys_record_share limit 5000, grants past 5000 dropped, shared record 404 RECORD_NOT_FOUND, buildReadFilter grant cap",
        "carrier: none · noted, not filed (PR Acceptance notes and addendum 'Not ranked'): batch writes are per-row N+1 even with no summary field (createMany 2 master reads + audit + activity insert per row = 209 statements per 50 rows; updateMany 4 child reads per row = 358); member reads of private objects read sys_queue once per scoped statement; analytics member path ANDs the share-scoped chain twice (R4 family); with 2 summary fields the same parent is updated once per field"
      ],
      "deviations": [
        "PR body cannot link the addendum comment: it was written at pr_create, before the addendum existed (the card asks the addendum to come after the PR is open, stamped with its head sha); dev does not PATCH PR bodies. It points to #33631 instead; the seat may add the link https://github.com/objectstack-ai/objectstack/issues/33631#issuecomment-6893156419",
        "pr_create sent no assignees (area common rule 3) where os-dev.md rule 2 names the claim's Account: - area rule followed",
        "repo-wide pnpm lint (area common rule 6) not run locally; os-dev.md assigns repo-level scans to CI. eslint ran on the three touched sources",
        "full @objectstack/dogfood typecheck declared to CI: locally it needs the d.ts of the whole closure, which the OS_SKIP_DTS build does not emit; narrowed to the fixture file through the same tsconfig (red then green)",
        "commit trailers are Co-Authored-By: Claude plus Claude-Session per the repo hook and project memory, not the harness's model-named trailer; the merge commit ae8ecd623 carries git's default message",
        "bench numbers span three bench commits (45aa1a521, 1634e0714, 697ba8f9f) over one engine tree a557fa386; later bench commits changed only the new legs, not the timed paths. The 11 commits merged from origin/main at the end were not re-benched (numbers stamp a557fa386)",
        "PostgreSQL ran with fsync=off and synchronous_commit=off for the whole run, not only the load (write ms understated)",
        "pnpm install ran as a harness background task awaited to completion, not a plain foreground call"
      ],
      "files_changed": [
        "packages/qa/dogfood/bench/sql-perf/README.md (+43 -2)",
        "packages/qa/dogfood/bench/sql-perf/app/objectstack.config.ts (+64 -0)",
        "packages/qa/dogfood/bench/sql-perf/bench.mjs (+296 -17)",
        "packages/qa/dogfood/bench/sql-perf/micro.mjs (+141 -5)"
      ],
      "line_budget": "+544 / -24 over 4 files, all inside the claim surface packages/qa/dogfood/bench/sql-perf/**; under the 3000-line human-merge threshold",
      "loose_ends": [
        "R8 M2 shape not measured as SQL: a request-scoped memo of the duplicate sys_user and sys_member reads; making the grants cache default-on is a ruling question (grants-cache ruling Fork 4), not a code card",
        "R9 hierarchy scopes (own_and_reports, unit*) and team/role/rule grants not measured: the fixture has no hierarchy",
        "R10 writes not timed through the network proxy (stated as statements x measured RTT)"
      ]
    }
  6. added a commit that references this issue on Nov 16, 2026
    3378e21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:datadomain:serverenhancementpm:dispatchedpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions