Skip to content
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

is it possible to identify synchronous executed functions? #495

Closed
helio-frota opened this issue Aug 25, 2021 · 7 comments
Closed

is it possible to identify synchronous executed functions? #495

helio-frota opened this issue Aug 25, 2021 · 7 comments

Comments

@helio-frota
Copy link

When looking at flamegraph tools we can see some executed functions.

I was thinking if is it possible to:

a) To see all the executed functions without native modules
or
b) To see all the executed functions using native modules

c) to use async_hooks + the results of a) or b) above to make a diff between all the sync and async executed functions.

If something like that is possible to do, then it will probably help to answer this:

#439
https://docs.google.com/document/d/1Yip9zU_8axfZwN-clGMeoNWVYHZPfBjepLV3Ur2JjwA/edit#
TODO: Investigate how to identify synchronous calls on running processes

Let's imagine an app is made of 20 functions, even if all the 20 were not executed if we are able to identify 4 of 13 making a difference for example 4 sync and 9 async, I believe that is really helpful to try to answer that item.

please let me know if that makes any sense 👍

@gireeshpunathil
Copy link
Member

@helio-frota - can you elaborate a little more on how you are drawing a relation between synchronously executed code and code that uses native modules in the context of performance analysis?

@helio-frota
Copy link
Author

helio-frota commented Aug 26, 2021

@gireeshpunathil sure thing, sorry I believe I caused confusion also to myself by reading the description above again : )

This issue is more asking if it is possible to create a relationship between async_hooks and other tools that capture execution context and try to make a difference between what is identified by async_hooks and other tools, to try to identify synchronous code execution.

About the native modules, I'll try to fix that part in the comment.
For example, https://github.com/davidmarkclements/0x is not using native modules.

  1. Does make sense to try to combine the results from this tool + results from async_hooks?

  2. Maybe async_hooks alone (without other tools) can help to identify synchronous code. 🤷‍♂️

Anyway, that is kind of confusing to me because sync code in this context, is related to timing and is supposed to be fast but when is not then it should be turned async to avoid block the execution.

Maybe the TODO should be?

TODO: Investigate how to identify the duration of synchronous calls on running processes

But at the same time, I start to think: What is considered a slow sync call (that may depend on each app requisites)

And thinking more on that (execution time of sync functions) maybe makes no sense to make a diff between functions
(example: 4 async and 16 sync of 20 functions), since we can't define that for example, 100ms is slow or fast for an app 😞

I believe I was naive to think that out of 20 functions executed if 15 are asynchronous then the other 5 are synchronous. 😄

@RafaelGSS
Copy link
Member

Does make sense to try to combine the results from this tool + results from async_hooks?

I don't think so. If I understood correctly the objective is to identify sync functions that are blocking the event-loop, so, I don't think that async_hooks has something very useful to it.

I believe that CPU profiling is the best way to identify which function is doing more work in the whole context.

I may not have understood what you want to achieve from that.

@helio-frota
Copy link
Author

If I understood correctly the objective is to identify sync functions that are blocking the event-loop,

@RafaelGSS exactly, my initial thoughts don't make any sense, it would be good to update the document.

from:
TODO: Investigate how to identify synchronous calls on running processes
to
TODO: Investigate how to identify sync functions that are blocking the event-loop on running processes

Then close this issue 👍

thanks

@RafaelGSS
Copy link
Member

TODO: Investigate how to identify sync functions that are blocking the event-loop on running processes

I believe CPU Profiling is common sense in this case.

@Qard
Copy link
Member

Qard commented Aug 30, 2021

Specific correlation between the two is difficult, but you can track event loop blocking time and time spent executing a given function, then just loosely correlate them based on time. You won't know X set of async tasks were delayed because of Y function taking too long, but you will know that Y function frequently blocks and would likely be a leading cause of async task delays.

@helio-frota
Copy link
Author

@Qard thank you for that extra information 👍 that clarifies more to me in relation to my first question and the subsequent comment.

Also, I've updated the document with a suggestion based on @RafaelGSS response, that is why I decided to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants