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

blocks: split macro into multiple functions, fast! #267

Merged
merged 1 commit into from
Jan 10, 2020

Conversation

iceiix
Copy link
Owner

@iceiix iceiix commented Jan 10, 2020

Improves fix for #184, whereas #255 reduced optimizations,
we now address the underlying compiler limitation and split out
the one massive lazy_static! initialization function, into
one function per block in the block_registration_functions module.

Previous build time, with opt-level=1:

% time cargo build --release
Compiling steven_blocks v0.0.1
Finished release [optimized] target(s) in 21.24s
cargo build --release 31.80s user 0.71s system 152% cpu 21.276 total

With this change, opt-level=3 and the function splitting fix:

% time cargo build --release
Compiling steven_blocks v0.0.1
Finished release [optimized] target(s) in 30.80s
cargo build --release 40.26s user 0.86s system 133% cpu 30.850 total

Full optimizations are expectedly slightly slower, but this is still
much much much faster than before this refactoring, where this crate
would take up to an unbelievable 5 hours (and tens of GB of RAM). Long
story short, we're now back to full optimizations and stable Rust.

Improves fix for #184, whereas #255 reduced optimizations,
we now address the underlying compiler limitation and split out
the one massive lazy_static! initialization function, into
one function per block in the block_registration_functions module.

Previous build time, with opt-level=1:

% time cargo build --release
   Compiling steven_blocks v0.0.1
    Finished release [optimized] target(s) in 21.24s
cargo build --release  31.80s user 0.71s system 152% cpu 21.276 total

With this change, opt-level=3 and the function splitting fix:

% time cargo build --release
   Compiling steven_blocks v0.0.1
    Finished release [optimized] target(s) in 30.80s
cargo build --release  40.26s user 0.86s system 133% cpu 30.850 total

Full optimizations are expectedly slightly slower, but this is still
much much _much_ faster than before this refactoring, where this crate
would take up to an unbelievable 5 hours (and tens of GB of RAM). Long
story short, we're now back to full optimizations and stable Rust.
@iceiix
Copy link
Owner Author

iceiix commented Jan 10, 2020

@iceiix iceiix merged commit 87e0726 into master Jan 10, 2020
@iceiix iceiix deleted the blocks_macros_fast branch January 10, 2020 04:08
@iceiix
Copy link
Owner Author

iceiix commented Jan 10, 2020

@woodgear If you are still interested in building this project, I believe this pull request should address the out of memory errors you were seeing compiling steven_blocks on Windows (#184), finally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant