-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Compiler: initialize right-away constants in a separate function #10334
Conversation
Here's what I get:
For the last one, here's the version it showed
|
@jwoertink Thanks! What's that ld warning? Is that a problem? First time I see it. |
Oh, and here's that benchmark with those 3 versions:
|
@asterite I've never seen that ld warning before. It only seems to happen when I compile from this PR. I ran |
It's also very strange that the error mentions a directory with Crystal 0.34.0 in it |
@jwoertink thank you for trying these! Of course you can also use a compiler from this PR with whatever program was slow to compile for you, and see if it's fixed. |
It is
I definitely don't have 0.34 on here 😂 |
Sweet! I ran the Lucky specs using this PR, and it
|
If you pass -s I think it tells you which macro runs were compiled |
Ah, yup.
Not a huge deal I guess. 1min is WAY better than the 14min I was seeing 😂 |
Let's wait for someone else to see if they also get those warnings. |
I checked before/after this PR against llvm@10 and bc+obj when from 27s to 7s. The released 0.36.0 tar.gz llvm@6 is even 12s. I'm happy with this. I'm not sure if @mattrberry can verify this before 0.36.1, that would be awesome. |
@jwoertink what does |
Maybe I have something left over from a while ago? |
Yes, it seems that you probably have a |
I don't think mattrberry has ever compiled the compiler before, but I'm pretty sure it will work fine and fast |
I've built the compiler on a few occasions, including when I tested your changes to the constants prior to 0.36.0. I'm happy to try again in a few hours. CryBoy appears to fail compilation on 0.36.0 still due to some later changes that went into 0.36.0, so I still need to work those out. I'll update this thread this evening when I get a chance to look into it a little further |
Testing on CryBoy: Compiler versions tested:
For each of these versions, I tested 3 ROMs 3 times. Across all of those runs, both 0.36.0 and this branch seemed to have similar performance, both of which improved fps over 0.35.1 by 20-25% depending on the rom. In terms of performance that I've noticed, this branch seems to be identical or close enough to identical to 0.36.0. If this improves upon the compilation speed of 0.36.0, I think this is a win-win :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test-alpine are failing sporadically. I did some runs localle to validate. This is GTG 🚀
Fixes the slowness in the compiler.
Alternative to #10330
The idea is to still eagerly initialize the constants that can be initialized like that, but do that in a separate function. It seems like that LLVM has an easier time optimizing things.
The code for doing that was already there in the compiler: it's used for all other constants, but doing that in a wrapper that makes sure they are only initialized once.
Does it really work, and is it really fast?
Please help me try it out. Here's what you can do:
crystal build src/ecr/process.cr --release -s
with the existing 0.36.0 compiler, or by compiling a compiler from master. Check how long the "bc+obj|" phase takes. For me this takes about 30 seconds.bin/crystal build src/ecr/process.cr --release -s
. It should be faster. For me this takes about 8 seconds.Then with a compiler built from this PR make sure this benchmark is still fast.
You can also compare the times with a 0.35.1 compiler. For me that "bc+obj" phase takes about 6 seconds, not 8. I think LLVM 11 is a bit slower in this aspect.