Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/acme-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

fraud-model-benchmark:
name: Fraud model benchmark
runs-on: ubuntu-latest
runs-on: ubuntu-latest-4-cores
steps:
- uses: actions/checkout@v4

Expand All @@ -49,7 +49,7 @@ jobs:
- run: npm run profile:cpu
env:
PROFILE_CPU_TASKS: 256
PROFILE_CPU_ITERATIONS: 6250000
PROFILE_CPU_ITERATIONS: 9500000
PROFILE_CPU_WORKERS: 32

unit-tests:
Expand Down Expand Up @@ -105,10 +105,10 @@ jobs:
include:
- platform: linux/amd64
tag-suffix: linux-amd64
runner: ubuntu-latest
runner: ubuntu-latest-4-cores
- platform: linux/arm64
tag-suffix: linux-arm64
runner: ubuntu-24.04-arm
runner: ubuntu-latest-4-cores
steps:
- uses: actions/checkout@v4

Expand Down
9 changes: 4 additions & 5 deletions solutions-engineering/migration-lab/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM --platform=linux/amd64 node:22-bookworm-slim
FROM node:22-bookworm-slim

WORKDIR /app

COPY app/package*.json ./
COPY app ./
RUN apt-get update && apt-get install -y python3 make g++ && rm -rf /var/lib/apt/lists/*
RUN npm ci --omit=dev

COPY app/src ./src
COPY app/scripts ./scripts
RUN node scripts/docker-build-workload.js

EXPOSE 3000

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const crypto = require('crypto');
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');

function taskCount() {
return Number(process.env.DOCKER_BUILD_TASKS || 64);
}

function iterationCount() {
return Number(process.env.DOCKER_BUILD_ITERATIONS || 18000000);
}

function workerCount() {
return Number(process.env.DOCKER_BUILD_WORKERS || 4);
}

function runNativeBuildTask(iterations) {
const output = crypto.pbkdf2Sync(
'acme-payments-container-build',
'native-addon-build-cache',
iterations,
64,
'sha512',
);

return output.readUInt32BE(0);
}

if (!isMainThread) {
parentPort.postMessage(runNativeBuildTask(workerData.iterations));
return;
}

function runTask(iterations) {
return new Promise((resolve, reject) => {
const worker = new Worker(__filename, { workerData: { iterations } });
worker.once('message', resolve);
worker.once('error', reject);
worker.once('exit', (code) => {
if (code !== 0) {
reject(new Error(`worker exited with code ${code}`));
}
});
});
}

async function main() {
const tasks = taskCount();
const iterations = iterationCount();
const workers = Math.min(workerCount(), tasks);
let nextTask = 0;

console.log(`running native build workload with tasks=${tasks} iterations_per_task=${iterations} workers=${workers}`);

async function runQueue() {
while (nextTask < tasks) {
nextTask += 1;
await runTask(iterations);
}
}

await Promise.all(Array.from({ length: workers }, () => runQueue()));
console.log('native build workload completed');
}

main().catch((error) => {
console.error(error.stack || error.message);
process.exit(1);
});
1 change: 1 addition & 0 deletions solutions-engineering/migration-lab/app/scripts/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const files = [
path.join(__dirname, 'shard-tests.js'),
path.join(__dirname, 'integration-db-stress.js'),
path.join(__dirname, 'docker-arch-check.js'),
path.join(__dirname, 'docker-build-workload.js'),
path.join(__dirname, 'resource-profile.js'),
];

Expand Down
Loading