9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Anthony Martin <ality@pbrane.org>
To: 9front@9front.org
Subject: Re: [9front] Understanding milli-CPUs (/dev/sysstat)
Date: Sun, 9 Jan 2022 00:14:30 -0800	[thread overview]
Message-ID: <YdqZZo+6iCYR7fQ9@alice> (raw)
In-Reply-To: <87k0fbzimt.fsf@turtle-trading.net>

Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net> once said:
> > I wrote a daily script which sends me an email via a cron job. The
> > mail contains this load value from /dev/sysstat.
>
> I see that this device is described in cons(3).  I do not see from that
> documentation what time span sysstat uses.  It seems that you need to
> write to the file to reset it and than read from it after some time.
> But it also says that the vale is "decayed over time" which sounds like
> some kind of moving average.  It does not say (unless I missed it), how
> fast this decay is (i.e. again over which time span).

/sys/src/9/port/proc.c:/^accounttime

	/* only one processor gets to compute system load averages */
	if(m->machno != 0)
		return;

	/*
	 * calculate decaying load average.
	 * if we decay by (n-1)/n then it takes
	 * n clock ticks to go from load L to .36 L once
	 * things quiet down.  it takes about 5 n clock
	 * ticks to go to zero.  so using HZ means this is
	 * approximately the load over the last second,
	 * with a tail lasting about 5 seconds.
	 */
	n = nrun;
	nrun = 0;
	n = (nrdy+n)*1000*100;
	load = ((uvlong)load*(HZ-1)+n)/HZ;
	m->load = load/100;

Nrdy is the total number of procs in the scheduler queues.
Nrun is the number of procs running on each mach (cpu).

The multiplication and accompanying division by 100 is there
to handle precision problems with high values of HZ (the clock
tick frequency).

Cheers,
  Anthony

  reply	other threads:[~2022-01-09 10:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07 12:01 sirjofri
2022-01-07 15:10 ` Benjamin Riefenstahl
2022-01-09  8:14   ` Anthony Martin [this message]
2022-01-09 12:36     ` Benjamin Riefenstahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YdqZZo+6iCYR7fQ9@alice \
    --to=ality@pbrane.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).