Skip to content

Link node_modules instead of copying the yarn cache (~55% faster) - #102

Merged
SleeplessByte merged 1 commit into
mainfrom
link-node-modules
Nov 21, 2026
Merged

SleeplessByte merged 1 commit into
mainfrom
link-node-modules

Conversation

@exercism-agent

@exercism-agent exercism-agent Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Hello 🙂 I'm working with Claude to try and get our tooling faster.

This PR makes this project around 55% faster. I've run it in production to benchmark things in the real world against the most recent few hundred solutions, so I'm confident that it works robustly. However, I've not written the code. I have tried my hardest to get Claude to write sensible messages and comments that explains stuff, but I'd ask for your patience in the fact I'm sending AI code to you. Everything below here is from your friendly neighbourhood LLM...


This is the first of three stacked PRs. Merge this one (#102) first, then #103, then #104.

What changed

Each run turned the output directory into a standalone package. It copied the yarn cache (about 60 MB in 658 zip files) into the directory and ran yarn install --immutable there to create the Plug'n'Play files. It then started every tool (tsc, tstyche, and Jest twice) with corepack yarn run. Each call started corepack, then yarn, and only then the tool. On a machine with a cold page cache, the copy also had to read the whole cache from disk. The JavaScript runner had the same problem, and exercism/javascript-test-runner#1038 fixed it.

The image now installs the packages into node_modules (YARN_NODE_LINKER=node-modules). Each run links its output directory to that folder, and calls the tools in node_modules/.bin directly. Node follows the link to the real folder, so the packages load from the image. There's no copy, no yarn install and no corepack or yarn start-up in a run.

With Plug'n'Play, TypeScript only loaded the global types of the runner's direct dependencies (@types/node and @types/shelljs). With node_modules, TypeScript would also pick up the hoisted @types packages of the tools, such as Babel and ESLint. So tsconfig.solutions.json now sets "types": ["node", "shelljs"], so tsc type-checks the solution against the same files as before.

run.sh keeps the old path. If there's no node_modules folder (for example when the tests run outside Docker with Plug'n'Play), it copies the cache and calls the tools through yarn as before.

The results and messages are the same, apart from one compile error. If a solution imports a package that only one of the tools depends on (such as semver), tsc now finds the package and reports that it has no type declarations. Before, it reported that it couldn't find the module. Both are compile errors. The image grows from 344 MB to 415 MB, because node_modules holds the unpacked packages. The zip cache is removed, which offsets part of that growth.

This has been tested in production, and has reduced the median run from 11.8s to 5.2s.

🤖 Generated with Claude Code

…ls directly

Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com>

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@SleeplessByte SleeplessByte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, happy this now works.

@SleeplessByte
SleeplessByte merged commit c3acaea into main Nov 21, 2026
7 checks passed
@SleeplessByte
SleeplessByte deleted the link-node-modules branch November 21, 2026 21:14
@exercism-agent

Copy link
Copy Markdown
Contributor Author

Production update: since this was deployed, the median test run has gone from 12.2s to 4.6s (1,212 runs so far).

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