Skip to main content

Module profile

Module profile 

Source
Expand description

The profiler behind retex profile, and the origins of macro definitions behind retex explain (docs/design/profiling.md).

Sampling. A timer thread adds the time elapsed to PENDING every millisecond. The engine looks at it at each macro call and each step of the main loop (Engine::profile_tick), and charges the time to its current state: the files and macros on the input stack, and the engine work under way (Work, marked by Engine::work_begin and Engine::work_end). Without a profiler the counter stays zero, and the check is one atomic load.

A macro leaves the input stack when its last token is read (TeX’s back_list tail calls), so the time including a macro’s callees is a lower bound.

Origins. With Origins on, each macro definition records the innermost file being read and its line (Macro::origin). A file belongs to a package: on the input stack when the file is opened, the first file above the document’s own files that is not one of them.

Structs§

FileInfo
A file read by the job.
Origins
Where macros were defined.
Profiler
The sampling profiler.
Summary
What a profile found.

Enums§

Frame
A frame of a sample’s stack.
SummaryFrame
A frame of a Summary, resolved.
Work
Engine work, charged on its own besides the macros that started it.

Constants§

INTERVAL
The interval between two samples.

Statics§

PENDING
Microseconds elapsed and not yet charged to the engine’s state.