Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> (Spoilers: it also allocates 60+ GB of RAM for intermediate results, so consider reducing the image size before running it on your own machine)

The input algorithm is essentially written in SSA form, and it's easy to analyze when each "register" stops being used; then you can drop the arrays after their last use. Turns out the number of live registers never exceeds 160 at any point in time, and with this one addition the max memory usage drops to barely above 1GB.



I don't know why you are downvoted (at the time of this writing). That's a very good point and makes the simple Python solution feasible on many more computers (due to reduced memory footprint). It's also a straightforward pass (once you know what liveness analysis is). Since there are no loops it's just one pass starting from the end and working backwards to determine whether a variable is live or not, and then an extra check on each iteration to decide whether to delete particular arrays.


I think getting downvoted (not by me) because if you scroll to the end of the post, that's the very first submission (by me).


Ah, fair. I didn't catch that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: