-
Notifications
You must be signed in to change notification settings - Fork 51
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
Callback duration metric #439
base: master
Are you sure you want to change the base?
Conversation
importing metrics here would create a circular dep that would need to be broken - but other than that, metrics aren't really appropriate for the task: the way to do this would be to introduce a pre/post callback which gets enabled by a |
Agree, metrics aren't the right way to measure this. I like @arnetheduck idea about pre/post callbacks, makes sense. |
I was thinking about that. It seems like it'd be possible to allow generic pre/post calls. It's not quite clear if it'd be more useful to track all callbacks or Future's or closure-iterators. I took a stab at it using a more concrete timing for each closure iterator for each async proc: #442 That approach doesn't allow for getting stacktraces, or only recording long running ones. |
If there no re-entrant calls to
And Calculating callbacks duration is pretty uninformative and intrusive for chronos scheduler. If you {.async.} procedure is slow - it is slow, if you need to get time of execution of this procedure - establish time measurement around this procedure. Metrics you trying to meter will help you measure parts of your procedures. For example:
So you got 3 measurement of code between calls to
|
I think this is being approached from the wrong end: ie I'd recommend first building a useful end-to-end solution for something concrete - ie something that provides value - if, in the end, it so happens that there exists a feature of sufficient genericity that it indeed would be easier to create a generic / shared solution in chronos, we can look at it from the perspective of a specific useful thing - like this, we're just throwing mud at a wall to see if something will stick and what shape it'll have. Notably, the above can trivially be developed in a branch of chronos and showcased using that branch. |
I think your original proposal with pre/post hooks makes more sense. It allows building this types of features on top of chronos without bundling them with chronos unless they prove useful... Of course, even the simple callback approach has to be carefully thought out - do we want it as a generic future that or only something that sits behind a flag and only allowed in debug builds? |
That's a useful question, and one I'm trying to understand. Measuring the non-async sections can be useful since these sections are often the parts that disrupt overall tail latencies in a project. It's often useful to tracking down incorrect usage of blocking calls (disk IO, compute, blocking network calls, unbroken for-loops, etc). Meanwhile, the time of the async portions can be somewhat gauged by proxy using total request time. If I understand it, the callback approach described above wouldn't provide the granularity to measure the actual time it takes to execute the async proc time, only the total duration. |
I disagree; this is a useful concrete solution to measure timings which would otherwise not be readily feasible to us. Also, the feedback from @cheatfate was helpful.
I'm onboard with creating a more generic solution if possible, but wanted to spitball something concrete and see how well it worked. These sort of timings could provide our project value, and possibly others, since non-async portions can easily cause issues.
Isn't that what a draft PR is for? ;) Still that was my first approach, but I don't have access to create a branch and things get lost on a fork. I am also new to Chronos as a project and unsure the best way to get useful feedback. A draft PR gives a chance for a broader audience to chime in. |
I took my PR from yesterday and used it to make a more generic solution based on callbacks in I'm not 100% sure if it's where you were thinking of adding the callbacks @arnetheduck. Future's made the most sense for a generic API as it could cover both iterators and callbacks. It'd need more testing to see how useful it'd be. Note, I also needed a third callback I'd say this PR could probably be closed? |
All right... this doesn't currently work and I need some help.
Here's the goal:
As a chronos user, I want to be able to measure callbacks durations (when using debug builds), so that I can be informed about long callbacks that will cause my app to block/not respond.
I've added a compile-flag and some code to asyncloop.nim to try and get this going, only to realize that chronos doesn't use nim-metrics. (And can't because nim-metrics uses chronos?) So I'm writing this message to ask help from you, experienced chronos developers! Do you see a use for a feature of this sort? How can this best be accomplished?