Repository navigation
Releases
v0.5.2
v0.5.1
Fixed
- The collector did not compile on MSVC x86.
_BitScanReverse64exists only on x64 and
ARM64, so 32-bit targets now scan the two 32-bit halves. - Shared memory could not be created in 32-bit MSVC Debug builds. slick-queue fetched
slick-shm 0.1.6 ahead of the required 0.1.7, and an installed older copy was accepted
too. The build and the installed package now require 0.1.7. With an older one installed,
the build fetches slick-shm and slick-queue.
Added
slick-perfmon-package-enabledcompiles the collector from an installed, enabled
package. The old package test installs with instrumentation off, reducing the
collector to a stub, so the x86 break slipped through.- Windows x86 CI job.
v0.5.0
Added
do_not_optimize(v)keeps the work producingvinside the span. A result held in a
register and read only afterend()could be computed after the closing timestamp, and
GCC, Clang and MSVC all did that at-O2. Free on GCC and Clang. On MSVC it costs one
stack store, plus a load for a non-constv.slick-perfmon-stamp_ordertest, which checks the order of work and stamps in the
compiled code.
Fixed
- The compiler could move memory operations across a fenced stamp, so a span could time
less than its work. GCC and MSVC move them acrossRDTSCP, MSVC treatsLFENCEas a
load-only barrier, and MSVC removed a span's stores outright. Compiler barriers now go
before every fenced stamp and after the closing one: a one-bytenopeach on MSVC
(three per begin/end pair), nothing elsewhere.
v0.4.0
Breaking changes are in bold under Changed.
Added
- Per-thread rings. Each instrumenting thread claims a single-producer ring on its first
stamp, so stamps no longer contend: a publish is three relaxed stores and a release
store, with no read-modify-write. The collector merges the rings by timestamp, so spans
still cross threads, DLLs and processes. Threads past the cap use the shared ring, and
a thread that exits hands its ring to the next new one. config::max_thread_rings(64, at most 4096; 0 sends every thread through the shared
ring) andconfig::thread_ring_capacity(65536 slots, a power of two). Together they
are capped at 2 GiB.prepare_thread(), which claims the calling thread's ring and faults its pages in.
start()does it for the calling thread, except inmode::shared_collector.Collector::session(), the handleattach()takes.- The collector frees rings held by a producer process that died.
--thread-ringsand--thread-ring-capacityonslick_perfmon_collector.- Benchmark cases for the cost of a publish and of a span at 1 to 8 threads.
Changed
attach()takesCollector::session()instead of asample_queue*, and a module
that attached must attach again after the host restarts. Until it does, its stamps go
to the ended session and are not recorded.Collector::ring()is only the shared ring that threads past the cap use. With
rings on, stamps written into it by hand are merged with the rings by timestamp, not
paired in the order written.- The shared-memory layout version is 5. The thread rings live in the
.metasegment
after the names. Rebuild collectors and producers together; a producer must use the
collector's thread ring settings orstart()throws. - The rings take
max_thread_rings × thread_ring_capacity × 16bytes of address space,
64 MiB by default, touched only as they are used. - Stamps are paired once they are 2 ms old, so periodic rows trail by that much.
flush(),shutdown()and the calls that flush first (snapshot(),reports(),
dump_summary()) wait at least ~20 µs instead and pair everything stamped before the
call. A thread that keeps stamping cannot hold them up. - The collector waits at least 50 µs between passes that found work.
- A stamp costs ~172 cycles (was ~205) and a value sample ~16 (was ~29). At 8 threads a
publish costs ~68 cycles where it cost ~429.overhead_cycles()reads ~130 (was ~165). - With rings on, stamps from threads past the cap are ordered by timestamp, so a
backwards TSC on one of them reads asorphanrather thaninvalid.
Fixed
- A span still open at
shutdown()was dropped without a count unless it was older than
stalled_sample_timeout. It now counts asabandoned.
v0.3.0
Several changes here are breaking: the entries in bold under Changed.
Added
- Value samples.
value(point, v), orSLICK_PERFMON_VALUE, records an unsigned 64-bit
number that is a measurement in itself — a queue depth, a batch size — with no begin,
no end and no timestamp. It reuses the 16-byte ring record and skips the TSC read, at
~29 cycles against ~196 for a stamp. The backend reports the same statistics as for a
latency but as recorded: no unit conversion and no overhead subtraction. Collector::snapshot_value()for a value point's statistics, andStageReport::value
to tell its row from a latency row inreports().- A
kindcolumn in the CSV,latencyorvalue, saying what a row's figure columns
hold. Value points are rows of the same CSV and the same summary table, under the
stage namevalue; in the summary their figures print as bare numbers. Collector::remove_shm(name), which removes both shared segments of a session. It is
now the only thing that does — see below.kValueStep,kMaxSpanStepandis_value_event()beside the existing step constants.- Benchmark cases for a value sample and for accumulating a drained value.
Changed
-
Step
0xFEis reserved as the value marker. Span steps are0x01..0xFD; a
step(point, 0xFE)is read back as a value sample. -
The shared-memory layout version is 4, because an event with step
0xFEnow means
something else. A collector and a producer built either side of this release refuse to
share a segment; rebuild them together. -
The CSV header has changed —
kindfollowsstage— and anything reading the file
by column position sees the columns fromcountonward move one place right. A CSV
written by an earlier version is not appended to:start()throws
std::invalid_argument, since rows in such a file cannot be told from value samples.
Use a newconfig::pathor move the old file aside. -
The stage label
valueis reserved. Aname_ofthat returns it for a step of a
span is treated as returning no name, and the stage gets the generated
step_<a>-><b>label. -
Shared segments are never removed implicitly. Neither
shutdown()nor
~Collectorunlinks the ring or the control block, so a collector restarted under
running producers reopens the same segments and reports them under the names they
published. On POSIX, where a segment outlives every process that mapped it, this means:/dev/shm/<shm_name>and<shm_name>.metaremain after a session until
Collector::remove_shm()is called;- a later session on the same name with a different
queue_capacityormax_names
throws a mismatch, and a renamed point keeps its first label, until the name is
removed — including the same-Collectorrestart with a newqueue_capacitythat
v0.2.0 made work; - a producer started with no collector running attaches to segments an earlier session
left behind, returnstruefromstart()and stamps at full cost into a ring
nothing drains. "Costs nothing without a collector" holds only for a name with no
segments.
On Windows a segment is freed with its last handle, so it persists only while some
process is attached. -
slick-queue 2.3.0 is now the minimum, for the build and for the installed package.
v0.2.0
Changed
- The summary table has an
invalidcolumn, afterdropped, so every point anomaly
appears there. Anything reading the summary by column position sees the columns from
invalidonward move one place right; the CSV already had it and is unchanged. - The summary's
p50andp99columns are always the run's real median and 99th
percentile, taken fromconfig::percentileswhen it has them and computed from the
histogram when it does not.StageReport::summary_p50andsummary_p99carry them. - slick-queue 2.1.0 is now the minimum, for the build and for the installed package.
Fixed
- Percentiles take the documented nearest rank,
ceil(p / 100 * n), instead of
rounding it:p51of{1, 10000}reported 1, though only half the samples are at or
below it. The rank is computed in integers, exactly, over every count auint64_tcan
hold — a floating-pointceil()would putp99.9of 1000 samples one rank too high. - The summary printed the nearest configured percentile under its fixed
p50andp99
headings: withpercentiles = {90}both columns showed the p90. - A span discarded for a backwards timestamp showed in the summary as a row of zeros,
becauseinvalidwas the one anomaly counter it did not print. shutdown()stopped its final drain at the first unpublished slot, silently dropping
every event published behind it. It now drains everything reserved before it; holes
share one grace period, the shorter ofstalled_sample_timeoutand 100 ms, and are
then stepped over and counted installed.- A shared-memory producer that kept publishing held
shutdown()open for as long as it
ran. The final drain now stops at what was reserved when shutdown began. dump_summary()read the stall count while the collector thread was incrementing it,
a data race on every live call during a stall. The header now shows the count
published with the rows beneath it.dump_summary()left the caller's stream in the summary's format — fixed notation,
four decimals, its own fill and alignment. The stream's format is now restored.- CSV and summary numbers follow the process's global locale no longer: a decimal comma
or digit grouping put extra separators in a CSV row. Both are written in the classic
locale; a stream passed todump_summary()keeps its own. - Restarting a shared session on the same
shm_namereopened the previous session's
segment, which the retired ring was still holding, and threw on a changed
queue_capacity. The retired ring is now freed first. cmake --installwith a customCMAKE_INSTALL_INCLUDEDIRproduced a package whose
exported target still pointed atinclude, so every consumer failed at generation.
The exported path now comes from the same variable the headers are installed with.
v0.1.0
Initial release.
Measurement model
- Raw-event measurement:
begin/step/endeach publish one 16-byte timestamped
event to a lock-free MPMC ring, and the backend reconstructs spans from them. No
delta, no lookup and no thread-local state on the instrumented thread. - Multi-step spans, reporting every stage transition plus the end-to-end total from the
same stamps. - Optional 24-bit correlation id (
seq), so concurrent spans on a single point pair
correctly. - Spans may open and close in different functions, threads, DLLs or processes.
ScopedSampleRAII guard andSLICK_PERFMON_SCOPE, stamping through exception
unwinding, withcancel()as the opt-out.- User-defined point ids plus a
constexpr(point, step)to name function; no
registration table.
Backend
- Statistics: count, min, max, mean, Welford standard deviation, and histogram
percentiles with a bounded ~3% relative error. - Anomaly reporting:
dropped,invalid,abandoned,orphan,stalled,
out_of_range— per interval in the CSV, as lifetime totals inreports()and the
summary. - Bounded, preallocated tables:
max_open_spansopen spans with amortised eviction,
max_stagesstage accumulators,max_namesshared name slots. Nothing grows under
load, and the surplus is counted rather than dropped. - Continuous TSC calibration against
steady_clock, refined over the whole run, and an
invariant-TSC probe that says so in the summary when there is none. - Startup measurement of the per-stamp floor, reported by
overhead_cycles()and
optionally subtracted from every stage (config::subtract_overhead, off by default). - Introspection for sizing a session:
peak_open_spans(),last_flush_cycles(),
name_conflicts().
Deployment
- Three modes: in-process
local, andshared_producer/shared_collectorover
shared memory, with a standaloneslick_perfmon_collectorexecutable. - Producers publish their point and stage names into the segment; the collector binary
needs no knowledge of them, and two peers disagreeing about one name is counted as a
conflict rather than silently resolved. - A producer whose collector is not running records nothing, creates no segment and
costs nothing;config::create_if_absentreverses the startup order. Collector::set_instance()shares one collector across DLL boundaries.SLICK_PERFMON_CSV,SLICK_PERFMON_SHMandSLICK_PERFMON_DISABLEconfigure or
auto-start a session without touching the instrumented binary; they only fill in
fields left at their defaults.
Output
- CSV time series, one row per stage per interval, carrying its own unit
(config::output_unit: cycles, nanoseconds or microseconds), its owntsc_hz, and
RFC 4180 quoting for user-supplied labels. - Restarting against an existing file appends only onto a matching header; a session
whose percentile list, unit or overhead correction disagrees with the file refuses to
start rather than write rows the header labels wrongly. - Rows with no samples are dropped, except where the counters are the content: an
interval's anomalies, theoverflowbucket for runs pastmax_stages, and a
collectorrow for a dropped or stalled interval that produced nothing else. - Human-readable summary table, written at shutdown and on demand via
dump_summary(). config::csv_flush_intervaltrades per-interval durability for fewer writes on the
collector thread.
Build
- Header-only, C++20, MSVC / GCC / Clang on Windows, Linux and macOS. x86-64 uses
RDTSC/RDTSCP; other architectures fall back tosteady_clockand say so. SLICK_PERFMON_ENABLED=0compiles every stamp out - measured at 0.0 cycles in the
benchmark - and drops the slick-queue and slick-shm dependencies with it. Both feature
switches are baked into the installedConfig.cmake, so afind_packageconsumer
gets the headers as they were built.- Runtime enable/disable costs nothing beyond the null check already on the path
(~2.5 cycles per stamp). - Compile-time tunables:
SLICK_PERFMON_SERIALIZE,SLICK_PERFMON_NAME_CAPACITY,
SLICK_PERFMON_HIST_PRECISION.
Measured cost
On an AMD Ryzen 9 5900HX (3.29 GHz TSC, Windows, unpinned): ~205 cycles for a single
fenced stamp and ~195 per stamp in a span, ~130-172 with SLICK_PERFMON_SERIALIZE=0.
Per-stamp cost is flat across span length, and a runtime seq is free. See the README
for the full table.