<FromGitter>
<Blacksmoke16> wouldnt be automatic tho
Liothen has joined #crystal-lang
repo1 is now known as repo
<FromGitter>
<asterite> @mattrberry so cool that the FPS went from 40 to 100. I'll try to make the compiler be smarter about constants...
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 258 seconds]
<oprypin>
😍
<oprypin>
curious to see if it will be about value types or just literals
<FromGitter>
<asterite> It's about everything :-)
<FromGitter>
<asterite> Essentially: when we are in the codegen phase, whenever we read a constant I'll mark it as "read". If we reach the place where the constant is declare and it wasn't yet read, we can assign that constant's value right there, and accessing it is always reading it. The usual behavior for constants otherwise is to have them be lazily initialized, so reading it always performs a check to see if it was initialized
<FromGitter>
... or not
<FromGitter>
<asterite> That goes against modular compilation, but since we don't have that anyway, there's no harm in improving the current situation... who knows when or whether we'll have modular compilation
<FromGitter>
<asterite> I think they are all the same time, it's just that 1.5ns is too small so if a fly passes by my computer or I cough it can already change :-P
<FromGitter>
<asterite> Trying out the const changes double the FPS in crab (well, from 30 to 60). I guess the author also made a bunch of other optimizations
<yxhuvud>
asterite: do you need to keep track of the difference between constants that are modified over time (say an array of stuff where the contents get modified) and stuff that are immutable? Or would that be another optimization?
<yxhuvud>
really impressive change though :)
<yxhuvud>
do you know what triggers the regression of the non-constant values?
<yxhuvud>
or is that just random noise?
<FromGitter>
<asterite> constant is actually "assigned just once" in crystal
<FromGitter>
<asterite> this change doesn't relate to having a mutable array as a constant
<FromGitter>
<asterite> so this optimization also applies for mutable arrays assigned to a constant
asterite_ has joined #crystal-lang
lanodan_ has joined #crystal-lang
lanodan has quit [Ping timeout: 244 seconds]
asterite has quit [Ping timeout: 244 seconds]
asterite_ is now known as asterite
Andriamanitra has quit [Ping timeout: 244 seconds]
zorp has quit [Ping timeout: 240 seconds]
lanodan_ is now known as lanodan
<FromGitter>
<mattrberry> @asterite That looks really promising!! I did make a number of other optimizations, but the biggest one for me was just inlining the constants. Iirc that’s what brought me from 40->100. Switching to just checking bits instead of casing over ranges bumped me up another 30 or so, and exchanging the stdlib Deque for a much simpler fifo queue got me another ~20
<FromGitter>
<mattrberry> Unfortunately I won’t be at my pc until tomorrow night to look more into it, but I’d be really curious if those changes affect CryBoy’s performance at all. I doubt it’d be as significant, but it’d still be interesting to see!
<FromGitter>
<mattrberry> And thank you for looking into that, truly awesome to have your insight on this and have these things addressed in the compiler directly (:
<FromGitter>
<christopherzimmerman> @asterite I feel like I’ve asked about this before but can’t find the convo, but is there a reason that calling map on a tuple always returns a union type?