Skip to content

Memory optimization of pruning pass #1001

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

Merged
merged 2 commits into from
Mar 24, 2022
Merged

Memory optimization of pruning pass #1001

merged 2 commits into from
Mar 24, 2022

Conversation

rdragos
Copy link
Contributor

@rdragos rdragos commented Mar 24, 2022

Closes #967.

@rdragos
Copy link
Contributor Author

rdragos commented Mar 24, 2022

Stats for the pruning pass, i.e. running

elk compile lowering.moose pruning.moose -p prune

Before (ca7a4dd)

calls to allocation functions: 248494957 (1131306/s)
temporary memory allocations: 43746471 (199161/s)
peak heap memory consumption: 5.18G
peak RSS (including heaptrack overhead): 5.47G
total memory leaked: 173.74K

After:

calls to allocation functions: 225867598 (1153698/s)
temporary memory allocations: 45630111 (233071/s)
peak heap memory consumption: 4.05G
peak RSS (including heaptrack overhead): 3.55G
total memory leaked: 173.74K

In release mode:

before (ca7a4dd)

/usr/bin/time ./target/release/elk compile lowering.moose pruning.moose -p prune 
17.50user 4.95system 0:11.72elapsed 191%CPU
 /usr/bin/time ./target/release/elk compile lowering.moose pruning.moose -p prune
17.89user 4.96system 0:12.07elapsed 189%CPU
/usr/bin/time ./target/release/elk compile lowering.moose pruning.moose -p prune
17.69user 4.87system 0:11.80elapsed 191%CPU

after:

/usr/bin/time ./target/release/elk compile lowering.moose pruning.moose -p prune
15.68user 4.38system 0:09.49elapsed 211%CPU
/usr/bin/time ./target/release/elk compile lowering.moose pruning.moose -p prune
15.06user 4.55system 0:09.07elapsed 216%CPU
/usr/bin/time ./target/release/elk compile lowering.moose pruning.moose -p prune
15.34user 4.59system 0:09.38elapsed 212%CPU

Copy link
Member

@mortendahl mortendahl left a comment

Choose a reason for hiding this comment

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

🚀

// Construct a new computation. NB: we did not toposort it.
Ok(Computation { operations: keep })
let mut iter = keep.iter();
// only keep the operations that were visited by DFS
Copy link
Member

Choose a reason for hiding this comment

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

nit: add comment that this works before retain is promising to visit elements in their original order?

@mortendahl mortendahl changed the title Prune mem opt Memory optimization of pruning pass Mar 24, 2022
@mortendahl mortendahl merged commit 86139ea into main Mar 24, 2022
@mortendahl mortendahl deleted the dragos/pruning-opt branch March 24, 2022 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elk memory: avoid operation cloning in prune_graph
2 participants