From nobody Wed Mar 22 20:15:57 2023 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 4Phfqj5y7Vz41FtT for ; Wed, 22 Mar 2023 20:16:01 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Phfqj5JbPz4KsR; Wed, 22 Mar 2023 20:16:01 +0000 (UTC) (envelope-from se@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679516161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CPym4lty5Rf/eaah1bf0Quez3DZd0p/hLzv8wedekNI=; b=akXTPHo5ivLvp1pyo+lgUsr1MdSsOMRhPUovASNDitxTE6jZ9L4HVBwlEEI73tOgNjcZhs Tu9L2gdrOzYmy0Fth3c/g2Bt9PLuk2BylsNgEFh8zp0BBNGkTfomfyvOCyialrka4R5e/b lhD8K8Dc1M7pU/UzqEjpt9xmfxhybitAW19+5a6Lr27na8GElKOL+cHXEZJJL1Wlj00jnE SB4O7VGNNC1zUSLfGEJDcdv+JAag2FVeAJxaBDdL8AyowRn7Y4otdhzVvH7n2PsRR4rGm8 2BxhiYUdh1XXYY0Ii+e/k8ssmoTD4TMfA+SJJzIvAFPMpc9H8iWjaltXxzLv7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679516161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CPym4lty5Rf/eaah1bf0Quez3DZd0p/hLzv8wedekNI=; b=ccGLtWIJGUGwel/PbRAbatggaW3SH8kUuwYeEXCVO0u9+bNIlhDvpyObPK7VZ9bRr6pnK6 n41LMacTDHhtvapA7t0ZkqqcHZWqUBAf/rTuGh4hoe8qgO1ut3Rpgp+4q9M2/orkTgRJeS pjQRYSPc7mPXt7RQPNyk/t3vBATg4s0mMAkwDUVEcA6rDT6lcWCNPEj/yvaCsV+Cp6Ycs2 5vPF2PEXwcffBjdTx6zjPMSxHYomxNmsElKyWq67eau+2LzFnhBr3vCE8JLFPYHROSNxfa 9Jl5VXgrWmSSR7auNQUbUdQSAohdFj6kw004SOhWC2q13R0P1H73gwW7xKXtLw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679516161; a=rsa-sha256; cv=none; b=fR/DExP00hVvzCiatkSrkfcPX6IgPjQdUYgol02xghO7uy5TsAMk3u+oDqb7tErMstqc+2 XtGedmITs8xvDHgCyOyEB3zBxy+HTHv34D2bEu8KM07Mxne7iBdnRB2wbJbzWir3qE1JsB krrxuSVgi+DFv7UcLp9LIxN8kPZkV3S0eBOTftSZSmPw09z8dEi6KyHfzSan8e3WdJE06o Z7pTP0+CjcCdKaH3TCxVIHIiGx/2+/4EunovjdiwaUah0UgxA7g9deVrUvXvYSQ4YBxgXf ti7vWvH8dV7I2nbyaGGi0DrEQwjX4AGhIDxE93qW1kurc0UzQ5YBqT3ga6P3eg== Received: from [IPV6:2003:cd:5f1a:a300:a5cf:f0a3:530e:bda] (p200300cd5f1aa300a5cff0a3530e0bda.dip0.t-ipconnect.de [IPv6:2003:cd:5f1a:a300:a5cf:f0a3:530e:bda]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Phfqj0SZCzFWN; Wed, 22 Mar 2023 20:16:00 +0000 (UTC) (envelope-from se@FreeBSD.org) Message-ID: <7f26102c-7542-78f8-0c7b-ef3cdaa1a4a6@FreeBSD.org> Date: Wed, 22 Mar 2023 21:15:57 +0100 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 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 From: Stefan Esser Subject: Re: Periodic rant about SCHED_ULE Content-Language: de-DE, en-US To: Mateusz Guzik , sgk@troutmask.apl.washington.edu Cc: freebsd-hackers@freebsd.org References: <8173cc7e-e934-dd5c-312a-1dfa886941aa@FreeBSD.org> <8cfdb951-9b1f-ecd3-2291-7a528e1b042c@m5p.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N Am 22.03.23 um 20:23 schrieb Mateusz Guzik: > I wrote a cpu burning program (memset 1 MB in a loop, with enough > iterations to take ~20 seconds on its own). > > I booted an 8 core bhyve vm, where I made sure to cpuset is to 8 distinct cores. > > The test runs *9* workers, here is a sample run: > > 4bsd: > 23.18 real 20.81 user 0.00 sys > 23.26 real 20.81 user 0.00 sys > 23.30 real 20.81 user 0.00 sys > 23.34 real 20.82 user 0.00 sys > 23.41 real 20.81 user 0.00 sys > 23.41 real 20.80 user 0.00 sys > 23.42 real 20.80 user 0.00 sys > 23.53 real 20.81 user 0.00 sys > 23.60 real 20.80 user 0.00 sys > 187.31s user 0.02s system 793% cpu 23.606 total > > ule: > 20.67 real 20.04 user 0.00 sys > 20.97 real 20.00 user 0.00 sys > 21.45 real 20.29 user 0.00 sys > 21.51 real 20.22 user 0.00 sys > 22.77 real 20.04 user 0.00 sys > 22.78 real 20.26 user 0.00 sys > 23.42 real 20.04 user 0.00 sys > 24.07 real 20.30 user 0.00 sys > 24.46 real 20.16 user 0.00 sys > 181.41s user 0.07s system 741% cpu 24.465 total > > It reliably uses 187s user time on 4BSD and 181s on ULE. At the same > time it also reliably has massive time imblance between > fastest/slowest in terms of total real time between workers *and* ULE > reliably uses more total real time to finish the entire thing. The problem is that user time depends on the number of CPU cycles, but real time on "when" the CPU is executing the last few cycles of the respective process. And in the case of a parallel program like the test program, where each thread takes the same number of cycles, but the thread with the highest real time determines the total real time taken (the other cores are idle for the last 0.3 to 3.8 seconds or 2 seconds on average, while real times with 4BSD are quite similar). > iow this is a tradeoff, but most likely a bad one Better balancing of the load would probably make ULE take less real time. The example of 9 identical tasks on 8 cores with 7 tasks getting 100% of a core and the other 2 sharing a core and getting 50% each could be resolved by moving a CPU bound process from the CPU with the highest load to a random CPU (probably not the one with the lowest load or limited to the same cluster or NUMA domain, since then it would stay in a subset of the available cores). Such a re-balancing could be performed at a relatively low rate (e.g. once per second) and only if all cores are running CPU bound tasks. This would probably not lead to an optimal distribution of threads to cores, but at least lead to a real time similar to 4BSD.