Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Sep 2019 16:53:16 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        cem@freebsd.org
Cc:        "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Subject:   Re: What value HZ?
Message-ID:  <16539c09c4b65c2f5d239e78d88e9d9985ba588b.camel@freebsd.org>
In-Reply-To: <CAG6CVpU8732Ci0QM7=tBn0ifHf8yO-53FBtvBCF34StBDTCx-A@mail.gmail.com>
References:  <201909060119.x861JWrG006910@repo.freebsd.org> <4917d7507b6ea6c360dccda261f53052aa085f2b.camel@freebsd.org> <5EE266EE-E650-48D8-9B0E-E674AD026470@freebsd.org> <3cb6429acc7e520932d2c906d1cac47540156355.camel@freebsd.org> <8F03EA29-0F3F-4321-9241-78F7C924FDE1@freebsd.org> <CANCZdfr6pz19NCLmsua6iGzusotrcHN=u47RH7Y1PdM4rnomZA@mail.gmail.com> <9BC03B61-F8B5-476C-AD34-9DEA5230BFCF@freebsd.org> <CANCZdfqbp%2BU3=0EM2n3bhg4DwXd_PVjvEYjGyQhkE5-MK-3-QA@mail.gmail.com> <CAPKkNb4ETFzD7pXi3=iDUxtSxZSffxFB5q9ZtmsJy2FUuaZB5A@mail.gmail.com> <CAG6CVpU8732Ci0QM7=tBn0ifHf8yO-53FBtvBCF34StBDTCx-A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 2019-09-07 at 18:58 -0700, Conrad Meyer wrote:
> Hi Constantine,
> 
> On Sat, Sep 7, 2019 at 3:05 PM Constantine A. Murenin
> <cnst++@freebsd.org> wrote:
> > 
> > For the sake of discussion, I recall that there was a measurable power
> > consumption difference between FreeBSD (HZ=1000) and OpenBSD (HZ=100) when
> > I played with a Kill-A-Watt a number of years ago.
> 
> Unfortunately, this is an apples to oranges comparison, and perhaps
> worse, vague and dated.  It would be more interesting to compare
> HZ=1000 to HZ=100 with an otherwise identical CURRENT FreeBSD system.
> 
> As far as I can tell, FreeBSD grew "tickless" timer support in r212541
> in 2010 (thanks mav@).  This is easily observed on my idle HZ=1000
> amd64 system with 'vmstat -i': "cpu0:timer" is firing at an average
> rate of 21 Hz — not 1000.  And that is the most frequent interrupt.
> 
> > Would it perhaps be prudent to try to qualify whether, and by how much,
> > this change affects power consumption on MIPS/ARM/RISCV, not just whether
> > each arch could cope with the change?
> 
> If someone has the time and inclination, then of course, it could be
> an interesting test to run.

In this mail, when I say HZ, I mean also 'hz' the global var that's
tunable...

When I saw this conversation moved to arch@ my first thought was "Good,
we can finally have the conversation I've been trying to have with
people for years."  But, alas, the focus even here is still just "100
vs 1000", not the base question I really want to see answered.  I'm
replying to this message in the thread because it comes closest to
touching on that base question, which is:

   What, exactly, does HZ control and affect these days?

It no longer controls how often periodic timer interrupts happen,
except on a few rare systems that don't support one-shot style event
timers.  I'm not sure any such systems even still exist, now that we've
nuked most of the old armv4 support.  If they do exist, I'm pretty sure
it's only in the MIPS arch.

It no longer controls the scheduling quantum for a process or thread. 
Or so I've been told, I'm pretty ignorant about the workings of both
schedulers.

It no longer controls the minimum amount of time a userland process can
sleep when calling the usleep() or nanosleep() functions.

The one thing I know for sure that HZ affects is whatever code still
exists that schedules timeouts in terms of 'ticks' rather than using
the newer SBT flavor of sleeping functions.  Old-school pause(9) and
msleep(9) and others that take a timeout in 'ticks' will have the
timeout granularity implied by HZ, and there is still such code around
in various device drivers and other places.

Aside from old-school tick-based sleep functions, does HZ do anything
anymore?

-- Ian




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16539c09c4b65c2f5d239e78d88e9d9985ba588b.camel>