-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Currently, evobench probes are measuring/logging every time the code path where they are placed is executed. For higher-up levels in the code, that is fine.
But sometimes one wishes to benchmark hot code regions. There are two problems using the current approach for those:
-
precision: the measurement and logging has overheads, and while the code region inside this probe's scope may still be OK, timings of probes higher up in the stack include the overhead of the inner scopes (it's possible this could be compensated to some extent, though, if done carefully).
-
log file size: the log files quickly grow very large and become costly to handle.
Statistical probes instead would only do measurement and logging every $n calls, where $n is some specified number, but randomized to avoid aliasing effects. E.g.
EVOBENCH_SCOPE_EVERY(1000, "foo", "bar")
would calculate a random number between 0 and 1000 (say 418) and store it in a counter local to this probe, then decrement until it reaches 0, in which case a measurement and logging is done and then the process repeats.
Open questions:
- Can
threadandstaticbe combined to get function-static variables that are also thread-local? How is their initialization behaviour?
Required work:
-
A good enough fast PRNG that's easy to access; what shall it be?
-
Changes in the probes library:
- The new log message kind
- The
EVOBENCH_SCOPE_EVERYmacro implementation
-
Changes in the evaluator:
- The new log message kind.
- Calculation for statistics accordingly.
- Representation ("tagging") in output somehow, so that readers can be aware of the "n chosen too large" pitfall. Idea: just prefix the count to the probe name, e.g.
1000|foo|bar.
Some additional details:
- If
nis so large that the calculated random number is larger than the total number the probe is called, then no logging will be done at all if it works as described above. Maybe the EVOBENCH_SCOPE_EVERY probe should measure+log the first time it is encountered, and calculate the random number first, and print it with the message; that way, some judgement could be done about how long the last period was before the probe is never called again (e.g. thread torn down).