Two pkgsrc work directory tips

Two tips for working with pkgsrc, derived in part from this mailing list post on users@ (follow the thread) and from my own experience.  If you put WRKOBJDIR=/usr/obj/pkgsrc into /usr/pkg/etc/mk.conf :

  1. You can clean up any leftover package building files by deleting the files in that directory and leave your pkgsrc files untouched.
  2. You can have a read-only /usr/pkgsrc, which means it can be shared over NFS (or SMB?) between multiple machines, DragonFly or otherwise.
Parallelized buildworld now possible

Buildworlds are now much faster, because they can run themselves in parallel.  Invoke it using the -j option to make.  Matthew Dillon saw a 25% reduction in time when using ‘make -j 12 buildworld’ on a 4-core system.  You may need to manually update xinstall and mkdir:

        cd /usr/src/usr.bin/xinstall
        make clean; make obj; make all install
        cd /usr/src/bin/mkdir
        make clean; make obj; make all install

It’ll also use more memory than a non-parallel build, but heck, that’s cheap these days.

An unexpected way to do strlen()

The general rule of thumb is that if you have a function written in an interpreted language (Perl, Python, etc.), it’ll be faster in C.  If you need it faster than that, you go to assembly.  Prepare to have your world rocked: Venkatesh Srinivas found that strlen() in libc was actually slower written in assembly than in C.  His commit message has numbers to back that up.

Video and USB fix

Matthew Dillon has written a contiguous memory mapper, which is designed to fix problems with video cards and USB drives that need a big chunk of memory to keep.  This can affect booting or later on, when disconnecting/reconnecting a USB drive.  If this still doesn’t fix the problem for you, try adjusting the sysctl ‘vm.dma_reserved’ to something bigger, like 64M.  It defaults to 16M.

(Normal mailarchive isn’t updating because of an ongoing upgrade to crater.dragonflybsd.org – sorry!)

What to do with /usr/obj

When building world and kernel on DragonFly, /usr/obj is where the work files get placed.  This can eat a bit of space, but it can be safely deleted.  If you keep the files around, subsequent rebuilds can be done faster with a quickwork/quickkernel, but this may not matter to you.

(This was answered on the mailing lists by Max Herrgaard, but I don’t have a link to his reply – sorry!)