Skip to content

Perf: initial commit optimizations#30

Open
matsbryntse-dev wants to merge 7 commits intomasterfrom
perf/initial-commit-optimizations
Open

Perf: initial commit optimizations#30
matsbryntse-dev wants to merge 7 commits intomasterfrom
perf/initial-commit-optimizations

Conversation

@matsbryntse-dev
Copy link
Copy Markdown
Collaborator

@matsbryntse-dev matsbryntse-dev commented Apr 1, 2026

Summary

  • commitAsync uses synchronous commit path when onComputationCycle !== 'effect', bypassing all generator overhead
  • cachedBaseRevisionLookup short-circuits when base revision is empty (initial commit)
  • markAndSweep skipped on initial commit — no revision history to compact
  • addOutgoingTo polymorphic deopt fixed — pass identifier explicitly instead of reading from polymorphic Quark subclass
  • hasCycles boolean guard added to skip Map.has() in hot loop when no cycles present
  • createFieldIdentifier avoids template string allocation per field
  • Quark.calculation/context cached on instance at creation time (avoids getter delegation)
  • entries.get ownership check skipped during initial commit (entries never replaced)

Benchmark

All measured in the same session, node autoresearch/benchmark.mjs --tasks=1000 --chains=10 --runs=5 (GanttProjectMixin initial commit):

Commit Median Description
origin/master 3741ms Current master
This PR ~2790ms Our optimizations on top of master

~25% faster than current master.

Test plan

  • All 64695 Engine tests pass (grunt tests --include=".t.js")
  • Verify non-initial commits still work (sync path falls back to generator when onComputationCycle === 'effect')

🤖 Generated with Claude Code

matsbryntse-dev and others added 3 commits April 1, 2026 17:43
Five optimizations targeting the GanttProjectMixin initial data load:

1. commitAsync uses sync path when onComputationCycle != 'effect'
   Bypasses all generator overhead for initial commit (41% alone)

2. cachedBaseRevisionLookup short-circuits when base revision is empty
   Avoids Map lookups + revision chain walks on initial commit (9%)

3. Skip markAndSweep on initial commit
   No revision history to compact, saves 50K+ Map operations (7%)

4. Fix polymorphic property access deopt in addOutgoingTo
   Pass identifier explicitly instead of reading from polymorphic
   Quark subclass (QuarkGen vs QuarkSync). Also adds hasCycles
   boolean guard to skip Map.has in the hot loop (9%)

5. Avoid template string allocation in createFieldIdentifier
   Use field.name directly instead of template string per field (2%)

Benchmark: 5591ms → 2630ms for 1000x10 Gantt tasks (53% improvement)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matsbryntse-dev matsbryntse-dev force-pushed the perf/initial-commit-optimizations branch from 1df24bc to 53b2ada Compare April 1, 2026 19:48
@matsbryntse-dev matsbryntse-dev changed the title Perf: initial commit optimizations (~53% faster) Perf: initial commit optimizations Apr 1, 2026
matsbryntse-dev and others added 4 commits April 1, 2026 22:52
Replaces getter delegation (this.identifier.calculation and
this.identifier.context || this.identifier) with cached instance
properties set during newQuark(). Saves ~100K getter calls during
initial commit calculation. ~5% improvement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
During initial commit, entries are never replaced by Write effects, so the
Map.get ownership check (entries.get(identifier) !== entry) always passes.
Skip it when baseRevisionEmpty is true. Saves ~50K Map.get calls. ~5% faster.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Leftover from abandoned batch-edges experiment. Reduces Transaction
property count by 1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Both sync and gen identifiers now use the same QuarkGen class, eliminating
V8 megamorphic property access deoptimization (LoadIC_Megamorphic was ~14%
of CPU time). A _isGenCalc flag set at quark creation time branches sync
vs gen in startCalculation without runtime type checking.

~5% improvement (2490ms to 2410ms).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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