What is Probe effect?
The phenomenon in which adding a measurement mechanism changes the behavior of the program being measured.
Japanese name: プローブ効果
The phenomenon in which adding a measurement mechanism changes the behavior of the program being measured.
Japanese name: プローブ効果
Measuring a program requires adding some mechanism, such as log output, code that records times or a debugger. The mechanism itself uses CPU time, memory and cache. As a result the timing of the processing changes and the program behaves differently from when it is not measured. This phenomenon is called the probe effect. A probe is an instrument inserted in order to measure. Because observing changes the thing observed, it is also called the observer effect.
In instrumentation, which inserts recording code at the entry and exit of functions, the shorter the function, the larger the effect. If 40 ns of recording per call is added to a function that really takes 10 ns, the measured time is 50 ns. The function appears to take 5 times its true time. The recording code also displaces cache contents, so surrounding code can slow down as well. Sampling, which records the state at regular intervals, is a method with a comparatively small effect.
In programs with several threads, some bugs change the result through slight differences in timing. A data race is the typical example. Adding log output or a debugger changes the order in which the threads run. The bug may then stop appearing or, conversely, appear more readily. A bug that vanishes when one tries to observe it is sometimes called a heisenbug. To reduce the effect, keep the recording light and check whether the result changes with and without measurement.
Answer: B. 4 times
Each measured call of f takes the true 20 ns plus 60 ns of recording, or 80 ns, andtimes. This phenomenon, in which the mechanism for measuring changes the very behavior being measured, is called the probe effect. Recording also replaces cache contents, so in practice the slowdown can be even larger. For programs with many small functions, measure the time breakdown with a sampling profiler, or subtract the measurement overhead itself.
It is hard to eliminate completely as long as the measurement is done in software. Choose a method with a small effect and estimate the cost of the measurement itself by measuring it separately. Mechanisms that do not modify the program, such as hardware performance counters, have a smaller effect.
Not necessarily. The logging may have changed the timing so that the condition for the bug has merely become less likely. If the logging is removed without the cause being identified, the bug may return.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.