Twinside / Rasterific

A drawing engine in Haskell
BSD 3-Clause "New" or "Revised" License
140 stars 11 forks source link

Restructuring the code (Refactoring) #34

Open stephano33 opened 6 years ago

stephano33 commented 6 years ago

I love the library! I did an interesting demo that got quite some positive feedback. Will publish that.

The demo showed the performance problems and also that a 1 line change can make the library 22% faster. Now I look for more performance gains. However, there is one problem with the library that hinders the readability.

Rasterific does 4 different things:

For me this is bad for readability and also from the standpoint of separation of concerns. I am probably going to rewrite a version of the library for myself to change that.

Minor things are copy/past code or code redundancy but this is a small detail.

Twinside commented 6 years ago

Hi, I'd like to see the code for the performance improvement, especially if it's just one line :].

I'm aware of a low hanging fruit on optimization for the 64 bit version of GHC, as some types used during rendering are tuned for 32bits, there is some quick win to do on memory usage.

For the "readability" bit, I don't know where you're going to, so I'll refrain to comment.

stephano33 commented 6 years ago

Hi,

Yes, I will give you the one line. But need to check again if it improves only my code or all code. Did you see the video of my snowflake benchmark? The video on Youtube?

If you give me a bit of feedback, I can make the speed improvements quicker.

type Container a = DList a One question is, why did you use dynamic lists? Was it more because it was easy? Or is it good to have lazy evaluation for speed? Would a Vector be better for speed?

After that I also have another question on how to improve the edge sorting in sortEdgeSamples.

stephano33 commented 6 years ago

The one line improvement is truing on strict evaluation on the modulate that allocates most; for instance, -X Strict on Rasterize.hs can help. But as you see, this is just a trick to know that there is some problem with perhaps lazy evaluation. This is not a fix.

The next big step is where to do the changes so that the edges are sorted in parallel. Where would you do that change?