Mar 11

pkg_add is a FreeBSD tool for installing packages, much like Linux’s apt-get and other tools. When you run it you can use the -r option to fetch a package, for example:

 pkg_add -v -r zip

When you do this, you’ll see it going off to download from one of the main FreeBSD servers, which can often be far away from you and a lot slower. If you’d like to download locally set the PACKAGEROOT environment variable to the server you’d like to use. For example:

export PACKAGEROOT=ftp://ftp.za.freebsd.org

“za” is the country code for South Africa. Most countries have local mirrors, and there are lists online. For example, “uk” or “au” would be for the UK or Australia.

Mar 10
em Driver Debug
icon1 admin | icon2 FreeBSD, Networking | icon4 03 10th, 2008| icon3No Comments »

If you’ve used FreeBSD chances are you’ve used the em driver (for Intel gigabit network cards). Debugging packet loss and link errors can be difficult, so here’s a handy tip for those of you using the driver –

Using sysctl, you can get “debug” information off of your cards.  Execute “sysctl hw.em0.stats=1” and “sysctl hw.em0.debug_info=1” each time you want the information to be logged to /var/log/messages (or dmesg). You can replace “em0″ with whichever network card you want, for a quick list of what seems to be available you can run “sysctl -a hw.”

Here’s what you can expect to see –

/kernel: em0: Adapter hardware address = 0xc62931e0
/kernel: em0:CTRL  = 0×3c0249
/kernel: em0:RCTL  = 0×0 PS=(0×8402)
/kernel: em0:tx_int_delay = 0, tx_abs_int_delay = 0
/kernel: em0:rx_int_delay = 0, rx_abs_int_delay = 0
/kernel: em0: fifo workaround = 0, fifo_reset = 0
/kernel: em0: hw tdh = 0, hw tdt = 0
/kernel: em0: Num Tx descriptors avail = 0
/kernel: em0: Tx Descriptors not avail1 = 0
/kernel: em0: Tx Descriptors not avail2 = 0
/kernel: em0: Std mbuf failed = 0
/kernel: em0: Std mbuf cluster failed = 0
/kernel: em0: Driver dropped packets = 0
/kernel: em0: Excessive collisions = 0
/kernel: em0: Symbol errors = 0
/kernel: em0: Sequence errors = 0
/kernel: em0: Defer count = 0
/kernel: em0: Missed Packets = 0
/kernel: em0: Receive No Buffers = 0
/kernel: em0: Receive length errors = 0
/kernel: em0: Receive errors = 0
/kernel: em0: Crc errors = 0
/kernel: em0: Alignment errors = 0
/kernel: em0: Carrier extension errors = 0
/kernel: em0: XON Rcvd = 0
/kernel: em0: XON Xmtd = 0
/kernel: em0: XOFF Rcvd = 0
/kernel: em0: XOFF Xmtd = 0
/kernel: em0: Good Packets Rcvd = 0
/kernel: em0: Good Packets Xmtd = 0

Mar 10

FreeBSD

FreeBSD has long been plagued by less-than-best SMP performance, especially in versions 4 and 5. Slashdot is reporting FreeBSD 7.0 SMP performs much better, and is ahead of Linux.

“After major improvements in SMP support in FreeBSD 7.0, benchmarks show it performing 15% better than the latest Linux kernels (PDF, see slides 17 to 19) on 8 CPUs under PostgreSQL and MySQL. While a couple of benchmarks are not conclusive evidence, it can be assumed that FreeBSD will once again be a serious performance contender. Some posters on LWN have noted that the level of Linux performance could be related to the Completely Fair Scheduler, which was merged into the 2.6.23 Linux kernel.”

There has since been an update trying to prove that Linux is faster –

Update: 03/06 21:32 GMT by KD : An anonymous reader sent in word that Linux kernel developer Nick Piggin reran the benchmark today and came to a different conclusion: In his benchmark Linux was faster than FreeBSD.

But whoever the winner, the performance is clearly much, much better than before.