kern.sched.preempt_thresh=224
kern.sched.preempt_thresh=224
kern.sched.preemp_thresh=224
sysctl kern.sched.ule.preemp_thresh
sysctl kern.sched.ule.preempt_thresh
kern.sched.ule.preempt_thresh: 40
kern.sched.4bsd.preempt_thresh
[i] Yes Master ? sysctl kern.sched
kern.sched.ule.always_steal: 0
kern.sched.ule.trysteal_limit: 2
kern.sched.ule.steal_thresh: 2
kern.sched.ule.steal_idle: 1
kern.sched.ule.balance_interval: 127
kern.sched.ule.balance: 1
kern.sched.ule.affinity: 1
kern.sched.ule.idlespinthresh: 157
kern.sched.ule.idlespins: 10000
kern.sched.ule.static_boost: 115
kern.sched.ule.preempt_thresh: 40
kern.sched.ule.interact: 30
kern.sched.ule.slice: 12
kern.sched.ule.quantum: 94488
kern.sched.topology_spec: <groups>
<group level="1" cache-level="3">
<cpu count="12" mask="fff,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11</cpu>
<children>
<group level="2" cache-level="2">
<cpu count="2" mask="3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">0, 1</cpu>
<flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags>
</group>
<group level="2" cache-level="2">
<cpu count="2" mask="c,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">2, 3</cpu>
<flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags>
</group>
<group level="2" cache-level="2">
<cpu count="2" mask="30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">4, 5</cpu>
<flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags>
</group>
<group level="2" cache-level="2">
<cpu count="2" mask="c0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">6, 7</cpu>
<flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags>
</group>
<group level="2" cache-level="2">
<cpu count="2" mask="300,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">8, 9</cpu>
<flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags>
</group>
<group level="2" cache-level="2">
<cpu count="2" mask="c00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">10, 11</cpu>
<flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags>
</group>
</children>
</group>
</groups>
kern.sched.available: 4BSD,ULE
kern.sched.name: ULE
kern.sched.4bsd.runq_fuzz: 1
kern.sched.4bsd.ipiwakeup.useloop: 0
kern.sched.4bsd.ipiwakeup.usemask: 1
kern.sched.4bsd.ipiwakeup.delivered: 0
kern.sched.4bsd.ipiwakeup.requested: 0
kern.sched.4bsd.ipiwakeup.enabled: 1
kern.sched.4bsd.slice: 12
kern.sched.4bsd.quantum: 94488
kern.sched.preemption: 1
kern.sched.cpusetsizemin: 2
kern.sched.cpusetsize: 128
kern.sched.ule.preempt_thresh=224
kern.sched.preempt_thresh=224
/etc/sysctl.conf
D'oh! That's what happens when carelessly using copy/paste!I used this for years as well
Code:kern.sched.preempt_thresh=224
And noticed it disappeared in Freebsd 15
fernandel and Manix missed the t from preemp_thresh
it should be
Code:kern.sched.preempt_thresh=224
and not
Code:kern.sched.preemp_thresh=224
also this is wrong
Code:sysctl kern.sched.ule.preemp_thresh
it should be
Code:sysctl kern.sched.ule.preempt_thresh
which on my system outputs
Code:kern.sched.ule.preempt_thresh: 40
And this doesnt exist for me
Code:kern.sched.4bsd.preempt_thresh
This is the full output kern.sched
Code:[i] Yes Master ? sysctl kern.sched kern.sched.ule.always_steal: 0 kern.sched.ule.trysteal_limit: 2 kern.sched.ule.steal_thresh: 2 kern.sched.ule.steal_idle: 1 kern.sched.ule.balance_interval: 127 kern.sched.ule.balance: 1 kern.sched.ule.affinity: 1 kern.sched.ule.idlespinthresh: 157 kern.sched.ule.idlespins: 10000 kern.sched.ule.static_boost: 115 kern.sched.ule.preempt_thresh: 40 kern.sched.ule.interact: 30 kern.sched.ule.slice: 12 kern.sched.ule.quantum: 94488 kern.sched.topology_spec: <groups> <group level="1" cache-level="3"> <cpu count="12" mask="fff,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11</cpu> <children> <group level="2" cache-level="2"> <cpu count="2" mask="3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">0, 1</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="c,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">2, 3</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">4, 5</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="c0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">6, 7</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="300,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">8, 9</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="c00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">10, 11</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> </children> </group> </groups> kern.sched.available: 4BSD,ULE kern.sched.name: ULE kern.sched.4bsd.runq_fuzz: 1 kern.sched.4bsd.ipiwakeup.useloop: 0 kern.sched.4bsd.ipiwakeup.usemask: 1 kern.sched.4bsd.ipiwakeup.delivered: 0 kern.sched.4bsd.ipiwakeup.requested: 0 kern.sched.4bsd.ipiwakeup.enabled: 1 kern.sched.4bsd.slice: 12 kern.sched.4bsd.quantum: 94488 kern.sched.preemption: 1 kern.sched.cpusetsizemin: 2 kern.sched.cpusetsize: 128
So after some digging around it looks
this is the new code you should use
Code:kern.sched.ule.preempt_thresh=224
as a replacement for the old code
Code:kern.sched.preempt_thresh=224
which should be added to
Code:/etc/sysctl.conf
some one correct me if im wrong
It was copy/paste...sorryI used this for years as well
Code:kern.sched.preempt_thresh=224
And noticed it disappeared in Freebsd 15
fernandel and Manix missed the t from preemp_thresh
it should be
Code:kern.sched.preempt_thresh=224
and not
Code:kern.sched.preemp_thresh=224
also this is wrong
Code:sysctl kern.sched.ule.preemp_thresh
it should be
Code:sysctl kern.sched.ule.preempt_thresh
which on my system outputs
Code:kern.sched.ule.preempt_thresh: 40
And this doesnt exist for me
Code:kern.sched.4bsd.preempt_thresh
This is the full output kern.sched
Code:[i] Yes Master ? sysctl kern.sched kern.sched.ule.always_steal: 0 kern.sched.ule.trysteal_limit: 2 kern.sched.ule.steal_thresh: 2 kern.sched.ule.steal_idle: 1 kern.sched.ule.balance_interval: 127 kern.sched.ule.balance: 1 kern.sched.ule.affinity: 1 kern.sched.ule.idlespinthresh: 157 kern.sched.ule.idlespins: 10000 kern.sched.ule.static_boost: 115 kern.sched.ule.preempt_thresh: 40 kern.sched.ule.interact: 30 kern.sched.ule.slice: 12 kern.sched.ule.quantum: 94488 kern.sched.topology_spec: <groups> <group level="1" cache-level="3"> <cpu count="12" mask="fff,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11</cpu> <children> <group level="2" cache-level="2"> <cpu count="2" mask="3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">0, 1</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="c,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">2, 3</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">4, 5</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="c0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">6, 7</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="300,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">8, 9</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> <group level="2" cache-level="2"> <cpu count="2" mask="c00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">10, 11</cpu> <flags><flag name="THREAD">THREAD group</flag><flag name="SMT">SMT group</flag></flags> </group> </children> </group> </groups> kern.sched.available: 4BSD,ULE kern.sched.name: ULE kern.sched.4bsd.runq_fuzz: 1 kern.sched.4bsd.ipiwakeup.useloop: 0 kern.sched.4bsd.ipiwakeup.usemask: 1 kern.sched.4bsd.ipiwakeup.delivered: 0 kern.sched.4bsd.ipiwakeup.requested: 0 kern.sched.4bsd.ipiwakeup.enabled: 1 kern.sched.4bsd.slice: 12 kern.sched.4bsd.quantum: 94488 kern.sched.preemption: 1 kern.sched.cpusetsizemin: 2 kern.sched.cpusetsize: 128
So after some digging around it looks
this is the new code you should use
Code:kern.sched.ule.preempt_thresh=224
as a replacement for the old code
Code:kern.sched.preempt_thresh=224
which should be added to
Code:/etc/sysctl.conf
some one correct me if im wrong
kern.sched.ule.preempt_thresh=224
kern.sched.preempt_thresh=224
kern.sched.4bsd.preempt_thresh
No problem mate happens to all of us
So to recap it looks like this is the new code
Code:kern.sched.ule.preempt_thresh=224
for the old code
Code:kern.sched.preempt_thresh=224
and this doesnt seem to exist
Code:kern.sched.4bsd.preempt_thresh
I think we need SirDice to confirm that
or if he's not about Sir David Beckham instead

kern.sched.name=4BSD
For what it's worth with more modern cpus, I don't think there's any real need anyway to change the default preempt_thresh value for desktop use.
That is the question, isn't it.So do you folks want more or less preemption?
That is the question, isn't it.
The bigger picture is "how does preemption affect responsivness on a desktop"?
What does responsiveness on a desktop actually look like?
Hit a key, character appears.
Move the mouse, cursor moves.
Click the mouse, menu pops up.
What's the path for that? Roughly (very roughly):
Device input, device driver, kernel event queue, Xorg processing event, Xorg handing event off to application, application rendering character/popping up menu.
Lots of things in the chain.
So what gets affected by the preemption threshhold?
I'd likely have issue above 2msDesktop reactiveness: what is the threshold for a user to detect a mouse movement/key type. 1ms, 10ms, 100ms? Quicker is better but what is quick enough? I think most interactive things say roughly 10ms or less.
Interesting. That implies you can detect the difference between a 2ms and a 10ms delay on say hitting a key and having it appear. Don't take that the wrong way; it's an analogy with speech and telephony. Look at everything related to voice on the POTS network and you wind up with 8KHz bandwidth with sampling at a rate lower than you would think.I'd likely have issue above 2ms
Would prefer input highest-priority above anything on desktop: if that's slow, then every interaction while on a desktop is slow.
Audiophiles shouldn't care about delay as long as it is constant.Or audiophiles stating that vacuum tube amps and analog inputs are light years ahead of any digital system. I truly believe some people can tell the difference, most can't but the actual input makes a difference in what can be heard. I'm saying that as someone that can't carry a tune if you put it in a bucket.
Agree completely. I think we still come back to what is the acceptable latency above zero. And honestly, I think that starts to become personal.Audiophiles shouldn't care about delay as long as it is constant.
Musicians on the other hand legitimately care about latency when they play and need to hear themselves. But there is a minimum delay you can't avoid due to sound being so slow between speakers and ear, so here again it is unreasonable to demand zero latency.
sysctl -d kern.sched.ule, and, of course, the source.Less for my ARM64 GPIO robot build where I want nearest RealTime I can muster.So do you folks want more or less preemption?
The paper on sched_ule: https://www.usenix.org/legacy/event/bsdcon03/tech/full_papers/roberson/roberson.pdf
Worth reading before turning knobs.
See alsosysctl -d kern.sched.ule, and, of course, the source.
sched_ule(4) tries to dynamically detect "interactive" programs as those that spend more time voluntarily sleeping (in sleep() or by waiting on a conditional variable — assumed to be waiting for user interaction) than running (burning CPU on a intensive processing task). This is a balancing act, but programs marked interactive get put in the queue to be run before tasks marked non-interactive (a compiler is the canonical example; after some moderate I/O at launch, it typically burns CPU without ever calling sleep() or blocking/waiting for something else).
The main tunable to adjust how aggressively tasks are labeled interactive is kern.sched.ule.interact [0..100; default 30]. 100=everything is marked interactive; 0 = nothing is. (Note setting to 0 or 100 largely "turns off" any impact from interactivity-scoring.)
Using idprio(1) or cpuset(1) directly on high (CPU) intensity tasks might be a more direct approach to try.
Other runnable tasks are scheduled before ones in the idle-queue, and idle-queue tasks are always preempted (provided they aren't in a syscall) when a non-idle-queue task becomes runnable. This might be a better choice than trying to tune a global system scheduling parameter.
Note if the "interfering" task is an I/O or memory bandwidth hog, some effect is unavoidable. FreeBSD doesn't have an ionice command.
On modern multi-core systems, you hopefully don't need to adjust these at all, but if you do, you need to pin down what your goal is and under what workload.
It would be great if we had a way to inspect this "interactivity score" on a per-thread or per-process basis.
I have concerns that CPU-heavy interactive applications such as web browsers might not be covered.
I don't follow this. The last time I looked, interactivity was a percentage which was added to the nice value to get the priority; the priorities were spit between interactive and batch. Interactive levels were assigned to dedicated queues (one per priority) with the batch levels handled by a ring of queues that guaranteed batch tasks all got some time. So being interactive wasn't a purely boolean distinction because there were many levels handled in priority order.The paper on sched_ule: https://www.usenix.org/legacy/event/bsdcon03/tech/full_papers/roberson/roberson.pdf
Worth reading before turning knobs.
See alsosysctl -d kern.sched.ule, and, of course, the source.
sched_ule(4) tries to dynamically detect "interactive" programs as those that spend more time voluntarily sleeping (in sleep() or by waiting on a conditional variable — assumed to be waiting for user interaction) than running (burning CPU on a intensive processing task). This is a balancing act, but programs marked interactive get put in the queue to be run before tasks marked non-interactive (a compiler is the canonical example; after some moderate I/O at launch, it typically burns CPU without ever calling sleep() or blocking/waiting for something else).
The main tunable to adjust how aggressively tasks are labeled interactive is kern.sched.ule.interact [0..100; default 30]. 100=everything is marked interactive; 0 = nothing is. (Note setting to 0 or 100 largely "turns off" any impact from interactivity-scoring.)