Skip to content

Conversation

@fingolfin
Copy link
Member

This fixes a performance regression from GAP 4.15.0 and in some cases makes things actually faster than they were then.

The problem was that the preimages of the new nice monomorphism for rational matrix groups in GAP 4.15.0 was way too slow. It worked via a homomorphism to a free group, decomposed elements into words, etc. etc. -- but the inverse really is a homomorphism whose domain is a permutation group, and so we can use that to compute preimages much more quickly.

Fixes #6135

@fingolfin fingolfin requested a review from ThomasBreuer October 2, 2025 17:15
@fingolfin fingolfin added topic: performance bugs or enhancements related to performance (improvements or regressions) topic: library release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes backport-to-4.15 labels Oct 2, 2025
@fingolfin fingolfin marked this pull request as draft October 2, 2025 19:15
@fingolfin fingolfin force-pushed the mh/optimize-nice-mono-rat-mat-groups branch from f78c756 to 516ae73 Compare October 2, 2025 19:34

# evaluate relators
phi := IsomorphismFpGroupByGenerators(H, GeneratorsOfGroup( H ));
phi := IsomorphismFpGroupByGeneratorsNC(H, GeneratorsOfGroup( H ) : method := "fast");
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the major bottleneck of this function. Specifically, I was using the example from issue #6135, but taking the direct product with itself to make it more a bit more spicy:

v:=[ [ [ 1, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 1, 0 ], [ 0, 0, 0, 0, 0, 1 ] ], [ [ 1, 0, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 1, 0 ], [ 0, 0, 0, 0, 0, 1 ] ], [ [ 1, 0, 0, 0, 0, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 0, 1, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 1 ] ], [ [ 0, 0, 0, 0, -1, 0 ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ -1, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 1 ] ], [ [ 0, 0, 0, 0, 0, 1 ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 1, 0 ], [ 1, 0, 0, 0, 0, 0 ] ], [ [ 0, 0, 0, 0, 0, -1 ], [ 0, 1, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 0, 0 ], [ 0, 0, 0, 1, 0, 0 ], [ 0, 0, 0, 0, 1, 0 ], [ -1, 0, 0, 0, 0, 0 ] ] ];
W:=Group(v);
G:=DirectProduct(W,W);

Then IsomorphismFpGroupByGenerators in the code I am commenting on here it takes 3.5 seconds. With the fast option it's down to ~900 milliseconds.

Alas neither is particularly great, the "old" code pre-4.15 is still faster. (Of course there are other examples where the new code is way, WAY faster, otherwise I wouldn't have put it in).

I wonder if constructive recognition would help to do this better (the group in question has very small factors: just A6 and otherwise 2-groups

@fingolfin fingolfin changed the title Make various operations for rational matrix groups faster (fixes a performance regression from GAP 4.15.0 but also beats 4.14.0) Make various operations for rational matrix groups faster (fixes a performance regression from GAP 4.15.0) Oct 4, 2025
@fingolfin fingolfin marked this pull request as ready for review October 6, 2025 08:13
@fingolfin fingolfin force-pushed the mh/optimize-nice-mono-rat-mat-groups branch from 516ae73 to f018b28 Compare October 6, 2025 10:30
This fixes a performance regression from GAP 4.15.0 and in some
cases makes things actually faster than they were then.
@fingolfin fingolfin force-pushed the mh/optimize-nice-mono-rat-mat-groups branch from f018b28 to 9eec33b Compare October 6, 2025 20:06
## Group([ (1,2)(3,4), (1,3)(2,4) ]), Group(()),
## Group([ (), (1,2), (1,2)(3,4), (1,2,3), (1,2,3,4) ]) ]
## gap> List( Irr( S4 ), chi -> StructureDescription(CentreOfCharacter(chi)) );
## [ "S4", "1", "C2 x C2", "1", "S4" ]
Copy link
Member Author

Choose a reason for hiding this comment

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

@ThomasBreuer thoughts on this change and the one below? I mean, I can also adjust the generator sets once again but I feel this is whack-a-mole...

(Of course this one here is still susceptible to a change in the order of the irreducibles. I considered using Set but "1" occurs twice. Guess I could use Collected or `Sort but that makes it even more artificial...

Copy link
Contributor

Choose a reason for hiding this comment

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

The group is SymmetricGroup( 4 ), which uses the Irr method for symmetric groups, thus the order of the irreducibles should be stable. Showing the StructureDescription values is fine.

Copy link
Contributor

@ThomasBreuer ThomasBreuer left a comment

Choose a reason for hiding this comment

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

Looks good.

## Group([ (1,2)(3,4), (1,3)(2,4) ]), Group(()),
## Group([ (), (1,2), (1,2)(3,4), (1,2,3), (1,2,3,4) ]) ]
## gap> List( Irr( S4 ), chi -> StructureDescription(CentreOfCharacter(chi)) );
## [ "S4", "1", "C2 x C2", "1", "S4" ]
Copy link
Contributor

Choose a reason for hiding this comment

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

The group is SymmetricGroup( 4 ), which uses the Irr method for symmetric groups, thus the order of the irreducibles should be stable. Showing the StructureDescription values is fine.

@fingolfin fingolfin merged commit 9628fc7 into master Oct 10, 2025
32 checks passed
@fingolfin fingolfin deleted the mh/optimize-nice-mono-rat-mat-groups branch October 10, 2025 15:13
fingolfin added a commit that referenced this pull request Oct 12, 2025
…rformance regression from GAP 4.15.0) (#6138)

This fixes a performance regression from GAP 4.15.0 and in some
cases makes things actually faster than they were then.
@fingolfin
Copy link
Member Author

Backported to stable-4.15 in commit 47a73f6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-4.15-DONE release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: library topic: performance bugs or enhancements related to performance (improvements or regressions)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4.15 performance regression in group homomorphism construction

2 participants