Skip to content

perf: speed up config loading - #123

Merged
Cherry merged 4 commits into
masterfrom
perf/config-and-logging
Oct 1, 2026
Merged

Cherry merged 4 commits into
masterfrom
perf/config-and-logging

Conversation

@Cherry

@Cherry Cherry commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Speeds up config loading at startup without changing behaviour, brings dependencies up to date, and fixes a flaky test.

  • Skip a redundant clone: loadConfig no longer runs _.cloneDeep before _.merge on JSON config files. _.merge already copies plain objects and arrays, so the clone did nothing.
  • Parse JSON first: the JSON handler now tries JSON.parse first and only strips comments if that fails. Most config files containing // are just URLs, not comments.
  • Dependencies:
    • nanoid 5 → 6. Same output; random() already guards against the sizes that now throw.
    • vitest and coverage 4 → 5.
    • Raised the minimum versions for dayjs and lodash.
    • Removed the poolOptions block from the vitest config, which vitest has ignored since v4.
  • Flaky test: "allows the process to exit gracefully" sometimes timed out on macOS. The test harness treated the child as finished on exit, which can fire before its output has been fully read. It now waits for close, and the test checks the full output instead of individual chunks.

Results

setup() time, excluding autoload, median of 15 runs on three production app configs:

Config size Before After
Large (~200 config files) 82ms 73ms (−11%)
Medium (~45 config files) 34ms 30ms (−11%)
Small (~35 config files) 25ms 23ms (−8%)

Testing

  • The resulting config and codes are identical to before for all three apps.
  • Ran every config file from those apps, plus edge cases, through the old and new JSON handler. Results and error messages match.
  • Added regression tests for // and /* inside JSON strings, config not sharing objects with cached JSON, and code() with null or frozen data.
  • Reproduced the macOS flake by delaying stdout until after exit: the old test fails with the same timeout seen in CI, and the fixed one passes.

Cherry added 4 commits October 1, 2026 14:49
Skip a redundant deep clone when merging JSON config, and only strip JSON comments when a plain parse fails.
Bump nanoid to v6 and vitest to v5, raise dayjs and lodash minimums, and drop the poolOptions config vitest has ignored since v4.
The test harness reported child exit before stdout was fully read, so the test sometimes missed the final log line and timed out. Wait for the child's close event and check the full output instead of individual chunks.
@Cherry
Cherry marked this pull request as ready for review October 1, 2026 14:32
@Cherry
Cherry requested a review from mja00 October 1, 2026 14:32
@Cherry
Cherry merged commit e46b63d into master Oct 1, 2026
23 checks passed
@Cherry
Cherry deleted the perf/config-and-logging branch October 1, 2026 14:45
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.

2 participants