CtrlK
BlogDocsLog inGet started
Tessl Logo

simon/skills

Auto-generated tile from GitHub (10 skills)

92

1.16x
Quality

94%

Does it follow best practices?

Impact

92%

1.16x

Average score across 44 eval scenarios

SecuritybySnyk

Advisory

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-44/

Diagnose and Fix V8 Performance Regression in Analytics Processor

Problem Description

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.

Output Specification

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.

Input Files

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

README.md

tile.json