4 ms·
Optimizing Haskell for performance can be tricky. When I wrote a functional image library (updated at [0]) I tried to get the frame draw rate down by using stri
by siraben 6y ago
Optimizing Haskell for performance can be tricky. When I wrote a functional image library (updated at [0]) I tried to get the frame draw rate down by using strictness, unpacked records, and so on, but one of the changes that made the biggest difference came from changing round to truncate[1], I went from 120 ms/frame to 65 ms/frame! The reason why is because round has quite a bit of logic associated with it[2] in Haskell's standard library, versus a simple one-liner for truncate.
It sort of shows that in even simple functions such as this, underlying implementation details can have an impact on performance.
Also, for some reason filling a C array in Haskell was faster than doing it in C, probably due to the switching between RTS.
[0] https://github.com/siraben/functional-images https://github.com/siraben/functional-images
[1] https://github.com/sbond75/OpenGLTesting/commit/116384edd6a36d7cb828310fcc8bfbf6327cc47d https://github.com/sbond75/OpenGLTesting/commit/116384edd6a3...
[2] https://hackage.haskell.org/package/base-4.14.0.0/docs/src/GHC.Real.html#truncate https://hackage.haskell.org/package/base-4.14.0.0/docs/src/G...
- ooobit2 6y agoI just watched a video on branchless programming, and it blew my mind that the guy got a 3.36s function to return in .48s by using more code. The idea of trying to outsmart a compiler or runtime is motivating me to pick back up coding after 8 years away.
- siraben 6y agoDo you have a link to that video?
- tangjurine 6y agohttps://youtu.be/bVJ-mWWL7cE https://youtu.be/bVJ-mWWL7cE Just googled branchless programming :)
- omniscient_oce 6y agoI love this guy's channel it's awesome.
- nickpeterson 6y agoI think it’s a sign our chipsets and tooling have become too complicated. We’re at this weird point where both sides are trying to guess what the other one is doing.
- mhh__ 6y agoThe Mill (seems to be chugging along if any one is looking for an update) is an interesting take on the problem. If you're not familiar its a (in development) exposed pipeline (static scheduling) VLIW ISA - not unheard of in DSP land but genuinely alien compared to a CISC scalar processor a la X86 or ARM. I'm not particularly optimistic about their chances of making into the shops but they haven't failed yet.
- zozbot234 6y ago> seems to be chugging along if any one is looking for an update Cite? I've been looking for recent updates and haven't found any.
- deleted 6y ago[deleted]