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

LieAlgebras: reduce allocations #4165

Merged
merged 9 commits into from
Oct 2, 2024

Conversation

lgoettgens
Copy link
Member

@lgoettgens lgoettgens commented Sep 30, 2024

some representative workload comparisons between 4a5b96d (two days old master) and this PR branch

  ___   ____   ____    _    ____
 / _ \ / ___| / ___|  / \  |  _ \   |  Combining ANTIC, GAP, Polymake, Singular
| | | |\___ \| |     / _ \ | |_) |  |  Type "?Oscar" for more information
| |_| | ___) | |___ / ___ \|  _ <   |  Manual: https://docs.oscar-system.org
 \___/ |____/ \____/_/   \_\_| \_\  |  1.2.0-DEV #master 4a5b96d 2024-09-28
 \___/ |____/ \____/_/   \_\_| \_\  |  1.2.0-DEV #lg/Lie-allocs ed5c5dd 2024-09-30
 
julia> using BenchmarkTools

julia> @btime basis($(special_linear_lie_algebra(QQ, 7)));
  79.304 μs (2497 allocations: 134.00 KiB)	# master
  7.550 μs (193 allocations: 42.50 KiB)		# this PR

julia> @btime root_system([(:D, 12), (:E, 6)]);
  7.043 ms (314018 allocations: 5.89 MiB)	# master
  3.032 ms (47004 allocations: 2.53 MiB)	# this PR

julia> @btime lie_algebra(QQ, $(Oscar.LieAlgebras._struct_consts(QQ, root_system(:F, 4), fill(true, 20))), check=true); # this is heavily used in testing
  6.746 s (88755679 allocations: 3.65 GiB)	# master
  37.229 ms (1103389 allocations: 37.98 MiB)	# this PR

julia> @btime lie_algebra(QQ, $(root_system(:B, 10)));
  60.045 ms (1213748 allocations: 66.03 MiB)	# master
  47.319 ms (623167 allocations: 40.60 MiB)	# this PR

julia> @btime Oscar.LieAlgebras._cartan_subalgebra($(special_linear_lie_algebra(QQ, 7))); # internal function to circumvent caching
  3.072 s (9245963 allocations: 1.41 GiB)	# master
  386.819 ms (1110135 allocations: 217.34 MiB)  # this PR

julia> @btime Oscar.LieAlgebras._root_system_and_chevalley_basis($(special_linear_lie_algebra(QQ, 7))); # internal function to circumvent caching
  3.137 s (11603843 allocations: 1.73 GiB)	# master
  884.441 ms (2280864 allocations: 451.74 MiB) 	# this PR

the release of Nemocas/Nemo.jl#1872 will reduce allocations in some cases even further

@lgoettgens lgoettgens added optimization Simpler/more performant code or more/better tests topic: LieAlgebras experimental Only changes experimental parts of the code labels Sep 30, 2024
Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 98.39572% with 3 lines in your changes missing coverage. Please review.

Project coverage is 84.71%. Comparing base (4a5b96d) to head (f1b177d).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
experimental/LieAlgebras/src/LinearLieAlgebra.jl 87.50% 1 Missing ⚠️
experimental/LieAlgebras/src/Types.jl 91.66% 1 Missing ⚠️
experimental/LieAlgebras/test/RootSystem-test.jl 98.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4165      +/-   ##
==========================================
+ Coverage   84.69%   84.71%   +0.01%     
==========================================
  Files         628      628              
  Lines       84449    84608     +159     
==========================================
+ Hits        71527    71674     +147     
- Misses      12922    12934      +12     
Files with missing lines Coverage Δ
experimental/LieAlgebras/src/AbstractLieAlgebra.jl 98.91% <100.00%> (-0.01%) ⬇️
experimental/LieAlgebras/src/LieAlgebra.jl 89.29% <100.00%> (+0.21%) ⬆️
experimental/LieAlgebras/src/LieAlgebraIdeal.jl 43.75% <100.00%> (ø)
experimental/LieAlgebras/src/LieAlgebraModule.jl 90.70% <100.00%> (+0.03%) ⬆️
experimental/LieAlgebras/src/LieAlgebras.jl 100.00% <ø> (ø)
experimental/LieAlgebras/src/LieSubalgebra.jl 58.71% <100.00%> (ø)
experimental/LieAlgebras/src/RootSystem.jl 92.47% <100.00%> (+2.18%) ⬆️
experimental/LieAlgebras/src/Util.jl 100.00% <100.00%> (ø)
...rimental/LieAlgebras/test/LinearLieAlgebra-test.jl 100.00% <ø> (ø)
experimental/LieAlgebras/src/LinearLieAlgebra.jl 95.97% <87.50%> (+0.11%) ⬆️
... and 2 more

... and 4 files with indirect coverage changes

@lgoettgens
Copy link
Member Author

According to the CI logs, this reduces time/allocations of the relevant tests as follows (on ubuntu-1.10, compared to https://github.com/oscar-system/Oscar.jl/actions/runs/11118011606):

  • experimental/LieAlgebras/test/AbstractLieAlgebra-test.jl: 84.75s, 45.8GB => 22.72s => 8.4GB
  • experimental/LieAlgebras/test/LieAlgebra-test.jl 14.96s, 4.4GB => 4.7s => 1.4GB
  • experimental/LieAlgebras/test/LieAlgebraModule-test.jl 30.43s, 12.5GB => 23.76s, 11.6GB

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Nice

@lgoettgens lgoettgens merged commit 3862e78 into oscar-system:master Oct 2, 2024
24 of 25 checks passed
@lgoettgens lgoettgens deleted the lg/Lie-allocs branch October 2, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental Only changes experimental parts of the code optimization Simpler/more performant code or more/better tests topic: LieAlgebras
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants