-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use coarsetime #92
Use coarsetime #92
Conversation
event->start_time = ctx->PHP_FUNCTION_ARG_START_TIME; | ||
event->end_time = ctx->PHP_FUNCTION_ARG_END_TIME; | ||
event->timestamp = bpf_ktime_get_ns(); | ||
event->elapsed = ctx->PHP_FUNCTION_ARG_ELAPSED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is actually clever.
Because you are now no longer affecting performance you can get the ts in the event instead of from the actual function in PHP. Event ordering is still giving the parent hierarchy, right?
Another way - though slightly more effort is to create a real realtime clock TS at start of request.
And then pass this realtime start, monotonic start and monotonic end always to the probe! - that way it’s both realtime and not really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been working well. I really like decoupling the timestamps and letting the probe me a metric.
@@ -30,16 +30,16 @@ unsafe extern "C" fn execute_ex(execute_data: *mut sys::zend_execute_data) { | |||
}; | |||
|
|||
// Run the upstream function and record the duration. | |||
let start = get_unix_timestamp_micros(); | |||
let start = Instant::recent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem is that you only update on function end. I don’t know how realistic it is to never call a small function that returns, but maybe a good way to solve this is to have a call stack depth % 20 or so and call update() every once in a while.
That can be a stack local variable - right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at options. Thanks for the review @LionsAd !
What does this change