# Cpu usage is not going up even on high load



## ruchir15 (May 6, 2022)

I have high configuration physical server over which I am doing performance testing.

```
FreeBSD 13.0-STABLE #0 stable/13-n247514-c39bfe47139   
..
...
FreeBSD/SMP: Multiprocessor System Detected: 40 CPU
```

However, when I am putting load on this freebsd server from a client, I see CPU is getting used to maximum in range of 60 to 70 (around to 30 to 40 percent idle) percent .i.e.

```
output from top command

last pid:  2573;  load averages:  7.63,  1.86,  1.22                                   up 0+00:59:52  11:34:15
22 processes:  1 running, 21 sleeping
CPU: 24.5% user,  0.0% nice, 41.5% system,  0.0% interrupt, 34.0% idle

user + system = 60
```

On checking  /var/log/messages

I see below message related to listen queue overflow.

```
May xxxx  xxxx kernel: sonewconn: pcb 0xfffff80208613ba0 ([::]:80 (proto 6)): Listen queue overflow: 193 already in queue awaiting acceptance (19265 occurrences)
```

So I tried configuring the value of

```
sysctl -d kern.ipc.somaxconn
kern.ipc.somaxconn: Maximum listen socket pending connection accept queue size (compat)
sysctl kern.ipc.somaxconn=4096
kern.ipc.somaxconn: 128 -> 4096
```

I stopped receiving error for  Listen queue overflow however still the cpu range is getting limited to 60 to 70 usage of cpu.

however as soon as turn off hyperthreading .i.e


```
sysctl machdep.hyperthreading_allowed=0
```

I see increase in cpu usage (cpu idle percentage going down )thus RPS (request per second ) on my client goes double .i.e

```
output from top command

last pid:  2523;  load averages:  4.73,  1.11,  0.40                                   up 0+00:01:51  12:03:53
22 processes:  1 running, 21 sleeping
CPU: 78.1% user,  0.0% nice, 13.5% system,  0.1% interrupt,  8.3% idle
```


I am wondering that ideally configuration is to enable hyperthreading.
(Even some other servers which has hyperthreading turn on and has lower specs showing good performance)

Any lead to understand why cpu usage is limited on 60 to 70 percent on high load when hyperthreading is on? How can I  increase CPU usage (thus throughput) even when hyperthreading is on?


----------



## SirDice (May 6, 2022)

```
FreeBSD 13.0-STABLE #0 stable/13-n247514-c39bfe47139
```
Update your system, this is an old -STABLE.


```
dice@hosaka:~ % uname -a
FreeBSD hosaka.dicelan.home 13.1-STABLE FreeBSD 13.1-STABLE #99 stable/13-n250645-d511f4c7bf9: Sun May  1 04:21:04 CEST 2022     root@hosaka.dicelan.home:/usr/obj/usr/src/amd64.amd64/sys/HOSAKA amd64
```



ruchir15 said:


> I see below message related to listen queue overflow.


Those have nothing to do with your CPU load. Your service is simply not handling connections fast enough, which could be because of a myriad of reasons. Slow disk I/O, bad database backend;  corrupted tables for example, or simply a badly tuned database.


----------



## ruchir15 (May 6, 2022)

SirDice said:


> ```
> FreeBSD 13.0-STABLE #0 stable/13-n247514-c39bfe47139
> ```
> Update your system, this is an old -STABLE.
> ...



The doubt is then how service handle connection quite fine when I disable the hyperthreading, the performance impoved just 2x folds...


----------



## SirDice (May 6, 2022)

ruchir15 said:


> The doubt is then how service handle connection quite fine when I disable the hyperthreading


Crap application? I mean, why would it have a problem with this? What service are we talking about here? How are things configured? What does the service do?


----------

