Hacker News new | ask | show | jobs
by loeg 2783 days ago
On modern FreeBSD, when I run the article's demo program, by default I see even higher and more variable latency than the author observed in 2004:

    0.017686
    0.031868
    0.055889
    0.008931
    0.014824
However, when I set the kern.timecounter.alloweddeviation sysctl ("Allowed time interval deviation in percents") to 0 (from the default of 5%), I get very low and consistently low latency:

    0.000036
    0.000031
    0.000030
    0.000037
    0.000036
    0.000040
There are pros and cons to both defaults.
1 comments

Can you elaborate on the cons?
Sure thing.

Why make wakeup imprecise by default? The slop allows for some coalescing of nearby (in time) events into a single wakeup, saving power[0]. This article provides some figures that give a good intuition for why this might work: https://arstechnica.com/gadgets/2013/06/how-os-x-mavericks-w...

See also: tickless kernels in general[1]; FreeBSD switched to a tickless kernel with coalescing about 5.5 years ago[2].

[0]: https://en.wikipedia.org/wiki/Timer_coalescing

[1]: https://en.wikipedia.org/wiki/Tickless_kernel

[2]: https://svnweb.freebsd.org/base?view=revision&revision=24777...

Yes it's true. This kernel has no tick.
"Well, that's what I heard!"
I agree that this can be beneficial, but do any BSDs support any laptop hardware as easily or as well as Linux does? Even assuming that hardware support is there, does the battery life even compare well to Linux on the same hardware, let alone Windows 10?

If one of the best kept secrets of open source is that some BSD somewhere has great hardware support and battery life better than Windows and Linux... that would be awesome!

To answer the broad question, yes, some BSDs (FreeBSD) support some laptop hardware[0] as well as Linux does. And yes, the battery life is comparable. FreeBSD has good support for idling in C-states, which is where most of your CPU power saving comes from; support for setting and managing P-states (which no longer have much impact on modern Intel CPUs, but mattered historically) via e.g., "powerd;" and support for wifi power saving modes and screen dimming (other big power draws).

The question that was sort of implied but not directly asked might be: if you pick a random laptop, do I think it's likely a BSD will support it better than Linux? And there I think the honest answer is "no." Linux definitely has an advantage in breadth of driver coverage.

In many ways FreeBSD is a well-kept "secret," but it's not a panacea.

[0]: https://wiki.freebsd.org/Laptops

From what I've heard about other systems, if the system is given some wiggle room in when it runs tasks, then it can often run multiple tasks in a single wakeup, instead of waking up for one task, doing it, going to sleep for a very short time, waking up to do the second, etc. Wakeups, from what I've heard, carry overhead and increase power consumption, which may matter. (Also, if the CPUs are normally fully busy with user programs instead of fully asleep with zero tasks, replace "wakeup" with "context switch into the kernel".)

I don't know if this is what loeg had in mind, and I have not investigated the subject myself.

This is exactly the right idea.