From nobody Tue Oct 15 08:41:35 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XSSJB6pmJz5Yb3h for ; Tue, 15 Oct 2024 08:41:46 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Received: from www121.sakura.ne.jp (www121.sakura.ne.jp [153.125.133.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4XSSJB1pYrz49KL for ; Tue, 15 Oct 2024 08:41:45 +0000 (UTC) (envelope-from junchoon@dec.sakura.ne.jp) Authentication-Results: mx1.freebsd.org; none Received: from kalamity.joker.local (123-1-21-232.area1b.commufa.jp [123.1.21.232]) (authenticated bits=0) by www121.sakura.ne.jp (8.17.1/8.17.1/[SAKURA-WEB]/20201212) with ESMTPA id 49F8fZj9098667; Tue, 15 Oct 2024 17:41:36 +0900 (JST) (envelope-from junchoon@dec.sakura.ne.jp) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dec.sakura.ne.jp; s=s2405; t=1728981696; bh=l6Md6B0kgQBhau5WuD5+9pLbSQcC7A7V3T6yoS7mv2s=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=H0/+3x8qCjL4ms1PHpSeOJNWvjdNUAKrsaxpxpWWkpcCq1Dlz+zXCPFRk3izWkBVv WcA01NwjT2TKCuLaXq0jAuq16Yaz51pALixcv7V+9bjY3p/lEjUKe8+RhsiX+HyX1j H92hMRnuzdArjKSevpvvXBzi1TsgquoZqppGr0xs= Date: Tue, 15 Oct 2024 17:41:35 +0900 From: Tomoaki AOKI To: void Cc: freebsd-hackers@freebsd.org Subject: Re: polling interval Message-Id: <20241015174135.14866b319a49ddafeca6e3bb@dec.sakura.ne.jp> In-Reply-To: References: <20241015000117.8a731ab66a1af876879f5ca8@dec.sakura.ne.jp> <9513c9d9-8f7c-4842-a535-b387082e4e3e@sentex.net> Organization: Junchoon corps X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd14.1) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:7684, ipnet:153.125.128.0/18, country:JP] X-Rspamd-Queue-Id: 4XSSJB1pYrz49KL X-Spamd-Bar: ---- On Tue, 15 Oct 2024 01:03:26 +0100 void wrote: > On Mon, Oct 14, 2024 at 03:32:52PM -0400, mike tancsa wrote: > > >Did adjusting it make any difference ? > > I set it to maximum, rebooted but the vm wouldnt come up > fully lol, so made another one. kern.hz dedines how frequently the forced task (process) switch happens. The fewer the value is, the faster the process runs (lower overhead) with the cost of lower responsiveness. OTOH, the higher kern.hz is, the more chance to responding for user interaction, with the cost of total performance loss (higher overhead). These are because how much instructions could be run on single tick (process/context switching) is affected with this. And this also affects kernel, not only userland. And of course, affected by IPC and clock freq of CPU cores and memory (including caches) bandwidth, too. This means, setting too high value causes kernel to not finishing needed-finishing-in-1-tick operations. Maybe your vm kernel thread would be in this state. > I'm going to try adjusting it in small increments to see if i can get the > virtio-net performance on freebsd guests to be as quick or nearly as quick as > linux ones in bhyve. > -- This tunable is defined as SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &hz, 0, "Number of clock ticks per second"); SYSCTL_INT(_kern, OID_AUTO, hz_max, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, HZ_MAXIMUM, "Maximum hz value supported"); SYSCTL_INT(_kern, OID_AUTO, hz_min, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, HZ_MINIMUM, "Minimum hz value supported"); in sys/kern/subr_param.c with related definitions and includes. In this file, HZ is dedaulted as 1000 if not defined in other place or make command line. Initially variable hz is set to -1, fetch for tunable kern.hz, if none, hz = vm_guest > VM_GUEST_NO ? HZ_VM : HZ; is applied. IIRC, in ancient days, default kern_hz (HZ) was 100 and bumped to 1000 (current default) at some point. So trying around 10000 or 5000 and if not satisfactory, try increasing or decreasing would be nice for recent amd64 hardwares. (It depends, though.) FYI, I'm configuring kern.hz=4096 in /boot/loader.conf. Lost where I've seen, but recommended by somewhere. -- Tomoaki AOKI