High Memory Usage while compiling astra bin #62

Closed
opened 2025-06-02 07:13:05 +00:00 by waseem-riaz-sndk · 4 comments
waseem-riaz-sndk commented 2025-06-02 07:13:05 +00:00 (Migrated from github.com)

I'm not sure if this is astra specific issue (because of type-level programming? Have not checked the repo) or is an issue at all but when cargo reaches the end to compile astra's binary, its memory usage steadily climbs to around 1 GB.

Image

This is on windows, on release build. I have not tested on linux.
Note: This is not the case on debug build

I'm not sure if this is astra specific issue (because of type-level programming? Have not checked the repo) or is an issue at all but when cargo reaches the end to compile astra's binary, its memory usage steadily climbs to around 1 GB. ![Image](https://github.com/user-attachments/assets/0f390f0d-fb9c-4986-9109-bcb2d5fa3608) This is on windows, on release build. I have not tested on linux. Note: This is not the case on debug build
ElhamAryanpur commented 2025-06-02 09:43:12 +00:00 (Migrated from github.com)

This is not Astra issue but it is to be expected. The release builds focus on highest possible optimizations, which hinders speed and memory usage but results in an amazing output that is incredibly performant.

Some things that can help, in case you're using Rust in general and do not want high memory usage, may be looking into sccache and mold. You can also modify Astra's Cargo.toml and remove this section from it and compiling again:

[profile.release]
opt-level = 3
lto = true
codegen-units = 1
overflow-checks = false
debug = 0
[profile.release.package."*"]
opt-level = 3
codegen-units = 1
This is not Astra issue but it is to be expected. The release builds focus on highest possible optimizations, which hinders speed and memory usage but results in an amazing output that is incredibly performant. Some things that can help, in case you're using Rust in general and do not want high memory usage, may be looking into sccache and mold. You can also modify Astra's Cargo.toml and remove this section from it and compiling again: ```toml [profile.release] opt-level = 3 lto = true codegen-units = 1 overflow-checks = false debug = 0 [profile.release.package."*"] opt-level = 3 codegen-units = 1 ```
waseem-riaz-sndk commented 2025-06-03 05:47:02 +00:00 (Migrated from github.com)

Thanks for the quick response. Makes sense. Have you checked how much performance you gain from this? I also noticed a decrease of 10% in binary size for this release profile compared to the regular release build.

Thanks for the quick response. Makes sense. Have you checked how much performance you gain from this? I also noticed a decrease of 10% in binary size for this release profile compared to the regular release build.
ElhamAryanpur commented 2025-06-03 12:53:51 +00:00 (Migrated from github.com)

I have not benchmarked the performance gains compared to a normal release build, but I am sure of the higher performance due to some things this maximum optimized profile has, that you can read here: https://doc.rust-lang.org/cargo/reference/profiles.html

Essentially it is able to run some constant codes at compile time to save on performance, better overall linking ability, dead code elimination, ...

I have not benchmarked the performance gains compared to a normal release build, but I am sure of the higher performance due to some things this maximum optimized profile has, that you can read here: https://doc.rust-lang.org/cargo/reference/profiles.html Essentially it is able to run some constant codes at compile time to save on performance, better overall linking ability, dead code elimination, ...
ElhamAryanpur commented 2025-06-06 09:34:50 +00:00 (Migrated from github.com)

closing due to not being an issue and hopefully resolved

closing due to not being an issue and hopefully resolved
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ArkForgeLabs/Astra#62
No description provided.