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

Workaround slow compile times for big StaticArray #9486

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

j8r
Copy link
Contributor

@j8r j8r commented Jun 15, 2020

Fixes #2485.

I didn't add details on the commit message, having no knowledge of what is causing this slow compile times in the background with LLVM - be free to edit it if somebody wants.

@jhass jhass changed the title Fix slow compile times for big StaticArray Workaround slow compile times for big StaticArray Jun 15, 2020
src/static_array.cr Outdated Show resolved Hide resolved
src/static_array.cr Outdated Show resolved Hide resolved
@j8r j8r force-pushed the fix-StaticArray-slow-compile-times branch from ee16b5c to 0e971dd Compare June 16, 2020 16:21
@waj
Copy link
Member

waj commented Jun 19, 2020

Please, don't merge this yet (#2485 (comment))

@waj
Copy link
Member

waj commented Jun 19, 2020

This should be now superseded by #9510 (if specs passes 🤞 😄 )

@j8r
Copy link
Contributor Author

j8r commented Jun 19, 2020

Closing in favor of #9510, which also reduces the compile time.

@j8r j8r closed this Jun 19, 2020
@j8r j8r deleted the fix-StaticArray-slow-compile-times branch June 19, 2020 17:01
@j8r j8r restored the fix-StaticArray-slow-compile-times branch June 19, 2020 21:32
@j8r j8r reopened this Jun 19, 2020
@j8r
Copy link
Contributor Author

j8r commented Jul 29, 2020

I think it can be fine to have this simple fix for now, before a true codegen fix (eventually by @waj ?) will be ready.
There is no downsides, and the changes are minimal.

@waj
Copy link
Member

waj commented Jul 29, 2020

I'm sorry @j8r but I still don't think it's a good idea. This is basically always unrolling the contents of the block. It might look harmless for small examples but the block could be any piece of code. Whatever the block is, the codegen will be writing LLVM code for it N times.

@j8r
Copy link
Contributor Author

j8r commented Jul 29, 2020

Ok, but block are always inlined, so is there really a difference at the end?

@waj
Copy link
Member

waj commented Jul 29, 2020

Block calls are inlined but the code from the block is only generated as many times yield is called. LLVM might decide later to unroll loops, effectively repeating the code, but that probably depends on the number of iterations and the size of the block.

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.

code with static arrays is very very slow to compile with the --release flag
5 participants