-
Notifications
You must be signed in to change notification settings - Fork 129
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
Fix #173 Templated C++ functions cut off after opening parenthesis in template arguments. #174
Conversation
Fixes #173 |
I think the failures here are legitimate (you can see the actual error by clicking "Details", then "View more details on Azure Pipelines", then clicking the failing build step in the list on the left. The style check fails because you haven't run The main tests fail because this changes the output of an existing test: -"java;start_thread;java_start;GCTaskThread::run;ThreadRootsTask::do_it;JavaThread::oops_do;frame::oops_do_internal;OopMapSet::all_do;PSRootsClosure<false>::do_oop;oopDesc* PSPromotionManager::copy_to_survivor_space<false>;InstanceKlass::oop_push_contents 1"
+"java;start_thread;java_start;GCTaskThread::run;ThreadRootsTask::do_it;JavaThread::oops_do;frame::oops_do_internal;OopMapSet::all_do(frame const*, RegisterMap const*, OopClosure*, void (*);PSRootsClosure<false>::do_oop;oopDesc* PSPromotionManager::copy_to_survivor_space<false>;InstanceKlass::oop_push_contents 1" Specifically: -"OopMapSet::all_do;
+"OopMapSet::all_do(frame const*, RegisterMap const*, OopClosure*, void (*); I think what's going wrong is that your new code fails to take into account when there are parentheses inside the function arguments too. In that case, your code will only remove what trails the last |
You should also be able to reproduce the test failure locally by running |
Was missing the submodule. Since the code compiled I didn't think there were any. |
Yeah, the submodule is only needed for tests. Sorry! I wish there was a way to tell git to always check out the submodule when cloning a repo :'( |
So I found the Rust stacks were also mangled due to, e.g. ...FromIterator<(K,V)>>::from_iter being cut off at the last parenthesis. However the js expectations are also "wrong" now. I'm saying wrong, since they don't get cut off when they have template parameters. My basic question would be why we even want to get rid of the parameter list? After all if it just says Call or Invoke, you know very little about the call stack. With the parameters it's much more informative. Wouldn't it be better to just leave the parameter lists inside? |
For example, without the parentheses this wouldn't be informative at all: |
The answer is (perhaps unhelpfully) that we do it because that's what flamegraph did. Now, that's not a very good reason in and of itself, but my guess was that they decided that the argument lists in general only contain redundant information once you have the function name. And I think in general that observation is correct. For the My preference would be to stick with pruning argument lists for now at least. |
src/collapse/perf.rs
Outdated
|
||
// Check for C++ template parameters | ||
let mut offset = 0usize; | ||
if let Some(last_closing_angle_bracket) = func.rfind('>') { |
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 don't think this will quite work either. Consider, for example:
foo(Vec<usize>)
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.
True, probably actually need to do some recursive descent parsing here.
Oh, by the way, we should probably add all these interesting weird cases we come across now as unit tests for that function! |
I'd say you don't know anything about which function is called here, if there's no argument list.
I already fixed the broken test cases on the Rust example. |
Right, but the argument list that you printed also tells you nothing more, since those are just the arguments that
Ah, yes, what I meant was more that we should add these as unit tests for |
…s in C++. * Add failing tests for C++ with std::function in template arguments. * Check if the opening parenthesis is inside a C++ function template, by counting opening vs closing angle brackets.
Codecov Report
@@ Coverage Diff @@
## master #174 +/- ##
=======================================
Coverage 90.23% 90.24%
=======================================
Files 16 16
Lines 2213 2224 +11
=======================================
+ Hits 1997 2007 +10
- Misses 216 217 +1
Continue to review full report at Codecov.
|
I now went with the matching of parentheses. The tidying now doesn't break the old tests (except the faulty Rust tests, which I updated), I added the small unit test for tidy_generic with some edge cases we found here. |
This looks great now, thank you! |
Thank you for your quick response and helpful comments. |
Thank you for sticking with it even with all my comments 😅 |
Oh, I also took the liberty of squashing your commit and cleaning up the commit message a little. Hope you don't mind. See 2230ac7. |
Fix too eager truncation of template parameters on opening parentheses in C++