You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There can be cases where you want a variable that is replicated for every matched event, but is not initialized every time the probe body is executed. This requires that you have global state that is only reference-able locally for a probe body.
Enter the unshared variable.
Use Case
Consider the following use case for this variable:
wasm:opcode:memory_grow {
unshared int count;
if count <= 0 {
...
count = rand() % 1000; // some random number between 0 and 1000
}
count--;
}
This effectively samples the execution of each memory_grow operation using random sampling. Continuing on this idea, you could use a global count to sample memory.grow at a random interval for the entire application, e.g.:
int count;
wasm:opcode:memory_grow {
if count <= 0 {
...
count = rand() % 1000; // some random number between 0 and 1000
}
count--;
}
Implementation Details
Basically implement a report variable that is not reported at the end of program execution.
Make It Fast (Wizard)
The JIT could put the if count <= 0 check inline (~3 opcodes) and then call out to the probe body callback if the predicate is true
Justification
There can be cases where you want a variable that is replicated for every matched event, but is not initialized every time the probe body is executed. This requires that you have global state that is only reference-able locally for a probe body.
Enter the
unshared
variable.Use Case
Consider the following use case for this variable:
This effectively samples the execution of each memory_grow operation using random sampling. Continuing on this idea, you could use a global count to sample memory.grow at a random interval for the entire application, e.g.:
Implementation Details
Basically implement a
report
variable that is not reported at the end of program execution.Make It Fast (Wizard)
if count <= 0
check inline (~3 opcodes) and then call out to the probe body callback if the predicate istrue
The text was updated successfully, but these errors were encountered: