Steven Barrett commented on issue #106 at Alfred Chen / linux-prjc

Steven Barrett
2025-12-01T02:40:45Z

It looks like an upcoming patch set that will probably make it to mainline soon has a major impact on the context switching benchmark: https://lore.kernel.org/lkml/20251123121827.1304-1-qq570070308@gmail.com/

From the patch set cover letter:

This series of patches primarily make some functions called in context
switching as always inline to optimize performance. Here is the
performance test data for these patches:
Time spent on calling finish_task_switch(), the unit is tsc from x86:
| test scenario | old | new | delta |
| gcc 15.2 | 13.94 | 12.40 | 1.54 (-11.1%) |
| gcc 15.2 + spectre_v2 | 24.78 | 13.70 | 11.08 (-44.7%) |
| clang 21.1.4 | 13.90 | 12.71 | 1.19 (- 8.6%) |
| clang 21.1.4 + spectre_v2 | 29.01 | 18.91 | 10.1 (-34.8%) |

Here's the ported version [1] for Project-C on v6.17, I've been running it all day and it feels a bit better. Also on the phoronix test suite, the context switch benchmark went from 800k bogo ops to 2.5 million on my 5950x. This is still far below mainlines numbers but still a very welcome upgrade.

Maybe it's worthwhile to incorporate this into a Project-C release before it hits mainline? Risk seems low, just replacing inline with __always_inline for several functions, and moving one locking function from alt_core.c to the headers where the rest of the locking functions are.

[1] https://github.com/zen-kernel/zen-kernel/commit/1a5574b41f66fc360a290f3e460ab17c4f7de99a