-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix ooms #92
Conversation
This change is... problematic. It's great for tail recursive things, but now a lot of our tests that operate on trees OOM. |
Probably, we should categorize redexes into 'shrinking' and 'growing', and process shrinking ones first? |
@tjjfvi I agree, a pair of stacks is the right way to do this. Any usecase that's solved by having a queue will be solved by having a shrinking redex stack and a growing redex stack. This is because some of the elements at the front of the queue will be shrinking, and other ones will be growing (having a queue works because there are enough shrinking redexes to keep |
@tjjfvi Let me preface this by saying I needed to gut out the builtins out of hvm-lang to be able to use this PR's commit The sequential program indeed now works for eg. 2^29 and so on, but the parallel one now takes much longer, and doesn't use the CPU cores nearly as well as before.
I guess correct and slow > incorrect and fast, but yeah maybe this approach needs some tweaking :) Here's the parallel program for reference Main n = (Sum (PowOfTwo n))
PowOfTwo n = (PowOfTwoHelp 1 n)
PowOfTwoHelp acc 0 = acc
PowOfTwoHelp acc e = (* 2 (PowOfTwoHelp acc (- e 1)))
Sum 0 = 0
Sum 1 = 1
Sum n =
let half1 = (/ n 2);
let half2 = (- n half1);
(+ (Sum half1) (Sum half2)) |
d19a52a
to
de3d1fc
Compare
@Janiczek can you test again? |
That one works much better! The parallel program now utilizes all cores to the max as expected. The memory usage in all the program runs seems to be stable around 1840 MB, rising slightly (eg. stopping around 1860 MB) as time goes on. So maybe some forgotten frees are still there, but much less prominent.
|
fd7c820
to
3e1ca16
Compare
This comment has been minimized.
This comment has been minimized.
…ate extra memory to prevent some OOMs.
This comment has been minimized.
This comment has been minimized.
ooh, perf wins across the board, love to see it |
Perf run for
|
Fixes #91
half_free
I can now run the program in #91 with 1G of memory for 2^28, and with only 1K of memory when single-threaded.
@Janiczek can you confirm this fixes it for you?