Hacker News new | ask | show | jobs
by gridspy 4115 days ago
Performance thought:

I like the way you raytrace the entire image at once. Clever, but you might be able to make it faster...

Right now you process the entire image in one hit. However a 1080p * 4 byte image is 777,600 bytes - from a quick read I believe you have several of these. They're large enough to blow the caches in your CPU.

It might be much faster to break the image into 8,16 or 32 square or rectangular or line shaped "patches" and process each in sequence. That would help you hit the same parts of your working arrays more often and keep them in cache between iterations.

I'm thinking

    for patch in patches
       for iter in iterations <-- currently your outer rendering loop
Might be a quick performance win worth playing with.

Hit me up at tom at gridspy (.co.nz) if you want to discuss further.

Amazing article, thankyou!

1 comments

I don't get something. Isn't 1080p a 1920x1080 image, which would make it 2073600px * 4 bytes = 8294400 bytes = 7.91 megabytes?