fs: Add Kernel-level VFS Performance Profiler#18607
fs: Add Kernel-level VFS Performance Profiler#18607Sumit6307 wants to merge 1 commit intoapache:masterfrom
Conversation
6cbaa23 to
b34527a
Compare
cederom
left a comment
There was a problem hiding this comment.
- Thank you @Sumit6307 very nice idea! :-)
- My remarks noted in the code.
- We should align the nomenclature
PROFILEvsPROFILER(second seems better suited imho), as both names are used for the same functionality. MaybePERForPERFPROFwould clearly indicate performance profiler? - Please also provide simple
nuttx/Documentationfor the new functionality.
|
@Sumit6307 why are you including mnemofs commit here? |
Yup, I would put that into a separate PR too :-P |
|
@Sumit6307 why not reuse sched_note syscall to profile fs performance? you can learn from Documentation |
b34527a to
f8a783e
Compare
I think sim:citest is the right place to include it! Please @simbit18 @lupyuen confirm it |
|
I agree with @xiaoxiang781216 that it would be good to use the existing framework for profiling this. I'm also not sure why this type of profiling would need to exist in the kernel space? It is just a timer surrounding open/close/read/write calls, which could be done from user space applications. What regressions is this catching? |
|
I was wondering if there might be a potential issue here, based on my understanding: |
It's not the user/caller need to concern, but the implementation o perf_getime should fix this problem instead. |
f4c0133 to
5361d4f
Compare
|
@xiaoxiang781216 @jingfei195887 I completely agree with @xiaoxiang781216. The cross-CPU synchronization of hardware counters used by While it might introduce minor jitter if threads migrate between cores during a syscall, the primary goal here is high-level regression detection in the CI (which runs in a controlled environment). The call counts remain 100% accurate, and the timing data still provides a very useful relative indicator for Catching sudden performance drops in the VFS path without the heavy complexity of host-side trace decoding. |
|
@acassis Thank you! I have just updated the I've added:
This ensures the profiler is always validated during CI regression tests, while staying disabled by default ( |
|
@acassis Hi sir, I have applied for the project “Add multi-user support for NuttX” and submitted my proposal on the official portal. Since you are the mentor for this project, I kindly request you to review my application and consider me. I have gone through the project in detail and have also contributed to the Apache organization, including NuttX. Thank you for your time and consideration. |
|
@Sumit6307 seems like boards/sim/sim/sim/configs/citest/defconfig is not normalized, please normalize it, more info: https://nuttx.apache.org/docs/latest/components/tools/refresh.html |
5361d4f to
9b91c66
Compare
@acassis Done I have normalized the |
|
@Sumit6307 still failing for citest board profile (sim:citest) |
9b91c66 to
5739cb0
Compare
@acassis Ah, thank you for catching that! My local editor accidentally sorted the disabled Kconfig comments ( I have manually reverted those negated configurations back to the top of the |
5739cb0 to
4b98324
Compare
|
Error: /home/runner/work/nuttx/nuttx/nuttx/fs/procfs/fs_procfsprofile.c:75:78: error: Long line found |
e4998b7 to
ed503d0
Compare
ed503d0 to
14dee63
Compare
This adds a kernel-level performance profiler for the VFS. By enabling CONFIG_FS_PROFILER, the core VFS system calls (file_read, file_write, file_open, and file_close) are instrumented to track high-resolution execution times using clock_systime_timespec() seamlessly. The collected statistics are exposed dynamically via a new procfs node at /proc/fs/profile, allowing CI regression testing without needing external debugging tools. Signed-off-by: Sumit6307 <sumitkesar6307@gmail.com>
14dee63 to
472b99f
Compare
Note: Please adhere to Contributing Guidelines.
Summary
Currently, assessing the latency or throughput of VFS operations requires external tools, ad-hoc test apps, or complex debug setups. This makes automated performance regression testing in CI difficult.
This PR introduces a Kernel-level VFS Performance Profiler to address this gap.
By enabling the new
CONFIG_FS_PROFILERconfiguration, the core VFS system calls (file_read, file_write, file_open, and file_close) are instrumented to track high-resolution execution times (in nanoseconds) and invocation counts seamlessly usingclock_systime_timespec().The collected statistics are exposed dynamically via a new procfs node at
/proc/fs/profile. This enables any testing script, CI workflow, or user-space application to effortlessly monitor filesystem performance bottlenecks and catch regressions.Impact
cat /proc/fs/profile.CONFIG_FS_PROFILER). When disabled, code size and performance impact are exactly zero.enter_critical_section) to ensure SMP (multi-core) scaling is not bottlenecked.Testing
Tested on Host: Windows 11 (via WSL2).
Tested on Board:
sim:nsh(NuttX Simulator).Test procedure:
CONFIG_FS_PROFILER=yandCONFIG_FS_PROCFS=y.Test Log: