-
Notifications
You must be signed in to change notification settings - Fork 163
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
Give human-readable names to functions in InstallMethod #3420
Conversation
da1e085
to
54dec72
Compare
Codecov Report
@@ Coverage Diff @@
## master #3420 +/- ##
==========================================
+ Coverage 85.34% 85.35% +<.01%
==========================================
Files 699 699
Lines 346091 346427 +336
==========================================
+ Hits 295373 295676 +303
- Misses 50718 50751 +33
|
@ChrisJefferson please assign labels to your PRs. |
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.
Looks sensible to me overall, but a comment needs to be adjusted. Also, some musings...
@ChrisJefferson I find the description for release notes "Give more library functions descriptive names when profiling" to be misleading. This PR does not seem to change any names - it intends to add ability to do this, and apparently adds new functions to do this, which should be then mentioned in release notes (and linked in their GAPDoc version to appropriate mansections). |
0f6f3b2
to
a6766fa
Compare
Improved code (although I haven't switched to an attribute). Linked up docs, and also linked up the unused doc for SetNameFunction. I put two things in the release notes, as I feel the better names are important (and this PR does add better names, that's the point). Adding "HasNameFunction" doesn't feel like something most people would care about, so it should probably be mentioned in some kind of "minor" section (or it can be put with all the other release notes, don't mind). |
3808817
to
8f8f113
Compare
I'm happy to rebase this, is this PR fine as it is? (I don't mind if someone else wants to add #3430 on top later). |
@ChrisJefferson as @alex-konovalov noted, the title of this PR is misleading, and unsuitable for release notes. |
OK, so this now obviously needs to be rebased... sorry for the hassle. |
I can't fix this, as I can't call HasNameFunction in oper.g, and I can't figure out where it is declared to know what/if it's "internal" name is. |
@ChrisJefferson |
Nope, segfaults |
Ahh, of course: As long as |
So one quick fix would be to check for |
Nope, still segfaults (see my pushed version, I check for |
Interesting. I can't reproduce a segfault here with your branch. I do get a strange error, though:
|
I guess the cause for the error is that w/o your patch, I get this:
but with it, I get this, which then breaks stuff:
I don't have time to track it down further right now, sorry. |
323d279
to
ff2c1fd
Compare
Hopefully now all updated + cleaned up. |
This makes these methods easier to understand when profiling. We add a name both to the installed method, and the function which calculates their rank, where present.
@@ -601,6 +601,31 @@ BIND_GLOBAL( "INSTALL_METHOD", | |||
fi; | |||
fi; | |||
|
|||
if IS_FUNCTION(method) and IsBound(HasNameFunction) and | |||
IsBound(TYPE_FUNCTION_WITH_NAME) and IsBound(TYPE_OPERATION_WITH_NAME) and | |||
not VAL_GVAR("HasNameFunction")(method) then |
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.
So, I am in principle fine with keeping this as is, but here's an alternative that might perhaps be a bit easier to read, and which would ensure that the handful of methods which are installed before HasNameFunction
is defined properly get names, too: Right before this function, insert HasNameFunction := ReturnFalse;
, possibly with a comment explaining what's going on. Then Unbind(HasNameFunction);
right before HasNameFunction
is actually defined. And here, we can then simply return to the original form, i.e.:
if IS_FUNCTION(method) and HasNameFunction(method) then
and of course similar for the rank function
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.
To be clear, I am OK with this is merged as-is, though you may wish to at least ponder my suggestion :-).
@markusbaumeister pointed out that many library functions show up as "nameless" in profiling output. This turned out to be because InstallMethod does not give the functions a useful name. This is a shame, as it's easy to give them a very informative name in InstallMethod. This PR does that.
This shouldn't cause any problems, apart from using a small amount of extra memory on strings. I decided to also give a useful name to the functions which calculate priority. While these functions are very small, it's still useful to know what they are in a trace.
Text for release notes