Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 Mar 2021 15:45:51 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 254040] AMD 5950X hyperthreading strange performance swings
Message-ID:  <bug-254040-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D254040

            Bug ID: 254040
           Summary: AMD 5950X hyperthreading strange performance swings
           Product: Base System
           Version: 12.2-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: dennis.noordsij@alumni.helsinki.fi

I plan to upgrade our server to a Ryzen 9 5950X system, 16 cores, 3400MHz b=
ase
frequency, 128GB RAM, and ran into an issue while testing.

For reference I will use a very simple command:

  dd if=3D/dev/zero bs=3D1M count=3D1000 | bzip2 - | wc

which, using a Linux rescue system (i.e. nothing else running) consistently=
 and
repeatedly completes in about:

  1048576000 bytes (1.0 GB, 1000 MiB) copied, 4.67561 s, 224 MB/s



Now for FreeBSD 12.2-RELEASE, on a basic boot not running anything except s=
sh:

if I _disable_ hyperthreading using machdep.hyperthreading_allowed=3D0, I g=
et the
following approximate result consistently and repeatedly:

  dd if=3D/dev/zero bs=3D1M count=3D1000 | bzip2 - | wc
  1048576000 bytes transferred in 4.874335 secs (215121876 bytes/sec)

Slightly slower than Linux, not sure if this is in how bzip2 is compiled et=
c,
but nothing that worries me.=20



However, if I _enable_ hyperthreading, i.e. the default I started with, the=
n I
will get:

  dd if=3D/dev/zero bs=3D1M count=3D1000 | bzip2 - | wc
  1048576000 bytes transferred in 4.887522 secs (214541450 bytes/sec)
  1048576000 bytes transferred in 7.507138 secs (139677190 bytes/sec)
  1048576000 bytes transferred in 6.227179 secs (168386989 bytes/sec)
  1048576000 bytes transferred in 7.590263 secs (138147516 bytes/sec)
  1048576000 bytes transferred in 7.421037 secs (141297776 bytes/sec)
  1048576000 bytes transferred in 4.922986 secs (212995935 bytes/sec)
  1048576000 bytes transferred in 4.945138 secs (212041827 bytes/sec)
  1048576000 bytes transferred in 7.671600 secs (136682828 bytes/sec)
  1048576000 bytes transferred in 7.673428 secs (136650273 bytes/sec)

i.e. very consistently varying results with relatively large differences in
commands executed immediately after one another (and no other load whatsoev=
er).


I'm curious why this is happening.

I am not running powerd or touched any of the cpu settings.



Booting _without_ hyperthreading:

CPU: AMD Ryzen 9 5950X 16-Core Processor             (3393.70-MHz K8-class =
CPU)=20
  Origin=3D"AuthenticAMD"  Id=3D0xa20f10  Family=3D0x19  Model=3D0x21  Step=
ping=3D0=20=20=20=20=20=20=20
=20
Features=3D0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,=
MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>=20
=20
Features2=3D0x7ed8320b<SSE3,PCLMULQDQ,MON,SSSE3,FMA,CX16,SSE4.1,SSE4.2,MOVB=
E,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>=20
  AMD Features=3D0x2e500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM>=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20
  AMD
Features2=3D0x75c237ff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,OSVW=
,IBS,SKINIT,WDT,TCE,Topology,PCXC,PNXC,DBE,PL2I,MWAITX,<b30>>=20
  Structured Extended
Features=3D0x219c97a9<FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,PQM,PQE,RDS=
EED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA>=20
  Structured Extended Features2=3D0x40068c<UMIP,PKU,VAES,VPCLMULQDQ,RDPID>=
=20=20=20=20=20=20=20=20
  Structured Extended Features3=3D0x10=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20
  XSAVE Features=3D0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
  AMD Extended Feature Extensions ID EBX=3D0x111ef657<CLZERO,IRPerf,XSaveEr=
Ptr>=20=20=20
  SVM: NP,NRIP,VClean,AFlush,DAssist,NAsids=3D32768=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
  TSC: P-state invariant, performance statistics=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
real memory  =3D 137434759168 (131068 MB)=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
avail memory =3D 133793423360 (127595 MB)=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
Event timer "LAPIC" quality 600=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20
ACPI APIC Table: <ALASKA A M I >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20
FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
FreeBSD/SMP: 1 package(s) x 2 cache groups x 8 core(s) x 2 hardware threads=
=20=20=20=20=20
FreeBSD/SMP Online: 1 package(s) x 2 cache groups x 8 core(s)=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20



# sysctl dev.cpu.0=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
                                                         dev.cpu.0.cx_metho=
d:
C1/hlt C2/io=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.cx_usage_counters: 11922 0=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20
dev.cpu.0.cx_usage: 100.00% 0.00% last 43430us=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.cx_lowest: C1=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.cx_supported: C1/1/1 C2/2/18=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
dev.cpu.0.freq_levels: 3400/3740 2800/2800 2200/1980=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.freq: 3400=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.%parent: acpi0=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.%pnpinfo: _HID=3DACPI0007 _UID=3D0=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
dev.cpu.0.%location: handle=3D\_SB_.PLTF.C000=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20
dev.cpu.0.%driver: cpu=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.%desc: ACPI CPU=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20


Booting _with_ hyperthreading:

CPU: AMD Ryzen 9 5950X 16-Core Processor             (3393.69-MHz K8-class =
CPU)=20
  Origin=3D"AuthenticAMD"  Id=3D0xa20f10  Family=3D0x19  Model=3D0x21  Step=
ping=3D0=20=20=20=20=20=20=20
=20
Features=3D0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,=
MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>=20
=20
Features2=3D0x7ed8320b<SSE3,PCLMULQDQ,MON,SSSE3,FMA,CX16,SSE4.1,SSE4.2,MOVB=
E,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>=20
  AMD Features=3D0x2e500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM>=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20
  AMD
Features2=3D0x75c237ff<LAHF,CMP,SVM,ExtAPIC,CR8,ABM,SSE4A,MAS,Prefetch,OSVW=
,IBS,SKINIT,WDT,TCE,Topology,PCXC,PNXC,DBE,PL2I,MWAITX,<b30>>=20
  Structured Extended
Features=3D0x219c97a9<FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,PQM,PQE,RDS=
EED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA>=20
  Structured Extended Features2=3D0x40068c<UMIP,PKU,VAES,VPCLMULQDQ,RDPID>=
=20=20=20=20=20=20=20=20
  Structured Extended Features3=3D0x10=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20
  XSAVE Features=3D0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
  AMD Extended Feature Extensions ID EBX=3D0x111ef657<CLZERO,IRPerf,XSaveEr=
Ptr>=20=20=20
  SVM: NP,NRIP,VClean,AFlush,DAssist,NAsids=3D32768=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
  TSC: P-state invariant, performance statistics=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
real memory  =3D 137434759168 (131068 MB)=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
avail memory =3D 133793423360 (127595 MB)=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
Event timer "LAPIC" quality 600=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20
ACPI APIC Table: <ALASKA A M I >=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20
FreeBSD/SMP: Multiprocessor System Detected: 32 CPUs=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
FreeBSD/SMP: 1 package(s) x 2 cache groups x 8 core(s) x 2 hardware threads=
=20=20=20=20=20


# sysctl dev.cpu.0=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.cx_method: C1/hlt C2/io=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20
dev.cpu.0.cx_usage_counters: 3232 0=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20
dev.cpu.0.cx_usage: 100.00% 0.00% last 65311us=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.cx_lowest: C1=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.cx_supported: C1/1/1 C2/2/18=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
dev.cpu.0.freq_levels: 3400/3740 2800/2800 2200/1980=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.freq: 3400=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.%parent: acpi0=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.%pnpinfo: _HID=3DACPI0007 _UID=3D0=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20
dev.cpu.0.%location: handle=3D\_SB_.PLTF.C000=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20
dev.cpu.0.%driver: cpu=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
dev.cpu.0.%desc: ACPI CPU=20



zenstates.py reports:

# ./zenstates.py -l
P0 - Enabled - FID =3D 88 - DID =3D 8 - VID =3D 48 - IDD =3D 22( / 1 )
             - Ratio =3D 34.00 - vCore =3D 1.10000
P1 - Enabled - FID =3D 8C - DID =3D A - VID =3D 58 - IDD =3D 1C( / 1 )
             - Ratio =3D 28.00 - vCore =3D 1.00000
P2 - Enabled - FID =3D 84 - DID =3D C - VID =3D 68 - IDD =3D 16( / 1 )
             - Ratio =3D 22.00 - vCore =3D 0.90000
P3 - Disabled
P4 - Disabled
P5 - Disabled
P6 - Disabled
P7 - Disabled
Core Performance Boost - Enabled
C6 State - Package - Disabled
C6 State - Core - Enabled


FWIW if I disable core performance boost the varying execution times shift =
from
~4.8 and ~7.8 to to ~6.5 and ~10.8 seconds respectively, i.e. same behaviour
just slower.

I was hoping someone could explain why this is happening (note it doesn't
happen on Linux), if it is expected, and/or how it can be worked around or
fixed, or where the problem would be (p-states?).=20

Happy to test anything.


PS - I tried a 13-BETA2 rescue boot which has HT enabled and it behaves exa=
ctly
the same.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-254040-227>