Haiku Grows Swap Support

News posted by bonefish on Fri, 2008-08-29 15:34
Thanks to Google Summer of Code student Zhao Shuai successfully finishing his project Haiku does now feature support for swapping. As of revision 27233 it is enabled by default, using a swap file twice the size of the accessible RAM. The swap file size can be changed (or swap support disabled) via the VirtualMemory preferences. Swap support finally allows building Haiku in Haiku on a box with less than about 800 MB RAM, as long as as the swap file is large enough. I tested this on a Core 2 Duo 2.2 GHz with 256 MB RAM (artificially limited) and a 1.5 GB swap file. Building a standard Haiku image with two jam jobs (jam -j2) took about 34 minutes. This isn't particularly fast, but Haiku is not well optimized yet. Haiku's swap implementation was heavily inspired by that of FreeBSD. At the moment it is not as sophisticated, but Zhao intends to borrow more of FreeBSD's optimizations.

Comments

Re: Haiku Grows Swap Support

Wohoo! Congrats, Zhao and Ingo!!!
Thanks a lot for your work, guys. It is highly appreciated!!!

Re: Haiku Grows Swap Support

Thank you Zhao Shuai and Ingo.
I hope we can see more from Zhao Shuai.

Now i Donate Haiku 30 USD ;-)

stargater

Re: Haiku Grows Swap Support

Nice piece of work Zhao, congrats !

Re: Haiku Grows Swap Support

Good to hear that swap support is available to Haiku but I would still say it best to avoid using it when the computer has enough RAM.

Those with DDR2 can upgrade RAM for very cheap. Unfortunately, those with SDRAM or DDR1 will pay lots to get more RAM and so are stuck using swap file ( to build Haiku ).

Those with 512+ MB should be fine for running Haiku + applications without swap.

I will have to try building Haiku with Haiku and see how it works. Your build time of 34 minutes was somewhat slow but this could also be because you were using swap - not entirely related to Haiku optimization. Try building Haiku with swap disabled, 1+ GB RAM and see if the build time improves. ( for comparison )

I would imagine that with 256MB you would have been hitting the swap file quite often and this would have lead to the long build time.

Re: Haiku Grows Swap Support

Actually, there's valid reasons to have swap even with plenty of ram. The reason being it allows the VM to be lazy about certain kinds of allocations/commitments. For instance in the case of jam during Haiku build, at peak it uses around 270MB and then forks. If you only have RAM, the VM must at that point commit an extra 270MB for the other process to guarantee that it's actually capable of running in the worst case scenario where it modifies every page (highly unlikely). If it had swap backing, it could be lazy about it, which would mean the pages only get committed when they actually change in the child process, and until that happens the extra mem is available for other apps/cache to use, even if swap is never actually needed/hit.

Re: Haiku Grows Swap Support

Nice work Zhao, thanks a lot!

Re: Haiku Grows Swap Support

Quote:

Your build time of 34 minutes was somewhat slow but this could also be because you were using swap - not entirely related to Haiku optimization. Try building Haiku with swap disabled, 1+ GB RAM and see if the build time improves. ( for comparison )

The only point WAS to test build time with swap. 34 minutes is bad, and it means the swap implementation needs further optimization...

Re: Haiku Grows Swap Support

Well, I dunno nuthin' bout building Haiku from within Haiku (I'd like to try it, but I still can't get Haiku to boot off the IDE drive, on QuadSlacker), but I noticed something even BETTER (to me). Copy time was down!

It was as high as 1:15 (1 min. 15 sec.), to copy a 512Mb folder (containing four 128Mb "haiku.image" files), but is now down to 45 sec.! And that seems to be a solid, consistent result. I don't understand why Haiku doesn't "know" the same folder is already in cache and just dumps it immediately from RAM to the disk, but... 45 sec. is very nice, in my book, regardless. Great work!!! Congratulations!

Since I only have 512Mb of RAM, I'm assuming trying to copy a 512Mb folder is going to mean Haiku has to use the swap space it now has, correct? Or does copying files operate differently than other functions?

Re: Haiku Grows Swap Support

Excellent news and congrats to Zhao Shuai. Thanks to your hard work, Haiku is just going to get better and better.

Re: Haiku Grows Swap Support

Thanks for the encouragement! But I think most honors should go to Ingo :-)

Re: Haiku Grows Swap Support

Nice Work! congratulations

Re: Haiku Grows Swap Support

谢谢你赵

Re: Haiku Grows Swap Support

Oh, Glad to see Chinese Characters.