Skip to content

Mega-combine: arguments object + inline coerce + all formatArgs caches + lazy getters + hoisted regex #35

@alanzabihi

Description

@alanzabihi

Hypothesis

Apply every proven optimization from the results history simultaneously. Prior individual and combined attempts showed 3-47ms improvements on Hetzner hardware but did not beat the Mac Mini baseline (104.62ms) in absolute terms. This mega-combine gives the Mac Mini contributor every known optimization in one commit.

IMPORTANT: Your metric must beat 104.62ms. Run bench on current main first to confirm your baseline.

All optimizations

common.js:

  1. Replace ...args with arguments + manual array copy in enabled branch (thesis Avoid rest parameter allocation for disabled calls #16: 4% primary, 23% guard)
  2. Inline typeof string check before coerce (thesis Skip coerce and inline string type check #22: skip function call)
  3. Hoist format regex to module scope (thesis Hoist format regex to module scope to avoid per-call RegExp allocation #15: avoid RegExp alloc)
  4. Replace args.splice with new array build (thesis Avoid args.splice in format string processing — build new array #8: avoid O(n) mutation)
  5. Lazy getters for .prev/.curr (thesis Eliminate per-call self.prev and self.curr property writes #11: remove 2 property writes/call)

node.js:
6. Pre-compute _colorCode, _colorPrefix at init (thesis #5)
7. indexOf newline guard in formatArgs (thesis #6)
8. Cache ms.humanize for repeated diffs (thesis #12)
9. Pre-compute suffix start at init (thesis #33)

Scope

  • src/common.js: items 1-5
  • src/node.js: items 6-9

Expected impact

High. On Hetzner, thesis #23 (items 6-8 + 5) showed 47ms (16.5%). Adding items 1-4 and 9 should push further. On Mac Mini, expect 15-25ms improvement to ~80-90ms range.

Risks

Many changes at once. Must verify fingerprints. Each change is individually proven correct so the combination should be safe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions