-
Notifications
You must be signed in to change notification settings - Fork 46
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
Reduce Memory Usage #626
Reduce Memory Usage #626
Conversation
MAXVERTS > 512 now supported!! :) And I got some test results
|
@james-d-mitchell is there any chance you're able to link me to the configuration for the "coverage" check run on azure? It's failing with a weird error that I can't reproduce locally, and I'd like to know exactly what config the system is using so I can debug I had a look in the .github/workflows folder but couldn't see any thing useful |
0074499
to
63dc0ab
Compare
Also rebased this onto main and force pushed, this should fix the ci. |
It did, thanks! Ignoring the coverage test this looks good to go |
Thanks @DanielPointon I think we can ignore the code coverage, unless you can see some places to add tests that test some lines that aren't tested, if you can, them please do, if not, then forget about it |
@DanielPointon I started reviewing this but realised that there are a few issues, and so I fixed compile warnings in digraphs in general in #633, and hoped you could rebase your PR on top of those. |
63dc0ab
to
15da166
Compare
Lol, 17 merge conflicts. I've rebased :) Will look at fixing compile warnings now |
@james-d-mitchell I think I've fixed all the compile warnings I caused, apologies if there's anything egregious I missed, the VIP is my first time writing C :) |
Unfortunately, the changes in this PR appear to leak memory, here's the output of valgrind: Thanks to @Joseph-Edwards for running valgrind. I will fix this. |
Ah, sorry! I've made a quick push to fix a few of the errors: DanielPointon@45c928a I can revert if it gets in the way of your debugging |
This is the valgrind output with those changes: |
@Joseph-Edwards thanks! @james-d-mitchell if you're okay to hold off until Monday I think I can fix this up over the weekend and save you some time. |
@james-d-mitchell all memory leaks now fixed, essentially the issue was that some structures have a 'size' parameter associated with them which is continuously updated, but the size of underlying structures doesn't always match this, which the free functions assumed. I've also rebased on main and added the functions to manually free cliques and homomorphism data. |
Awesome thanks @DanielPointon and @Joseph-Edwards ! |
Unfortunately, it seems like there are still memory leaks when testing |
Fixed! Sorry about that. C is hard. |
@DanielPointon no need to apologise! I took the liberty of Valgrinding |
c84469b
to
1b7f890
Compare
I just rebased this (and squashed it) on to the current main branch, this was more or less difficult, and so might contain some mistakes! |
With the changes in this PR, I'm seeing an approx.
This was tested after I commented out the lines:
in With the
I'll need to investigate a bit further to see why this might be the case. I'm more or less happy to accept a small loss of performance with these changes, ~~but I'm not sure that I'd class ~27% as small. ~~ UPDATE: I added an addition test at the end of |
8c5d978
to
42f9b41
Compare
@Joseph-Edwards any chance you can run this through valgrind again? I think I might have inadvertently force pushed and deleted some of Daniel's fixes :( |
@james-d-mitchell will the new Valgrind action suffice? If no, I'll happily run it again. I also think I have a local copy of the old branch. If that'd be helpful to see, I can push it to my fork |
Thanks @Joseph-Edwards, if you could push the old branch to your fork that'd be awesome! Also the new valgrind action would be just fine, where is that exactly? |
69ed72f
to
fdbcd06
Compare
Pushed to https://github.com/Joseph-Edwards/Digraphs And hopefully you should be able to see the Valgrind action in the actions tab. It should be callable somehow, but I'm not sure how off the top of my head. |
fdbcd06
to
4dcc904
Compare
Thanks @Joseph-Edwards I figured out how to call the valgrind job, and thanks for the push too! |
This commit combines all the changes by @DanielPointon, with a few cleanups by me on top. The aim of this commit it to make the memory allocation more dynamic in the kernel extension of Digraphs for computing homomorphisms and cliques. Namely, instead of allocating memory for a bunch of fixed sized (512) arrays we only allocate the memory required to perform any requested computations, and we reuse that if possible for subsequent computations, and only allocate more memory if there isn't enough allocated previously. This commit also exposes two functions DIGRAPHS_FREE_* that can be used to release the allocated memory for computing homomorphisms or cliques. There might be a small performance penalty for these changes, for example, with these changes: gap> Test("~/digraphs/tst/extreme/cliques.tst"); Digraphs package: standard/cliques.tst msecs: 2848 true gap> Test("~/digraphs/tst/extreme/cliques.tst"); Digraphs package: standard/cliques.tst msecs: 2923 true gap> Test("~/digraphs/tst/extreme/grahom.tst"); Digraphs package: extreme/grahom.tst msecs: 65177 true gap> Test("~/digraphs/tst/extreme/grahom.tst"); Digraphs package: extreme/grahom.tst msecs: 65956 true and before: gap> Test("~/digraphs/tst/extreme/cliques.tst"); Digraphs package: standard/cliques.tst msecs: 2861 true gap> Test("~/digraphs/tst/extreme/cliques.tst"); Digraphs package: standard/cliques.tst msecs: 2928 true gap> Test("~/digraphs/tst/extreme/grahom.tst"); Digraphs package: extreme/grahom.tst msecs: 64881 true gap> Test("~/digraphs/tst/extreme/grahom.tst"); Digraphs package: extreme/grahom.tst msecs: 64997 true
4dcc904
to
4ce7831
Compare
Contains the following:
Dynamic memory allocation and deallocation for Homomorphism
Dynamic memory allocation and deallocation for Cliques
Subtle bug fix for Bliss Graphs when N > 512/3 (see the old allocation of BLISS_GRAPH[i] vs the new in homos.c)
Support for Digraph homomorphism with N>512
Support for Bitarray operations with N > 512
Support for flexible bitarray lookup sizes
Logic for memory allocation is as follows:
Max(Vertices(Digraph1), Vertices(Digraph2))
orVertices(Digraph1)
, depending on the operation taking placeMax(Vertices(Digraph1), Vertices(Digraph2)) > current size
orVertices(Digraph1) > current size
, increase the current size of the structures, free and re-reallocate them.Logic for bitarrays: