Skip to content

chore(tests): speed up large upload byte checks - #140402

Merged
steipete merged 1 commit into
mainfrom
codex/perf-upload-buffer-assertion
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-upload-buffer-assertion

Conversation

@steipete

@steipete steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The large upload regression spent most of its test time deeply comparing an 8 MiB buffer. The existing case took 9.417 seconds in the controlled local run, with about 3.91 GB peak process memory.

Why This Change Was Made

Compare the materialized file with exact native Buffer equality and retain an explicit length assertion. The two 4 MiB chunks, SHA-256 checks, SQLite state, deferred archive reads, transactional install claim, zero redundant native-byte copies, and cleanup checks remain unchanged. Smaller archive comparisons retain their existing diagnostics.

User Impact

Test-only performance improvement; no production, schema, upload-limit, or behavior change. The test still checks every byte, including same-length corruption.

Evidence

Both original and candidate full-file runs passed all 23 cases on the same Node 24.19.0/pnpm 12.3.4 frozen install, with separate fresh compiler caches. The selected case improved 9.417 → 0.327 seconds; peak process RSS improved 3.91 → 2.14 GB. Total command wall time was noisy (18.66 → 19.59 seconds), so this is a scoped case/memory improvement, not a claimed whole-CI speedup.

A temporary control changed only the final materialized byte: the length assertion passed and byte equality failed as expected. The control was then removed and exact candidate bytes verified. Node's comparator implementation was inspected; this uses full byte equality rather than sampling or digest-only comparison.

The changed-file gate passed, including core test types, all three dead-code scans, lint and formatting. Independent P2 review passed with no findings. One test file changes by +3/-1 lines; production is unchanged. Exact-head CI remains the landing gate.

@steipete steipete self-assigned this Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 19:53
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 3:59 PM ET / 19:59 UTC.

ClawSweeper review

What this changes

The PR replaces deep comparison of an 8 MiB uploaded archive in a regression test with native Buffer equality and an explicit length assertion.

Merge readiness

✅ Ready for maintainer review

This remains a useful, narrowly scoped optimization: current main retains the expensive assertion, and the replacement preserves exact byte checking. No actionable correctness or security findings.

Priority: P3
Reviewed head: 0c6a51e7f8e56f86d24f1096450d5ad7edc2e951

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable optimization with preserved byte integrity and useful reported validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository-state MEMBER author is exempt from the external contributor gate, and no authority changes trigger additional proof; the supplied test benchmark and corruption control directly address the changed assertion.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository-state MEMBER author is exempt from the external contributor gate, and no authority changes trigger additional proof; the supplied test benchmark and corruption control directly address the changed assertion.
Evidence reviewed 7 items Verified introduced change: The merge-base-to-head diff changes only the large archive assertion; the chunk sizes, checksum checks, transaction observation, and redundant-copy assertion remain intact.
Current main still needs the optimization: Fetched main retains the deep toEqual comparison in the same large-upload case.
Latest release comparison: The supplied latest release also retains the deep comparison; this optimization is not already present there.
Findings None None.
Security None None.

How this fits together

The skill upload store stages archive chunks in SQLite and materializes a committed archive for installation. This regression test checks that materialization preserves every byte while avoiding unnecessary archive reads and copies.

flowchart LR
  A[Archive chunks] --> B[SQLite upload staging]
  B --> C[Size and checksum verification]
  C --> D[Install claim]
  D --> E[Temporary archive file]
  E --> F[Length and byte equality check]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +2. Total +2 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 3 1 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 3 1 +2

Review metrics

Metric Value Why it matters
Reported case performance 9.417 → 0.327 seconds; peak RSS 3.91 → 2.14 GB The controlled measurements support a case-specific time and memory benefit; total command wall time did not improve.

Technical review

Best possible solution:

Retain the full-size regression and its storage invariants while using native equality for the large materialized buffer.

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

Not applicable as a product bug: this is test-performance cleanup, supported by reported controlled before/after measurements and a corruption negative control.

Is this the best way to solve the issue?

Yes. Native equality preserves the required byte-for-byte invariant without reducing the fixture or replacing the comparison with sampling or a checksum.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7974cc77bf27.

Labels

Label changes:

  • add P3: This is a low-risk test-performance improvement with no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository-state MEMBER author is exempt from the external contributor gate, and no authority changes trigger additional proof; the supplied test benchmark and corruption control directly address the changed assertion.

Label justifications:

  • P3: This is a low-risk test-performance improvement with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository-state MEMBER author is exempt from the external contributor gate, and no authority changes trigger additional proof; the supplied test benchmark and corruption control directly address the changed assertion.

Evidence

What I checked:

  • Verified introduced change: The merge-base-to-head diff changes only the large archive assertion; the chunk sizes, checksum checks, transaction observation, and redundant-copy assertion remain intact. (src/skills/lifecycle/upload-store.test.ts:414, 0c6a51e7f8e5)
  • Current main still needs the optimization: Fetched main retains the deep toEqual comparison in the same large-upload case. (src/skills/lifecycle/upload-store.test.ts:414, 7974cc77bf27)
  • Latest release comparison: The supplied latest release also retains the deep comparison; this optimization is not already present there. (src/skills/lifecycle/upload-store.test.ts:414, 3928bad9badf)
  • Production boundary: withCommittedUpload reads the committed archive under an install claim, writes its bytes to a temporary archive, and invokes the callback inspected by the changed test. The PR does not modify this production flow. (src/skills/lifecycle/upload-store.ts:616, 0c6a51e7f8e5)
  • Native comparator contract: The introduced Buffer.equals call establishes the Node dependency signal. Inspected Node source checks byte lengths and delegates nonempty distinct buffers to its native comparator: Node Buffer implementation. (lib/buffer.js:806)
  • Reported controlled validation: The captured PR body reports 23 passing cases before and after, case duration of 9.417 to 0.327 seconds, and peak RSS of 3.91 to 2.14 GB. It also reports that changing only the final materialized byte passed the length assertion but failed equality. These are contributor-reported results; this read-only review did not execute tests. Captured context sourceRevision: be31d75d5eb628c53029600e771cc317feb2af0a7ac51ff6b2a042f9a719e014. (0c6a51e7f8e5)

Likely related people:

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

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.

@steipete
steipete merged commit 9474ff6 into main Sep 6, 2026
167 checks passed
@steipete
steipete deleted the codex/perf-upload-buffer-assertion branch September 6, 2026 20:03
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
…rol-ui

* origin/main:
  docs: remove the empty release-sections nav group (#140427)
  fix(tooling): omit Codex machine squash credit (#140420)
  chore(ui): refresh control ui locales (#140384)
  refactor(plugin-sdk): reuse native approval input contracts (#140415)
  fix: silent model WebSocket streams hang past the idle timeout (#140335)
  perf(ai): avoid unused text extraction for image results (#140409)
  fix(ui): distinguish failed GitHub status checks from disconnected accounts (#140333)
  refactor(cron): share runtime feedback schema fields (#140408)
  fix: avoid duplicate cloud worker teardown during recovery (#140377)
  fix(cli): show executable approval scope (#138386)
  refactor(ui): reuse shared requirement records (#140407)
  test(gateway): table-drive device token lifecycle checks (#140403)
  fix(chat): fence delayed history at terminal retirement (#140379)
  test(skills): compare large upload bytes natively (#140402)
  refactor(delivery): reuse the canonical rendered batch plan type (#140386)
  docs(start): repair the first-run path from landing page to first channel (#140390)

# Conflicts:
#	docs/.i18n/glossary.zh-CN.json
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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