From fe4f73f2ee571fb2cf8ad2dbe586c4507d5969f1 Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Mon, 7 Oct 2024 17:34:01 +0200 Subject: [PATCH] chore(replicache-perf): Cleanup build (#2580) - Use tsx for build script and remove build for runner. - Fix typescript errors - Move idb brenchmark enumeration to idb file. --- .github/workflows/perf-smoke.yml | 2 +- .github/workflows/perf-v2.js.yml | 2 +- package-lock.json | 57 +---------------- package.json | 1 + packages/replicache-perf/package.json | 5 +- .../replicache-perf/src/benchmarks/idb.ts | 63 ++++++++++++++++--- packages/replicache-perf/src/perf.ts | 54 +--------------- packages/replicache-perf/src/runner.ts | 2 +- .../tool/{build.js => build.ts} | 22 +------ packages/replicache/.eslintignore | 2 - 10 files changed, 68 insertions(+), 142 deletions(-) rename packages/replicache-perf/tool/{build.js => build.ts} (53%) diff --git a/.github/workflows/perf-smoke.yml b/.github/workflows/perf-smoke.yml index 75f9ce0a8d..68c36a47c6 100644 --- a/.github/workflows/perf-smoke.yml +++ b/.github/workflows/perf-smoke.yml @@ -29,5 +29,5 @@ jobs: working-directory: packages/replicache-perf run: | npm run build - node out/runner.js --format=json --run='populate 1024x1000 \(clean, indexes: 0\)' + npx tsx src/runner.ts --format=json --run='populate 1024x1000 \(clean, indexes: 0\)' shell: bash diff --git a/.github/workflows/perf-v2.js.yml b/.github/workflows/perf-v2.js.yml index b748aae633..8818f383a9 100644 --- a/.github/workflows/perf-v2.js.yml +++ b/.github/workflows/perf-v2.js.yml @@ -32,7 +32,7 @@ jobs: working-directory: packages/replicache-perf run: | npm run build - node out/runner.js --format=json | tee perf-temp-output.json + npx tsx src/runner.ts --format=json | tee perf-temp-output.json node tool/split-perf.js perf-temp-output.json perf-v2-output.json perf-v2-p95-output.json shell: bash diff --git a/package-lock.json b/package-lock.json index b7b9e94d8e..eda31aef74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@rocicorp/prettier-config": "^0.2.0", "prettier": "^3.0.3", "syncpack": "^12.3.2", + "tsx": "^4.19.1", "turbo": "^1.13.2", "vitest": "^2.0.3" } @@ -1410,7 +1411,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15562,7 +15562,6 @@ "version": "4.19.1", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.1.tgz", "integrity": "sha512-0flMz1lh74BR4wOvBjuh9olbnwqCPc35OOlfyzHba0Dc+QNUeWX/Gq2YTbnwcWPO3BMd8fkzRVrHcsR+a7z7rA==", - "dev": true, "license": "MIT", "dependencies": { "esbuild": "~0.23.0", @@ -15585,7 +15584,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15602,7 +15600,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15619,7 +15616,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15636,7 +15632,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15653,7 +15648,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15670,7 +15664,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15687,7 +15680,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15704,7 +15696,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15721,7 +15712,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15738,7 +15728,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15755,7 +15744,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15772,7 +15760,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15789,7 +15776,6 @@ "cpu": [ "mips64el" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15806,7 +15792,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15823,7 +15808,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15840,7 +15824,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15857,7 +15840,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15874,7 +15856,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15891,7 +15872,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15908,7 +15888,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15925,7 +15904,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15942,7 +15920,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15959,7 +15936,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -15973,7 +15949,6 @@ "version": "0.23.1", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", - "dev": true, "hasInstallScript": true, "license": "MIT", "bin": { @@ -16013,7 +15988,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -17416,6 +17390,7 @@ "playwright": "^1.43.1", "replicache": "15.2.1", "shared": "0.0.0", + "tsx": "^4.19.1", "typescript": "^5.5.3", "xbytes": "^1.7.0" } @@ -18698,7 +18673,6 @@ "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", - "dev": true, "optional": true }, "@esbuild/openbsd-x64": { @@ -27469,6 +27443,7 @@ "playwright": "^1.43.1", "replicache": "15.2.1", "shared": "0.0.0", + "tsx": "^4.19.1", "typescript": "^5.5.3", "xbytes": "^1.7.0" }, @@ -28921,7 +28896,6 @@ "version": "4.19.1", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.1.tgz", "integrity": "sha512-0flMz1lh74BR4wOvBjuh9olbnwqCPc35OOlfyzHba0Dc+QNUeWX/Gq2YTbnwcWPO3BMd8fkzRVrHcsR+a7z7rA==", - "dev": true, "requires": { "esbuild": "~0.23.0", "fsevents": "~2.3.3", @@ -28932,168 +28906,144 @@ "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", - "dev": true, "optional": true }, "@esbuild/android-arm": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", - "dev": true, "optional": true }, "@esbuild/android-arm64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", - "dev": true, "optional": true }, "@esbuild/android-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", - "dev": true, "optional": true }, "@esbuild/darwin-arm64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", "integrity": "sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==", - "dev": true, "optional": true }, "@esbuild/darwin-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", - "dev": true, "optional": true }, "@esbuild/freebsd-arm64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", - "dev": true, "optional": true }, "@esbuild/freebsd-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", - "dev": true, "optional": true }, "@esbuild/linux-arm": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", - "dev": true, "optional": true }, "@esbuild/linux-arm64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", - "dev": true, "optional": true }, "@esbuild/linux-ia32": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", - "dev": true, "optional": true }, "@esbuild/linux-loong64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", - "dev": true, "optional": true }, "@esbuild/linux-mips64el": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", - "dev": true, "optional": true }, "@esbuild/linux-ppc64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", - "dev": true, "optional": true }, "@esbuild/linux-riscv64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", - "dev": true, "optional": true }, "@esbuild/linux-s390x": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", - "dev": true, "optional": true }, "@esbuild/linux-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", - "dev": true, "optional": true }, "@esbuild/netbsd-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", - "dev": true, "optional": true }, "@esbuild/openbsd-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", - "dev": true, "optional": true }, "@esbuild/sunos-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", - "dev": true, "optional": true }, "@esbuild/win32-arm64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", - "dev": true, "optional": true }, "@esbuild/win32-ia32": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", - "dev": true, "optional": true }, "@esbuild/win32-x64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", - "dev": true, "optional": true }, "esbuild": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", "integrity": "sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==", - "dev": true, "requires": { "@esbuild/aix-ppc64": "0.23.1", "@esbuild/android-arm": "0.23.1", @@ -29125,7 +29075,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "optional": true } } diff --git a/package.json b/package.json index 03ea410806..8af071595e 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@rocicorp/prettier-config": "^0.2.0", "prettier": "^3.0.3", "syncpack": "^12.3.2", + "tsx": "^4.19.1", "turbo": "^1.13.2", "vitest": "^2.0.3" }, diff --git a/packages/replicache-perf/package.json b/packages/replicache-perf/package.json index eca4de5ffe..8b2c1675a1 100644 --- a/packages/replicache-perf/package.json +++ b/packages/replicache-perf/package.json @@ -6,8 +6,8 @@ "check-types": "tsc", "check-types:watch": "tsc --watch", "lint": "eslint --ext .ts,.tsx,.js,.jsx src/", - "build": "node tool/build.js", - "perf": "npm run build && node out/runner.js" + "build": "tsx tool/build.ts", + "perf": "npm run build && tsx src/runner.ts" }, "type": "module", "dependencies": { @@ -26,6 +26,7 @@ "playwright": "^1.43.1", "replicache": "15.2.1", "shared": "0.0.0", + "tsx": "^4.19.1", "typescript": "^5.5.3", "xbytes": "^1.7.0" }, diff --git a/packages/replicache-perf/src/benchmarks/idb.ts b/packages/replicache-perf/src/benchmarks/idb.ts index 219934bb65..797d7a4c75 100644 --- a/packages/replicache-perf/src/benchmarks/idb.ts +++ b/packages/replicache-perf/src/benchmarks/idb.ts @@ -1,11 +1,11 @@ -import {deleteDB, IDBPDatabase, openDB} from 'idb/with-async-ittr'; +import {deleteDB, type IDBPDatabase, openDB} from 'idb/with-async-ittr'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore Invalid module when using node16 module resolution. import xbytes from 'xbytes'; import type {Bencher, Benchmark} from '../benchmark.js'; -import {randomData, RandomDataType} from '../data.js'; +import {randomData, type RandomDataType} from '../data.js'; -export function benchmarkIDBReadGetAll(opts: { +function benchmarkIDBReadGetAll(opts: { dataType: RandomDataType; group: string; valSize: number; @@ -62,7 +62,7 @@ export function benchmarkIDBReadGetAll(opts: { }; } -export function benchmarkIDBReadGetAllGetAllKeys(opts: { +function benchmarkIDBReadGetAllGetAllKeys(opts: { dataType: RandomDataType; group: string; valSize: number; @@ -120,7 +120,7 @@ export function benchmarkIDBReadGetAllGetAllKeys(opts: { }; } -export function benchmarkIDBReadGet(opts: { +function benchmarkIDBReadGet(opts: { dataType: RandomDataType; group: string; valSize: number; @@ -198,7 +198,7 @@ async function idbPopulateInlineKey( await tx.done; } -export function benchmarkIDBWrite(opts: { +function benchmarkIDBWrite(opts: { dataType: RandomDataType; group: string; valSize: number; @@ -245,7 +245,7 @@ export function benchmarkIDBWrite(opts: { }; } -export function benchmarkIDBReadGetWithInlineKeys(opts: { +function benchmarkIDBReadGetWithInlineKeys(opts: { dataType: RandomDataType; group: string; valSize: number; @@ -303,7 +303,7 @@ export function benchmarkIDBReadGetWithInlineKeys(opts: { }; } -export function benchmarkIDBReadGetAllWithInlineKey(opts: { +function benchmarkIDBReadGetAllWithInlineKey(opts: { dataType: RandomDataType; group: string; valSize: number; @@ -360,7 +360,7 @@ export function benchmarkIDBReadGetAllWithInlineKey(opts: { }; } -export function benchmarkIDBWriteWithInlineKey(opts: { +function benchmarkIDBWriteWithInlineKey(opts: { dataType: RandomDataType; group: string; valSize: number; @@ -408,3 +408,48 @@ export function benchmarkIDBWriteWithInlineKey(opts: { }, }; } + +export function benchmarks(): Array { + const benchmarks: Benchmark[] = []; + + for (const b of [ + benchmarkIDBReadGet, + benchmarkIDBReadGetWithInlineKeys, + benchmarkIDBReadGetAll, + benchmarkIDBReadGetAllGetAllKeys, + benchmarkIDBReadGetAllWithInlineKey, + benchmarkIDBWrite, + benchmarkIDBWriteWithInlineKey, + ]) { + for (const numKeys of [1, 10, 100, 1000]) { + const dataTypes: RandomDataType[] = ['string', 'object', 'arraybuffer']; + for (const dataType of dataTypes) { + const kb = 1024; + const mb = kb * kb; + const sizes = [ + kb, + 32 * kb, + // Note: on blink, as of 4/2/2021, there's a cliff at 64kb + mb, + 10 * mb, + 100 * mb, + ]; + const group = dataType === 'arraybuffer' ? 'idb' : 'idb-extras'; + for (const valSize of sizes) { + if (valSize > 10 * mb) { + if (numKeys > 1) { + continue; + } + } else if (valSize >= mb) { + if (numKeys > 10) { + continue; + } + } + + benchmarks.push(b({group, dataType, numKeys, valSize})); + } + } + } + } + return benchmarks; +} diff --git a/packages/replicache-perf/src/perf.ts b/packages/replicache-perf/src/perf.ts index d7c34b4082..094a33e705 100644 --- a/packages/replicache-perf/src/perf.ts +++ b/packages/replicache-perf/src/perf.ts @@ -1,19 +1,10 @@ -import {Benchmark, runBenchmark} from './benchmark.js'; +import {type Benchmark, runBenchmark} from './benchmark.js'; import {benchmarks as compareBenchmarks} from './benchmarks/compare-utf8.js'; import {benchmarks as hashBenchmarks} from './benchmarks/hash.js'; -import { - benchmarkIDBReadGet, - benchmarkIDBReadGetAll, - benchmarkIDBReadGetAllGetAllKeys, - benchmarkIDBReadGetAllWithInlineKey, - benchmarkIDBReadGetWithInlineKeys, - benchmarkIDBWrite, - benchmarkIDBWriteWithInlineKey, -} from './benchmarks/idb.js'; +import {benchmarks as idbBenchmarks} from './benchmarks/idb.js'; import {benchmarks as mapLoopBenchmarks} from './benchmarks/map-loop.js'; import {benchmarks as replicacheBenchmarks} from './benchmarks/replicache.js'; import {benchmarks as storageBenchmarks} from './benchmarks/storage.js'; -import type {RandomDataType} from './data.js'; import {formatAsReplicache} from './format.js'; export const benchmarks = [ @@ -22,48 +13,9 @@ export const benchmarks = [ ...storageBenchmarks(), ...compareBenchmarks(), ...mapLoopBenchmarks(), + ...idbBenchmarks(), ]; -for (const b of [ - benchmarkIDBReadGet, - benchmarkIDBReadGetWithInlineKeys, - benchmarkIDBReadGetAll, - benchmarkIDBReadGetAllGetAllKeys, - benchmarkIDBReadGetAllWithInlineKey, - benchmarkIDBWrite, - benchmarkIDBWriteWithInlineKey, -]) { - for (const numKeys of [1, 10, 100, 1000]) { - const dataTypes: RandomDataType[] = ['string', 'object', 'arraybuffer']; - for (const dataType of dataTypes) { - const kb = 1024; - const mb = kb * kb; - const sizes = [ - kb, - 32 * kb, - // Note: on blink, as of 4/2/2021, there's a cliff at 64kb - mb, - 10 * mb, - 100 * mb, - ]; - const group = dataType === 'arraybuffer' ? 'idb' : 'idb-extras'; - for (const valSize of sizes) { - if (valSize > 10 * mb) { - if (numKeys > 1) { - continue; - } - } else if (valSize >= mb) { - if (numKeys > 10) { - continue; - } - } - - benchmarks.push(b({group, dataType, numKeys, valSize})); - } - } - } -} - function findBenchmark(name: string, group: string): Benchmark { for (const b of benchmarks) { if (b.name === name && b.group === group) { diff --git a/packages/replicache-perf/src/runner.ts b/packages/replicache-perf/src/runner.ts index 5aa7764b8f..7083ce234f 100644 --- a/packages/replicache-perf/src/runner.ts +++ b/packages/replicache-perf/src/runner.ts @@ -11,7 +11,7 @@ import * as playwright from 'playwright'; import {assert} from 'shared/src/asserts.js'; import {makeDefine} from 'shared/src/build.js'; import { - BencherMetricsFormat, + type BencherMetricsFormat, toBencherMetricFormat, } from './bencher-metric-format.js'; import {formatAsBenchmarkJS, formatAsReplicache} from './format.js'; diff --git a/packages/replicache-perf/tool/build.js b/packages/replicache-perf/tool/build.ts similarity index 53% rename from packages/replicache-perf/tool/build.js rename to packages/replicache-perf/tool/build.ts index 53304b2d97..17e9032900 100644 --- a/packages/replicache-perf/tool/build.js +++ b/packages/replicache-perf/tool/build.ts @@ -7,11 +7,7 @@ import {makeDefine, sharedOptions} from 'shared/src/build.js'; const dirname = path.dirname(fileURLToPath(import.meta.url)); -/** - * @typedef {'unknown'|'debug'|'release'} BuildMode - */ - -async function buildIndex() { +async function buildIndex(): Promise { const minify = true; const define = makeDefine('release'); const outfile = path.join(dirname, '..', 'out', 'index.js'); @@ -26,20 +22,4 @@ async function buildIndex() { }); } -async function buildRunner() { - const define = makeDefine('release'); - const outfile = path.join(dirname, '..', 'out', 'runner.js'); - await esbuild.build({ - external: ['node:*', '@web/*', 'command-line-*', 'get-port', 'playwright'], - bundle: true, - target: 'esNext', - format: 'esm', - platform: 'node', - define, - outfile, - entryPoints: [path.join(dirname, '..', 'src', 'runner.ts')], - }); -} - await buildIndex(); -await buildRunner(); diff --git a/packages/replicache/.eslintignore b/packages/replicache/.eslintignore index d02e3128b3..4fb0b343ac 100644 --- a/packages/replicache/.eslintignore +++ b/packages/replicache/.eslintignore @@ -8,5 +8,3 @@ src/*/generated/ web-test-runner.config.js perf/index.js -# Ignore this file because dependencies fails ts type check -runner.js