Untitled Lesson
Skill Matrix
UNLOCK NODES BY LEARNING NEW TAGS.
In a CPU profile, a function shows high "total time" but very low "self time." What does this most likely indicate?
💻 Code Challenge | +75 XP
Given a slow endpoint, write the diagnostic steps as code comments: checking process.cpuUsage() first, then capturing a CPU profile under load, then identifying the function with the highest self time.
A regex validating user-submitted email addresses is occasionally causing the entire service to hang for several seconds on specific inputs. Reorder the steps to diagnose and fix a suspected ReDoS vulnerability.
Task: Reorder the blocks in logical sequence to solve the problem.
A.D.A. Interface
Adaptive Didactic Assistant

Pascual Vila
Frontend Instructor // Code Syllabus
The Error //
Assuming a slow endpoint is I/O-bound (and optimizing the database query) without first confirming it via CPU usage or a profile
// Cheap first check to avoid wasted effort
const usage = process.cpuUsage();
// High and sustained CPU usage during the slow request points CPU-bound
// Low CPU usage during a slow request points I/O-bound insteadThe Solution //
Optimizing the wrong category of bottleneck wastes significant investigation and engineering time with no improvement to show for it. Check system-level CPU usage first (a quick, cheap signal) before assuming the cause and diving into a specific optimization.
The Error //
Using a regular expression with nested quantifiers against unvalidated, potentially long user input
// Dangerous: vulnerable to catastrophic backtracking
const regex = /(a+)+b/;
// Safer: avoid the nested quantifier structure entirely
const regex = /a+b/; // linear time, no backtracking explosionThe Solution //
Certain regex patterns exhibit catastrophic exponential-time backtracking against specific adversarial inputs, effectively creating a denial-of-service vector if reachable with user-controlled input — a single malicious request can hang the event loop for an extremely long time. Avoid nested quantifiers in patterns that process user input, and consider a regex complexity linter or a dedicated validation library.