Skip to content

Optimize vecs against the noise-aware baseline - #15

Open
RowDaBoat wants to merge 6 commits into
benchmark-updatefrom
measured-optimizations
Open

RowDaBoat wants to merge 6 commits into
benchmark-updatefrom
measured-optimizations

Conversation

@RowDaBoat

@RowDaBoat RowDaBoat commented Sep 7, 2026 •

Copy link
Copy Markdown
Owner

Scope

Optimize vecs without changing its public API or external contract.

Method

  • Use benchmark-update as the comparison baseline.
  • Keep one optimization per commit.
  • Require 15 matched process pairs and reject any directional regression.
  • Run the complete test suite and tests/manycomponents.nim with -d:ArchetypeWords=2.
  • Push each measured optimization separately.

Optimizations

Direct Meta initialization (56f479a)

New entities write their Meta.id through the already-known archetype slot instead of looking the entity up again through the public write iterator.

Cached removal transition (dd526fd)

Immediate component removal computes the destination archetype ID before materializing a component-ID sequence. The sequence is allocated only when that destination archetype must be created. Focused coverage verifies duplicate removal types, reference retention, column order, and pending additions.

Static query component IDs (36b54ae)

Query column setup uses compile-time component IDs after query matching has already handled registration, avoiding repeated builder-registration checks for every matched archetype.

Raw query column pointers (b89adf0)

Query setup obtains component column bases through the erased buffer data pointer instead of taking typed element zero after a length check.

Direct query column indexes (f6350c2)

Query setup reads the archetype column map directly instead of calling getIndex for each requested component in every matched archetype.

Each optimization was accepted only after its own 15-pair incremental comparison showed a measurable gain and no directional regression.

Cumulative result versus benchmark-update

After rebasing both branches onto the current main benchmark layout, the final tip and baseline were compiled from the same absolute checkout path and compared across 15 alternating matched process pairs.

  • Create entity: 11.4% faster.
  • Create entity after archetype warmup: 14.2% faster.
  • Remove component: 18.9% faster.
  • Remove component after archetype warmup: 20.4% faster.
  • Add/remove cycles: 9.6-9.7% faster.
  • Heterogeneous iteration: 54.8% faster.
  • All remaining rows are unchanged or statistically inconclusive.
  • No directional regression or memory change.

Validation

  • Rebased cleanly onto the current main benchmark names and style.
  • Complete suite passes across 21 test files.
  • tests/manycomponents.nim passes with -d:ArchetypeWords=2.
  • Both post-rebase CI runs pass, including the baseline benchmark comparison.

@RowDaBoat
RowDaBoat force-pushed the measured-optimizations branch from a0f44d1 to 8f9b1ac Compare September 7, 2026 22:34
@RowDaBoat
RowDaBoat marked this pull request as ready for review September 7, 2026 23:36

This branch has not been deployed

No deployments
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