1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using a ramdisk for faster port compiling

Discussion in 'Installation and Maintenance of Ports or Packages' started by ring_zero, Apr 26, 2012.

  1. ring_zero

    ring_zero New Member

    Messages:
    67
    Thanks Received:
    21
    Has anyone tried using a ramdisk for optimized/faster compilation of ports? I added eight GB of RAM to this machine rather whimsically, (it's so cheap now), and am trying to come up with different ways of using it. I liked the idea of a ramdisk to speed up compilation, but I have no idea where to mount it.
     
  2. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,515
    Thanks Received:
    2,351
    Mount it anywhere you like and set WRKDIRPREFIX. See ports(7) what it does.
     
    ring_zero thanks for this.
  3. kpa

    kpa Well-Known Member

    Messages:
    4,080
    Thanks Received:
    803
    Mount it somewhere under /var, for example /var/ports/tmp and set the work directory for ports in /etc/make.conf like this:

    Code:
    WRKDIRPREFIX=/var/ports/tmp
    
     
    ring_zero thanks for this.
  4. ring_zero

    ring_zero New Member

    Messages:
    67
    Thanks Received:
    21
    Works rather well. Thanks.
     
  5. cabriofahrer

    cabriofahrer New Member

    Messages:
    76
    Thanks Received:
    1
    Sounds interesting, but I don't understand why with the above given path in /var the work directory is moved into RAM? What am I missing?
     
  6. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,515
    Thanks Received:
    2,351
    /var/ports/tmp/ is the mountpoint where the RAM disk is mounted on. But it's just an example. You can mount it anywhere you like as long as WRKDIRPREFIX points to it.
     
  7. DutchDaemon

    DutchDaemon Administrator Staff Member Administrator Moderator

    Messages:
    10,721
    Thanks Received:
    2,137
    I'll give you one local example:

    /etc/fstab
    Code:
    tmpfs			/staging	tmpfs	rw		0	0
    


    /etc/make.conf
    Code:
    WRKDIRPREFIX=/staging


    That's all you need.

    df -h
    Code:
    tmpfs           9.9G    4.0k    9.9G     0%    /staging
    


    ls -ld /staging
    Code:
    drwxr-xr-x  3 root  wheel  40 Jun 15 12:19 /staging


    Just ran make on a test port with some dependencies to show what happens:

    $ find /staging -type d
    Code:
    /staging
    /staging/usr
    /staging/usr/ports
    /staging/usr/ports/misc
    /staging/usr/ports/misc/unclutter
    /staging/usr/ports/misc/unclutter/work
    /staging/usr/ports/misc/unclutter/work/unclutter
    /staging/usr/ports/devel
    /staging/usr/ports/devel/imake
    /staging/usr/ports/devel/imake/work
    /staging/usr/ports/devel/imake/work/imake-1.0.4
    /staging/usr/ports/devel/imake/work/imake-1.0.4/.deps
    /staging/usr/ports/devel/gccmakedep
    /staging/usr/ports/devel/gccmakedep/work
    /staging/usr/ports/devel/gccmakedep/work/gccmakedep-1.0.2
    /staging/usr/ports/devel/makedepend
    /staging/usr/ports/devel/makedepend/work
    /staging/usr/ports/devel/makedepend/work/makedepend-1.0.3
    /staging/usr/ports/devel/makedepend/work/makedepend-1.0.3/tests
    /staging/usr/ports/devel/makedepend/work/makedepend-1.0.3/tests/28045
    /staging/usr/ports/devel/makedepend/work/makedepend-1.0.3/.deps
    /staging/usr/ports/x11
    /staging/usr/ports/x11/xorg-cf-files
    /staging/usr/ports/x11/xorg-cf-files/work
    /staging/usr/ports/x11/xorg-cf-files/work/xorg-cf-files-1.0.4
    
     
  8. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,512
    Thanks Received:
    2,213
    Time a big port compile both from RAM and off disk. Reboot before each to clear filesystem cache. With buildworld, I found essentially zero difference putting /usr/obj in a tmpfs.
     
  9. DutchDaemon

    DutchDaemon Administrator Staff Member Administrator Moderator

    Messages:
    10,721
    Thanks Received:
    2,137
  10. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,512
    Thanks Received:
    2,213
    That's an interesting point. Certainly those multiple builds of LibreOffice didn't do mine any good.
     
  11. DutchDaemon

    DutchDaemon Administrator Staff Member Administrator Moderator

    Messages:
    10,721
    Thanks Received:
    2,137
    In fact, all of my caches (browsers, etc.) are on a tmpfs as well.
     
  12. sim

    sim New Member

    Messages:
    157
    Thanks Received:
    5
    This is a somewhat tangential observation/question...

    Running ZFS with 8GB (total) RAM, I note that even on heavy builds (world etc), the HD light only pulses very briefly and occasionally - e.g. one single short flash every few seconds. (I can't remember what it used to be like when I used to run UFS). So, assuming there's a decent caching infrastructure in place, like ZFS's L2ARC, is there something to be said for letting the system use memory as it sees fit? Is there much to be gained by manually specifying a RAM disc these days?

    sim