Skip to content

All-in-one: arguments object, inline coerce, skip regex, cache prefix+humanize, skip split #28

@alanzabihi

Description

@alanzabihi

Hypothesis

Combining ALL sub-threshold optimizations from prior theses into a single change can achieve a compound improvement exceeding 3ms. Prior individual theses showed improvements in isolation but failed to beat the current best (104.62ms) because they were measured on different hardware or achieved less than 3ms individually.

This thesis combines 6 independent optimizations:

  1. Replace ...args with arguments + manual array copy (thesis Avoid rest parameter allocation for disabled calls #16: 23% guard improvement)
  2. Inline typeof check, skip coerce for strings (thesis Skip coerce and inline string type check #22: eliminates function call)
  3. Pre-compute color prefix at init (thesis Pre-compute ANSI color prefix per instance at init time #5: eliminates per-call string concat)
  4. Short-circuit split/join for no-newline (thesis Short-circuit split/join for single-line messages in formatArgs #6: avoids array alloc 75% of calls)
  5. Cache ms.humanize for repeated diffs (thesis Cache ms.humanize result for identical consecutive diffs #12: skips ms library)
  6. Lazy getters for .prev/.curr (thesis Eliminate per-call self.prev and self.curr property writes #11: removes 2 property writes/call)

Rationale

Each optimization targets a different bottleneck. None interact with each other. Combined, they remove: 1 array allocation (disabled), 1 function call, 2-3 string concats, 1 array alloc, 1 ms library call, and 2 property writes per enabled call. The compound effect should be well over 3ms.

Scope

  • src/common.js: arguments instead of rest, inline coerce, lazy prev/curr getters
  • src/node.js: cached prefix in init, indexOf newline guard, humanize cache

Expected impact

High. Each optimization contributes ~0.5-2ms; combined, they should produce 5-10ms improvement on the current 104.62ms baseline.

Risks

Must verify all 6 optimizations compose correctly. Each targets independent code so interaction risk is low.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions