Auto-generated tile from GitHub (10 skills)
92
94%
Does it follow best practices?
Impact
92%
1.16xAverage score across 44 eval scenarios
Advisory
Suggest reviewing before use
An engineering team has been running a Node.js analytics event processor in production. After a recent refactor, the service began taking significantly longer to process the same volume of events — processing time went from ~200ms to over 2 seconds for the same dataset. The engineers suspect V8 is failing to optimize some of the hot functions but aren't sure which ones or why.
Your job is to investigate the V8 optimization behavior of the provided script, document your diagnostic process and findings, and produce a corrected version of the script that allows V8 to optimize it effectively. The team needs a repeatable diagnostic workflow they can follow in the future, so they want the process scripted.
Produce the following files:
profiling.sh — A shell script that runs the full diagnostic and profiling workflow on inputs/processor.js. The script should: first run the optimization tracing step to identify deoptimization issues, then (once the deoptimization picture is clear) run CPU profiling, and save all output to files.processed.txt — The output of processing the V8 tick profile log (generated by running your profiling.sh).diagnostic.md — A written analysis of what deoptimization issues were found, which functions were affected and why, and what the checkpoint confirms before proceeding to profiling.fixed_processor.js — A corrected version of inputs/processor.js that addresses the V8 optimization problems identified.Clean up any large temporary files (e.g., isolate-*.log raw tick files) after processing.
The following file is provided as input. Extract it before beginning.
=============== FILE: inputs/processor.js =============== 'use strict';
// Analytics event processor - processes batches of user interaction events
function createEvent(type, data, priority) { // Create event object if (priority === 'high') { return { priority: priority, type: type, data: data, timestamp: Date.now(), processed: false }; } return { type: type, data: data, timestamp: Date.now(), processed: false // note: no 'priority' field for non-high events }; }
// Accumulates scores — called millions of times function sumScores() { let total = 0; for (let i = 0; i < arguments.length; i++) { total += arguments[i]; } return total; }
// Calculates a priority weight — called on every event in the hot loop function priorityWeight(event) { if (event.priority === 'high') { return 10; } // Returns a string for non-high priority — same function, different type! return 'low'; }
// Marks an event as done; called after processing function markDone(event) { event.processed = true; // Remove priority from processed events to save memory if (event.priority !== undefined) { delete event.priority; } }
// ----------- main processing loop -----------
const BATCH_SIZE = 500000; const events = [];
for (let i = 0; i < BATCH_SIZE; i++) { const priority = i % 5 === 0 ? 'high' : 'normal'; events.push(createEvent('click', { id: i, value: Math.random() }, priority)); }
const start = Date.now(); let grandTotal = 0;
for (const event of events) { const weight = priorityWeight(event); // weight is sometimes a number, sometimes a string — coercion happens here grandTotal = sumScores(grandTotal, weight); markDone(event); }
console.log(Processed ${events.length} events in ${Date.now() - start}ms);
console.log(Grand total: ${grandTotal});
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20
scenario-21
scenario-22
scenario-23
scenario-24
scenario-25
scenario-26
scenario-27
scenario-28
scenario-29
scenario-30
scenario-31
scenario-32
scenario-33
scenario-34
scenario-35
scenario-36
scenario-37
scenario-38
scenario-39
scenario-40
scenario-41
scenario-42
scenario-43
scenario-44
skills
documentation
fastify
init
linting-neostandard-eslint9
node
nodejs-core
rules
oauth
octocat
snipgrapher