-
Notifications
You must be signed in to change notification settings - Fork 160
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
Reorder methods after new implications are added #2521
Conversation
edd1329
to
d05e382
Compare
Codecov Report
@@ Coverage Diff @@
## master #2521 +/- ##
=========================================
Coverage ? 75.42%
=========================================
Files ? 478
Lines ? 241759
Branches ? 0
=========================================
Hits ? 182343
Misses ? 59416
Partials ? 0
|
lib/oper1.g
Outdated
ranknow := rank(); | ||
else | ||
ranknow := rank; | ||
fi; |
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.
Perhaps rename rank to baserank, and ranknow to rank, in order to reduce the diffs?
So the problem (or at least the first one) turns out to be for |
d05e382
to
0a43914
Compare
The bug that arose is fixed in #2533 (the reordering revealed a real bug in the library). There are still a few changes to output formats and similar |
d6d0d66
to
ae15f65
Compare
This is now working, as far as I can see, although the diagnostic printout needs to be removed before it is merged. The method rankings are recomputing to respect current implications:
This takes about 60ms (on my laptop) in a standard GAP session if there is nothing to do (I had to expand a couple of caches to get it down to that) but about 1.5second with all packages (more or less) loaded. Documentation and possibly tests are also still due. |
Tests fail: first off, |
ae15f65
to
64b75ff
Compare
lib/package.gi
Outdated
else | ||
List( RecNames( GAPInfo.PackagesInfo ), LoadPackage ); | ||
fi; | ||
ResumeMethodReordering(); |
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.
This change of indentation increases the diff needlessly... It seems the only actual changes was that a call to SuspendMethodReordering
was inserted?
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.
Oh and also ResumeMethodReordering
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.
Thanks, will fix.
lib/oper.g
Outdated
continue; | ||
fi; | ||
meths[base+n+3] := rank; | ||
if i = 1 or rank <= meths[base-3] 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.
Why -3? Wait, is that trying to access the previous method's entry? But that could break if BASE_SIZE_METHODS_OPER_ENTRY
changes again, no? It's also not immediately clear which "field" base-3
refers to. While this makes it clear: meths[base+n+3 - BASE_SIZE_METHODS_OPER_ENTRY]
(I'd still ad a comment to explain what's going on, though?)
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.
Will do
43a97b4
to
3565b1d
Compare
@@ -252,6 +252,7 @@ one can install also <E>immediate methods</E>. | |||
<Heading>Logical Implications</Heading> | |||
|
|||
<#Include Label="InstallTrueMethod"> | |||
<#Include Label="MethodReordering"> |
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.
Do we really want to make this publicly documented? Why?
lib/filter.g
Outdated
## | ||
#F SuspendMethodReordering() | ||
#F ResumeMethodReordering() | ||
#F ResetMethodReordering() |
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.
For consistency with other files, there should be two spaces after each #F
, and also ()
should be ( )
(but we'll survive w/o this changed, too ;-)
lib/filter.g
Outdated
## <Func Name="ResumeMethodReordering" Arg=""/> | ||
## <Func Name="ResetMethodReordering" Arg=""/> | ||
## | ||
## <Description> These functions control whether the method reordering process |
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.
Virtually every other GAPDoc comment in the library has <Description>
and </Description>
on their own lines. Just sayin'
lib/filter.g
Outdated
## described in <Ref Func="InstallTrueMethod"/> is invoked or not. Since this | ||
## process can be comparatively time-consuming, it is usually suspended when | ||
## a lot of implications are due to be installed, for instance when loading | ||
## the library, or a package. This is done by called <C>SuspendMethodReordering()</C> |
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.
called -> calling? Also, the recommend usage is that every reference to a function should use <Ref Func=...>
, even if it is inside the body of the documentation of the function itself.
lib/filter.g
Outdated
## | ||
## <C>ResetMethodReordering()</C> effectively exits all nested suspensions, resuming | ||
## reordering immediately. This function is mainly provided for error recovery and | ||
## similar purposes.</Description> |
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.
Indeed, what if there is an error duing package loading? That happens frequently for me if I try LoadAllPackages()
(because I have tons of non-distributed packages and development versions, with all kinds of conflicts). For options, we have the OnQuit
hook. Perhaps a call to ResetMethodReordering
should be added to OnQuit
, too? (Both in the GAP and in the HPC-GAP version).
## By default <C>InstallTrueMethod</C> adjusts the method selection data structures | ||
## to take care of this, but this process can be time-consuming, so functions | ||
## <Ref Func="SuspendMethodReordering"/> and <Ref Func="ResumeMethodReordering"/> | ||
## are provided to allow control of this process. |
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 think it's good to document this somewhere. But do we really want to document it for the public? I.e. perhaps move this out of the GAPDoc comment; or put it inside an XML comment?
lib/filter.g
Outdated
## </Description> | ||
## </ManSection> | ||
## <#/GAPDoc> | ||
## | ||
|
||
|
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.
Why insert these three empty lines?
lib/oper.g
Outdated
@@ -1922,6 +1917,96 @@ BIND_GLOBAL( "FLUSH_ALL_METHOD_CACHES", function() | |||
end); | |||
|
|||
fi; | |||
############################################################################# |
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.
Insert an empty line before this comment starts?
src/opers.c
Outdated
@@ -1946,6 +1946,9 @@ static ALWAYS_INLINE Obj GetMethodUncached( | |||
// entry n+3 is the rank | |||
// entry n+4 is the info text | |||
// entry n+5 is, if set, the location where the method was installed | |||
// entry n+6 is, if set, the relative rank that was supplied when | |||
// the method was installed, either as a small integer or a function | |||
// of no arguments |
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.
That's a somewhat odd wrapping (looking at the differing line lengths); also, could perhaps align at "if set"?
And perhaps should say: "a function of no arguments, which returns a small integer to be used as rank"?
This use of such a function as "base rank" should ideally be documented somewhere, too, no? And I guess we'd also have to go through the library to search for places where this should be used...
|
||
|
||
|
||
|
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.
You may need to remove these trailing empty lines, at least if/once this is rebased on master (as we added tests for "malformed" test files -- not sure if they accept trailing empty lines... perhaps they do, after all)
@fingolfin thanks for the review. I'll pick up the small things after I've fixed constructors and actually supported the function for the rank adjustment in InstallMethod (which I've just realised I need to do). If we're going to do this, I do think it should be documented publicly (although it doesn't need a huge song and dance) because there is a small but real risk of two things:
In either case I think it's better to be able to point people at documentation. |
b1e63c6
to
3c8b617
Compare
Subject to the tests, I think this is now complete. |
@stevelinton I fixed #2594 in PR #2604, so if approve and merge the latter, it should be possible to resume with this PR |
40ad33c
to
f12b1e1
Compare
The only test now failing is testpackages and that seems to be failing to loaf float, which loads OK for me on my laptop in this branch. Anyone know what's happening. |
We seen this in float before, I am sure it's not related to this PR:
I've restated it so see if this will stay - someone suggested that this may depend on underlying Travis CI setups, and does not happen each time. (Cf. #2391). |
f12b1e1
to
33c2729
Compare
I'm completely mystified by the test failure. float won't load because "atexit" is not defined, but (a) it's not actually mentioned anywhere in float that I can see and (b) it's a standard library function. I also don't see how the changes in this PR can possibly be related. |
This is a problem with float, or rather, the binutils/linker version installed on Travis. It affected many PRs and also master, hence we disabled float in the tests now. If you rebase on latest master, this should go away |
33c2729
to
0b34b4b
Compare
Adjust MethodsOperation to include base rank
…CALCULATE_ALL_METHOD_RANKS()
…or it being unset in RankFilter
0b34b4b
to
28d3d3f
Compare
@stevelinton any plans to rebase this (and perhaps squash some of the comments)? |
@stevelinton ping? |
Since I'd like to make some more changes in lib/oper.g, it would be good to finalize this. In order to make progress, I will push a cleaned up and rebased version of this PR as a fresh PR (if @stevelinton agrees, I can also later update this PR here instead, but for now, I don't want to modify his work w/o permission) |
See PR #2773 |
This is the start of an attempt to address #2513. At this stage it provides a function
RECALCULATE_ALL_METHOD_RANKS()
which does what it says. It is not called automatically. It still has a debugging printout when method ordering changes. It only seems to break one thing intestinstall