diff --git a/docs/FIXTURES/BABYLON.md b/docs/FIXTURES/BABYLON.md index c49327471b..3c964d4a9c 100644 --- a/docs/FIXTURES/BABYLON.md +++ b/docs/FIXTURES/BABYLON.md @@ -16,10 +16,15 @@ and slowest fixture in the suite. **Workspace resolution at scale.** Every other fixture is a single package; this one is 86 of them with internal cross-dependencies, which is a different problem from installing a wide flat graph. It is the fixture that catches a tool handling -`workspace:` protocol specifiers, hoisting, or link topology badly. +cross-workspace ranges, hoisting, or link topology badly. It is also the only fixture whose own `vlt.json` declares workspaces. +Its 323 references between workspace packages are plain semver ranges, not +`workspace:`, and every tool gets them as committed. See +[METHODOLOGY](../METHODOLOGY.md#what-a-benchmark-is-here) for how each tool +links them. + ## Variations All install variations. No `build`, `build-cache` or `run`. diff --git a/docs/METHODOLOGY.md b/docs/METHODOLOGY.md index 1e0addf113..d319d985ed 100644 --- a/docs/METHODOLOGY.md +++ b/docs/METHODOLOGY.md @@ -46,6 +46,30 @@ vlt can also be pointed at `registry.npmjs.org`; these numbers don't measure that. The `registry-*` variations are the ones that hold the client constant and compare registries. +Fixtures are installed as committed, with the same dependency specs for every +tool (berry and zpm still get their `packageManager` pin and `.yarnrc.yml`). +In `babylon`, workspace packages depend on each other by plain semver range +(`"@dev/core": "^1.0.0"`), not `workspace:`, and each tool links them its own +way: + +- vlt rewrites most of those ranges (257 of 323) to `workspace:*` in + `package.json` on its first install. That rewrite is part of its timed run + wherever the manifests start out unmigrated, which is `clean`; in the other + variations the untimed first warmup migrates them. vlt 1.8.0 leaves the 66 + exact and peer specs on the published `@babylonjs/*` names as they are, and + in about half of cold installs it resolves four of them (`gui`, `loaders`, + `materials`, `serializers`) to registry copies instead of the workspace, + downloading 4 extra tarballs ([vltpkg/vltpkg#2154](https://github.com/vltpkg/vltpkg/issues/2154)). + So vlt's `babylon` `clean` results can differ between runs until that is + fixed. +- pnpm links them (the fixture's `pnpm-workspace.yaml` sets + `linkWorkspacePackages: true`), but first asks the registry for each one: + about 240 lookups per cold install, most answered 404 for private packages. + It also installs `@babylonjs/shared-ui-components`, a peer dependency, from + the registry. +- Every tool downloads `babylonjs-gltf2interface@6` from the registry, because + `packages/tools/devHost` asks for `^6.42.0` and the workspace has 8.49.6. + vlt finishes some work in detached processes that keep running after the `vlt` command exits: unpacking fetched tarballs into its cache (about 19 seconds after a cold `babylon` install), revalidating cached manifests, diff --git a/suite/scripts/add-workspace-protocol.js b/suite/scripts/add-workspace-protocol.js deleted file mode 100644 index 9c7fa96e1b..0000000000 --- a/suite/scripts/add-workspace-protocol.js +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env node - -/** - * Adds `workspace:` protocol prefix to inter-workspace dependency specs. - * - * Some package managers (like vlt) require the `workspace:` protocol to - * resolve workspace packages, while others (like npm, yarn classic) do it - * automatically by matching package names. This script bridges that gap by - * rewriting dependency specs for workspace packages. - * - * Uses `workspace:*` to match any local version, since workspace packages - * in monorepos often have cross-references where the semver range in the - * dep spec may not strictly match the current local version. - * - * Usage: node scripts/add-workspace-protocol.js [fixture-path] - * - * If no fixture-path is given, uses the current directory. - */ - -import { readFileSync, writeFileSync, existsSync } from 'node:fs' -import { join, resolve } from 'node:path' -import { execSync } from 'node:child_process' - -const fixtureRoot = resolve(process.argv[2] || '.') - -// Read root package.json to get workspace globs -const rootPkgPath = join(fixtureRoot, 'package.json') -if (!existsSync(rootPkgPath)) { - console.error(`No package.json found at ${rootPkgPath}`) - process.exit(1) -} - -const rootPkg = JSON.parse(readFileSync(rootPkgPath, 'utf8')) -const workspaceGlobs = rootPkg.workspaces || [] - -if (workspaceGlobs.length === 0) { - console.log('No workspaces defined, nothing to do.') - process.exit(0) -} - -// Find all workspace package.json files -const findCmd = `find ${fixtureRoot}/packages -name package.json -not -path '*/node_modules/*'` -const packageJsonPaths = execSync(findCmd, { encoding: 'utf8' }) - .trim() - .split('\n') - .filter(Boolean) - -// Also include the root package.json -packageJsonPaths.push(rootPkgPath) - -// Build a set of workspace package names -const workspacePackageNames = new Set() -for (const pkgPath of packageJsonPaths) { - try { - const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) - if (pkg.name) { - workspacePackageNames.add(pkg.name) - } - } catch { - // skip malformed files - } -} - -console.log(`Found ${workspacePackageNames.size} workspace packages`) - -// Now rewrite all package.json files -const depFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] -let modifiedCount = 0 - -for (const pkgPath of packageJsonPaths) { - try { - const raw = readFileSync(pkgPath, 'utf8') - const pkg = JSON.parse(raw) - let modified = false - - for (const field of depFields) { - const deps = pkg[field] - if (!deps) continue - - for (const [name, spec] of Object.entries(deps)) { - if ( - workspacePackageNames.has(name) && - typeof spec === 'string' && - !spec.startsWith('workspace:') - ) { - // Use workspace:* to always resolve to the local version - // regardless of what semver range was originally specified - deps[name] = 'workspace:*' - modified = true - } - } - } - - if (modified) { - // Preserve the original formatting - const indent = raw.match(/^(\s+)"/m)?.[1] || ' ' - const newline = raw.endsWith('\n') ? '\n' : '' - writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + newline) - modifiedCount++ - } - } catch { - // skip malformed files - } -} - -console.log(`Modified ${modifiedCount} package.json files to add workspace: protocol`) diff --git a/suite/scripts/clean-helpers.sh b/suite/scripts/clean-helpers.sh index 55e8cdfd3d..30ffe9200e 100644 --- a/suite/scripts/clean-helpers.sh +++ b/suite/scripts/clean-helpers.sh @@ -271,6 +271,9 @@ clean_git() { fi } +# vlt rewrites plain ranges that link a workspace sibling to `workspace:*` +# (on `babylon`, 80 package.json files) on its first install. Restore the +# fixture's manifests so the next tool starts from the project as committed. clean_workspace_protocol() { echo "Restoring package.json files (undo workspace: protocol changes)..." if command -v git &> /dev/null && git rev-parse --git-dir > /dev/null 2>&1; then diff --git a/suite/scripts/variations/common.sh b/suite/scripts/variations/common.sh index 36577df63a..d1b8dca2bf 100644 --- a/suite/scripts/variations/common.sh +++ b/suite/scripts/variations/common.sh @@ -75,7 +75,7 @@ BENCH_SETUP_BERRY="touch yarn.lock; echo \"$BENCH_COMMAND_YARN_MODERN_CONFIG\" > BENCH_SETUP_ZPM="touch yarn.lock; echo \"$BENCH_COMMAND_YARN_MODERN_CONFIG\" > .yarnrc.yml; { echo '[zpm prepare]'; echo 'cwd:'; pwd; echo 'package.json:'; ls -la package.json || true; echo 'yarn path:'; command -v yarn || true; echo 'yarn version:'; yarn -v || true; echo 'canary version:'; echo \"$BENCH_ZPM_VERSION\"; echo 'packageManager (before):'; npm pkg get packageManager || true; echo 'set packageManager=yarn@'"$BENCH_ZPM_VERSION"':' ; npm pkg set packageManager=\"yarn@$BENCH_ZPM_VERSION\" || true; echo 'packageManager (after):'; npm pkg get packageManager || true; } >> $BENCH_OUTPUT_FOLDER/zpm-prepare.log 2>&1" BENCH_SETUP_PNPM="npm pkg delete packageManager >/dev/null 2>&1 || true" -BENCH_SETUP_VLT="node $BENCH_SCRIPTS/add-workspace-protocol.js . >> $BENCH_OUTPUT_FOLDER/vlt-prepare.log 2>&1" +BENCH_SETUP_VLT="" BENCH_SETUP_BUN="" BENCH_SETUP_DENO="" BENCH_SETUP_AUBE="npm pkg delete packageManager >/dev/null 2>&1 || true"