-
Notifications
You must be signed in to change notification settings - Fork 270
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
Adding manual sample entries #193
Comments
You've bumped into the lack of an extendable Sample API here. Right now the solution is to add your own So the "plan" is to simplify the Sample implementations and expose custom callbacks to add your own Sample types without having to add anything to the implementation. That's not going to solve your immediate problem, however. I don't want to add this extra kind of API but let me think about it all day today. It may be that you'll have to maintain a fork for this kind of custom modification but maybe there's a way to avoid that. |
Ok, good to know. 👍 I'd also like to point out that this is not an immediate concern, but I would like to to have something in place for us during this year. |
Can you give me an example of the Lua functions you want to call that generates this debug/timing info for you? |
Tbh, I'm not sure I need/want this feature request anymore. Currently, I've implemented a As for Lua, it has the capability of adding a debug hook, but I couldn't get it to work reliably with LuaJIT (only did a first test the other day). Since we have the Lua begin/end, and it seems to solve our use case, I'll close this feature request. |
You can quickly detect an unbalanced tree due to missing ends by marking your root with |
Coming back to this, I believe I need to be able to make it a bit more "robust" than simply asserting on unmatched scopes. What would be the best way to achieve this? |
I believe in that case, I should be able to protect that scope with a Lua PCall, so that I can catch any lua error, and then gracefully exit the profile scope. |
Can you inject a to-be-closed variable? |
Do you mean like a struct with constructor/destructor (i.e. RAII behavior)? Yes, we use those on the C++ side, however, the problem is that Lua can make calls to But, I can set my own position to jump to by making my own protected Lua call. |
to-be-closed variables call their I was thinking you inject some lua bytecode to introduce the variable on each sampling scope, or do it via the API, if possible. |
Aha, I didn't know about that functionality! Unfortunately, we're stricly Lua 5.1 due to the compatibility with LuaJIT. |
If you could debug hook The only alternative I can see is to make stack imbalances less fatal. That will require some more book keeping per sample:
It could work... but it will require yet another integer storage with increment/decrement. Annoying, but more robust. Though that said, if the tree is reconstructed elsewhere, instead of when you call Push/Pop, that cost won't factor in the threads you are timing. But that's for a later date. And to be fair... I'm usually in favour of this kind of redundancy as it makes the library easier to adopt and maintain. And we already have Yet more comments: and the integer could be bitwise very small unsigned as wrap-around will ensure we'll always hit zero if there tree is balanced. If it's 8-bits it means somebody would need 257 children to break the balance detection, 16-bits even more. |
My favorite so far is the book keeping with the open/closed children. For the workarounds I had in mind in Lua/C all involved wrapping functions. I'd have to put your code into a function. The wrapper call signature is a bit clunky.
|
In our use case, we have projects that have large Lua code bases, and sometimes they need to figure out where the time is spent in their scripts.
Lua has it's own way of adding debug callbacks, which allows the client to gather the data they need.
I think it would be beneficial to be able to add these "externally" collected samples into the profiler data.
On the C side, it might be good to mimic the current C code flow with the Begin/End pairs:
As a first step, the question is what do you think about the idea, and if it would fit Remotery?
The text was updated successfully, but these errors were encountered: