-
Notifications
You must be signed in to change notification settings - Fork 300
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
[ruby] ANTLR Profiler Summary #4950
Conversation
* Introduced global profiling to summarize rule and parse performance across the project * Added a shutdown hook to dump a summary of the profiler rules in a file `antlr_summary.log` at the root of the project with this information
private val fileCost = TrieMap.empty[String, Long] | ||
private var projectRoot: Option[Path] = None | ||
|
||
sys.addShutdownHook { |
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.
Hmm, I wonder if a shutdown hook is really the best option here - feels a bit messy, since we're mixing concerns: the lifetime of the jvm vs. the completion of a scan.
Sure, that's identical in all current use cases, but are we certain that's going to stay like that forever?
I'd feel better if we collect the results somewhere, maybe even pass them properly, and explicitly print them at the end of the analysis.
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.
Right, my concern was getting metrics on projects that currently don't finish within a couple of minutes, e.g., GitLab. I do, however, understand the concern that shutdown hooks generally aren't for things like this.
Perhaps I could add some flag to detect an early exit, and use the shutdown hook to dump the summary via the hook only if this is the case? Right now the results for each file are written next to each file, so these can be recovered if the scan fails.
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.
Not sure I understand. If a scan doesn't finish within a couple of minutes, how does a shutdown hook help with that?
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.
If we, for example, want to find out a summary of the most expensive rules so far (and not wait for hours), and then we use Ctrl+C
to prematurely stop joern-parse
, we can still get the results.
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.
@mpollmeier Just following up on this. If I remove the hook, it's not a big issue, as the conclusion of which rules are expensive are pretty universal across repos. Would that be preferrable?
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.
Ah ok, understood. Given that for current use cases the hook is not a problem, we can just leave it there and add a comment saying it's optional and just for debug output and can be removed if need be. Or something like that...
private val fileCost = TrieMap.empty[String, Long] | ||
private var projectRoot: Option[Path] = None | ||
|
||
sys.addShutdownHook { |
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.
Ah ok, understood. Given that for current use cases the hook is not a problem, we can just leave it there and add a comment saying it's optional and just for debug output and can be removed if need be. Or something like that...
antlr_summary.log
at the root of the project with this informationExamples from below give a good starting point for the currently most expensive rules:
Railsgoat
ChatWoot