Skip to content

Combined: pre-allocate source shapes + singleton proxy handler + cache proxyOf in each() #66

@alanzabihi

Description

@alanzabihi

Hypothesis

Three near-miss optimizations showed directional improvement individually:

The deltas dont add linearly, but combining the two strongest (#52 and #53) both target object shape/allocation overhead. Together they reduce V8 hidden class transitions AND repeated property resolution.

Implementation:

  1. Pre-allocate source objects with {start, end: null, input} in parser (from Pre-allocate Node source object structure to reduce shape transitions #53)
  2. Singleton proxy handler at module level in container.js (from Avoid repeated proxyOf and parent dereferences in container.each hot loop #52)
  3. Cache proxyOf and indexes references in each() (from Avoid repeated proxyOf and parent dereferences in container.each hot loop #52)

These are independent optimizations — no interference expected. Combined delta target: 4-5ms.

Editable surface

  • lib/parser.js — pre-allocate source object shape
  • lib/container.js — singleton proxy handler, cache proxyOf/indexes in each()
  • lib/node.js — singleton proxy handler for leaf nodes

What's different from prior work

Expected impact

Combined METRIC composite improvement of 4-6ms. The two strongest near-misses target complementary overhead (allocation shapes vs property resolution).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions