hot path
Code that runs very often, such as on every request, where small costs add up.
In more detail
Small costs such as extra allocations or logging add up there, so it is the first place to optimise after profiling. Code that rarely runs is seldom worth tuning.
Example
V8 counts how often functions run and optimises the hot ones first.Related terms
- allocation — Reserving memory for a new object on the heap.
- ValueTask<T> — A cheaper alternative to Task<T> that avoids an allocation when an async method usually finishes synchronously, such as a cache hit.
- profiler — A tool that records where a running program spends its time or allocates memory.
- just-in-time compilation — Compiling code into machine code while the program is already running, focusing on the parts that run most often.
- TurboFan — V8's optimising compiler, which turns hot functions into fast machine code based on the types it has seen.
- CPU profile — A recording of where a program spent its CPU time, made by sampling the call stack many times per second.
- instrumentation — Code, often a library, that makes an application emit telemetry about its operations.
- log level — A label on each log message saying how serious it is, from debug and info up to error, critical and emergency.
- exporter — A component that sends telemetry out to a backend; in the collector it is the last stage of a pipeline.
Taught in
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Async and Await: Managing Concurrency — Modern .NET Core, C# & Enterprise Microservices
- V8 Engine & JIT Pipeline: Bytecode & Turbofan — Node.js Internals & Backend Services
- Diagnostic Profiling: CPU Profiler & Heap Snapshots — Node.js Internals & Backend Services
- Log Levels Done Properly — Full-Stack Observability: Metrics, Tracing & Logging
- Instrumenting A Service With Client Libraries — Full-Stack Observability: Metrics, Tracing & Logging