Skip to content

perf(native): avoid directory observation bigint buffers - #665

Closed
steipete wants to merge 4 commits into
mainfrom
codex/native-directory-record-owner-20260925
Closed

steipete wants to merge 4 commits into
mainfrom
codex/native-directory-record-owner-20260925

Conversation

@steipete

@steipete steipete commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Native directory observations currently build intermediate Rust records and allocate temporary vectors for each bigint field. Return the existing N-API records directly and use output-only u64 fields, which N-API converts directly into JavaScript bigint values. This removes the intermediate conversions and two temporary word buffers per pathname observation, or four per descriptor observation.

JavaScript field names, bigint types, property order and filesystem checks stay the same. Owned handles close before JavaScript conversion; caller-owned descriptors stay borrowed. Accepted bigint inputs and their lossless validation are unchanged. If N-API bigint creation itself fails, its diagnostic now includes the conversion reason; ordinary filesystem errors are unchanged. The unchanged counter reports 51,372 production lines at 5b90ab8, 25 fewer than baseline 554fd1c.

Independent P2 review is clean. All 24 required current-head checks passed on their first attempts (CI). A fresh matched Linux build passed eight focused Rust tests per revision and installed Node/Bun behavior checks. A separate test-only addon passed all 32 unsigned-bigint boundary calls, including values above 2^53, above 2^63 and u64::MAX. Compiled root JavaScript and declarations match baseline; only the changelog differs in the root package. Native binaries differ, so instruction equivalence is not established.

Performance qualification is INCONCLUSIVE, and this PR remains draft. The fixed comparison completed 32 fresh-process children, 479,232 timed calls and 1,440 sample means. Independent reconstruction confirmed eight source and seven identical-baseline control threshold crossings, all on Root.read(). Control variation prevents causal attribution or acceptance of the change's overall performance. The data and fixed thresholds are retained; no repeat or retuning was performed. No measured speedup or performance-neutrality claim is made.

The earlier 3a0525a implementation and its artifact-only results remain separately preserved; they do not qualify this implementation. The runner was physically released after evidence collection.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 25, 2026, 3:05 AM ET / 07:05 UTC (Revision 3).

ClawSweeper review

What this changes

The branch returns directory observations directly from the native Node binding with unsigned 64-bit fields, updates one Rust assertion, and adds a changelog note.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open. Current main does not contain this optimization, and current-head native tests address the prior bigint compatibility concern. The PR’s matched performance comparison remains inconclusive, so its benefit needs a maintainer decision.

Priority: P3
Reviewed head: 5b90ab86b37ebb2b2ab5f7e8acae7239342333f2
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch and current-head native checks are promising, but the optimization’s runtime effect remains unqualified.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied review state identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Current-head native checks exercise real directory observations on three operating systems; the reported Linux installed Node/Bun and separate unsigned-boundary checks are supportive, while performance attribution remains unresolved. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied review state identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Current-head native checks exercise real directory observations on three operating systems; the reported Linux installed Node/Bun and separate unsigned-boundary checks are supportive, while performance attribution remains unresolved. No stored-data contract changes.
Evidence reviewed 7 items Introduced binding change: The pinned PR diff changes the observation outputs to output-only N-API objects with u64 fields and removes the intermediate BigInt conversion.
Filesystem checks retained: The descriptor observer still compares the retained descriptor, named directory, and final canonical path before returning its record.
Node consumer contract: The binding interface requires bigint identity fields, and the JavaScript observer validates their types before use.
Findings None None.
Security None None.

How this fits together

The native binding observes directory identity and canonical path through filesystem handles. Node receives those observations as bigint fields and uses them in directory guards and mutation checks.

flowchart LR
A[Node filesystem request] --> B[Native directory observer]
B --> C[Open directory handle]
C --> D[Check path and identity]
D --> E[Bigint observation]
E --> F[Node directory guards]
Loading

Decision needed

Question Recommendation
Should this native observation change land as a performance improvement when the matched comparison cannot distinguish its effect from control variation? Wait for controlled qualification: Keep the PR open until a comparison with stable identical-baseline controls establishes the runtime effect.

Why: The code path is focused and current-head contract checks pass, but the stated performance outcome is unqualified; accepting that tradeoff requires maintainer judgment.

Before merge

  • Resolve merge risk (P1) - The matched comparison shows similar Root.read() threshold crossings in the changed build and identical-baseline control, so it does not establish whether the native hot path improves or regresses after merge.
  • Complete next step (P2) - Resolve the inconclusive performance qualification before merge; if accepting this as internal simplification, remove the Unreleased performance note.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Performance threshold crossings 8 changed, 7 identical-control The contributor-reported control variation prevents attributing a runtime improvement or regression.

Merge-risk options

Maintainer options:

  1. Qualify the hot path (recommended)
    Use a comparison with stable same-baseline controls to determine the native observation and Root.read() effect before merge.
  2. Accept an unmeasured simplification
    A maintainer may accept the unknown runtime effect as a code simplification and remove the Unreleased performance note.

Technical review

Best possible solution:

Land the direct observation record after stable controls establish its practical benefit while preserving exact bigint identities and descriptor ownership.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR proposes an optimization rather than reporting broken existing behavior. Current-main source shows the intermediate conversion, but the supplied comparison does not reproduce a reliable performance difference.

Is this the best way to solve the issue?

Unclear: direct record construction is a narrow way to remove the intermediate conversion, but the practical performance effect has not been established under stable controls.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 554fd1c3c3e5.

Labels

Label changes:

  • add merge-risk: 🚨 other: The hot-path runtime effect remains unresolved by the matched comparison despite passing correctness checks.
  • remove merge-risk: 🚨 compatibility: Current PR review merge-risk labels are merge-risk: 🚨 other.

Label justifications:

  • P3: This is a focused allocation cleanup without a reported user-facing failure.
  • merge-risk: 🚨 other: The hot-path runtime effect remains unresolved by the matched comparison despite passing correctness checks.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied review state identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. Current-head native checks exercise real directory observations on three operating systems; the reported Linux installed Node/Bun and separate unsigned-boundary checks are supportive, while performance attribution remains unresolved. No stored-data contract changes.

Evidence

What I checked:

  • Introduced binding change: The pinned PR diff changes the observation outputs to output-only N-API objects with u64 fields and removes the intermediate BigInt conversion. (native/src/lib.rs:54, 5b90ab86b37e)
  • Filesystem checks retained: The descriptor observer still compares the retained descriptor, named directory, and final canonical path before returning its record. (native/src/directory_observation.rs:125, 5b90ab86b37e)
  • Node consumer contract: The binding interface requires bigint identity fields, and the JavaScript observer validates their types before use. (src/native-binding.ts:23, 5b90ab86b37e)
  • Still distinct from main: Current main constructs separate Rust observation records and converts their fields to BigInt at the native export boundary. (native/src/lib.rs:341, 554fd1c3c3e5)
  • Current-head native checks: Run 36102956513 targets the pinned head; its native directory observation step succeeded on Ubuntu, macOS, and Windows. The six installed-package smoke jobs also succeeded, although their package probe does not directly assert the observation fields. (.github/workflows/ci.yml:1089, 5b90ab86b37e)
  • Performance qualification: The PR body reports 8 threshold crossings for the changed build and 7 for an identical-baseline control, all on Root.read(), and expressly calls performance qualification inconclusive. It also reports Linux installed Node/Bun checks and a separate unsigned-boundary addon; those are contributor-reported results rather than an independently inspected trace. (5b90ab86b37e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Establish the native observation and Root.read() effect with stable same-baseline controls, or obtain explicit acceptance as an internal simplification and remove the performance note.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-25T05:12:10.170Z sha 3a0525a :: blocked before merge. :: none
  • reviewed 2026-09-25T06:31:34.367Z sha 5b90ab8 :: blocked before merge. :: none

@steipete steipete changed the title refactor(native): share directory observation records perf(native): avoid directory observation bigint buffers Sep 25, 2026
@steipete
steipete marked this pull request as ready for review September 25, 2026 06:27
@steipete
steipete requested a review from a team as a code owner September 25, 2026 06:27
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Sep 25, 2026
@steipete
steipete marked this pull request as draft September 25, 2026 07:01
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. and removed merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Sep 25, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Closing during queue triage. The allocation reduction is real, but the completed study established neither a speedup nor neutrality (8 candidate vs 7 control threshold crossings). Happy to revisit with a benchmark that shows user-visible benefit.

@steipete steipete closed this Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant