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

Reorder methods after new implications are added #2521

Closed
wants to merge 12 commits into from

Conversation

stevelinton
Copy link
Contributor

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 in testinstall

@stevelinton stevelinton added kind: bug Issues describing general bugs, and PRs fixing them do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) kind: discussion discussions, questions, requests for comments, and so on labels Jun 6, 2018
@codecov
Copy link

codecov bot commented Jun 7, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@64f4323). Click here to learn what that means.
The diff coverage is 94.46%.

@@            Coverage Diff            @@
##             master    #2521   +/-   ##
=========================================
  Coverage          ?   75.42%           
=========================================
  Files             ?      478           
  Lines             ?   241759           
  Branches          ?        0           
=========================================
  Hits              ?   182343           
  Misses            ?    59416           
  Partials          ?        0
Impacted Files Coverage Δ
src/opers.c 94% <ø> (ø)
lib/init.g 71.76% <ø> (ø)
lib/error.g 38.2% <0%> (ø)
src/hpc/c_type1.c 82.76% <100%> (ø)
src/c_type1.c 83.41% <100%> (ø)
lib/package.gi 69.82% <33.33%> (ø)
lib/filter.g 92.85% <83.33%> (ø)
lib/oper.g 82.23% <92.47%> (ø)
src/hpc/c_oper1.c 87.11% <98.91%> (ø)
src/c_oper1.c 88.31% <99.14%> (ø)

lib/oper1.g Outdated
ranknow := rank();
else
ranknow := rank;
fi;
Copy link
Member

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?

@stevelinton
Copy link
Contributor Author

So the problem (or at least the first one) turns out to be for IsomorphismPermGroup where the method for permutation groups overtakes the method for finite nilpotent groups. I'm not sure why exactly this causes the computation to fail, and that is almost certainly a bug that needs fixing.

@stevelinton
Copy link
Contributor Author

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

@olexandr-konovalov olexandr-konovalov added the gapdays2018-spring Issues and PRs that arose at http://www.gapdays.de/gap-jupyter-days2018 label Jun 8, 2018
@stevelinton stevelinton force-pushed the reorder-filters branch 4 times, most recently from d6d0d66 to ae15f65 Compare June 13, 2018 13:09
@stevelinton
Copy link
Contributor Author

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:

  • when the library and its needed/recomended packages are loaded and before reading files from the command-line
  • after loading a package (except that LOAD_ALL_PACKAGES only does it once at the end)
  • any other time when the implications caches are being refreshed

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.

@fingolfin
Copy link
Member

Tests fail: first off, make docomp needs to be run in HPC-GAP, too (it has its own set of c_*.c files). Secondly, testspecial is broken, because those tests "see" all those debug outputs.

lib/package.gi Outdated
else
List( RecNames( GAPInfo.PackagesInfo ), LoadPackage );
fi;
ResumeMethodReordering();
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and also ResumeMethodReordering

Copy link
Contributor Author

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
Copy link
Member

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?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@stevelinton stevelinton force-pushed the reorder-filters branch 2 times, most recently from 43a97b4 to 3565b1d Compare June 15, 2018 11:44
@@ -252,6 +252,7 @@ one can install also <E>immediate methods</E>.
<Heading>Logical Implications</Heading>

<#Include Label="InstallTrueMethod">
<#Include Label="MethodReordering">
Copy link
Member

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()
Copy link
Member

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
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

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.
Copy link
Member

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>
##


Copy link
Member

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;
#############################################################################
Copy link
Member

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
Copy link
Member

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...





Copy link
Member

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)

@stevelinton
Copy link
Contributor Author

@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:

  1. Package code or future library development installs implications which change the ranking of existing library methods causing surprises
  2. Some package (homalg -- I'm looking at you) turns out to install lots of implications at "run time" after package loading and suddenly gets a lot slower.

In either case I think it's better to be able to point people at documentation.

@stevelinton stevelinton force-pushed the reorder-filters branch 2 times, most recently from b1e63c6 to 3c8b617 Compare June 28, 2018 15:41
@stevelinton stevelinton removed the do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) label Jun 28, 2018
@stevelinton
Copy link
Contributor Author

Subject to the tests, I think this is now complete.

@fingolfin
Copy link
Member

@stevelinton I fixed #2594 in PR #2604, so if approve and merge the latter, it should be possible to resume with this PR

@stevelinton stevelinton force-pushed the reorder-filters branch 3 times, most recently from 40ad33c to f12b1e1 Compare July 24, 2018 13:35
@stevelinton
Copy link
Contributor Author

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.

@olexandr-konovalov
Copy link
Member

olexandr-konovalov commented Jul 24, 2018

We seen this in float before, I am sure it's not related to this PR:

Loading float ... 
#W dlopen() error: /home/travis/build/gap-system/gap/pkg/float-0.9.1/bin/x86_6\
4-pc-linux-gnu-default64/float.so: undefined symbol: atexit
Error, module '/home/travis/build/gap-system/gap/pkg/float-0.9.1/bin/x86_64-pc-linux-\
gnu-default64/float.so' not found in
  if not LOAD_DYN( arg[1], false ) then
    Error( "no support for dynamic loading" );
fi; at /home/travis/build/gap-system/gap/lib/files.gd:583 called from 

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).

@stevelinton
Copy link
Contributor Author

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.

@fingolfin
Copy link
Member

fingolfin commented Aug 1, 2018

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

@fingolfin
Copy link
Member

@stevelinton any plans to rebase this (and perhaps squash some of the comments)?

@fingolfin
Copy link
Member

@stevelinton ping?

@fingolfin
Copy link
Member

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)

@fingolfin
Copy link
Member

See PR #2773

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gapdays2018-spring Issues and PRs that arose at http://www.gapdays.de/gap-jupyter-days2018 kind: bug Issues describing general bugs, and PRs fixing them kind: discussion discussions, questions, requests for comments, and so on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants