Skip to content

fs: Add Kernel-level VFS Performance Profiler#18607

Merged
acassis merged 1 commit intoapache:masterfrom
Sumit6307:vfs-profiler-gsoc
Apr 26, 2026
Merged

fs: Add Kernel-level VFS Performance Profiler#18607
acassis merged 1 commit intoapache:masterfrom
Sumit6307:vfs-profiler-gsoc

Conversation

@Sumit6307
Copy link
Copy Markdown
Contributor

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_PROFILER configuration, 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 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 command.
  4. Read the profile node to verify accuracy.

Test Log:

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> 

@github-actions github-actions Bot added Area: File System File System issues Size: M The size of the change in this PR is medium Size: L The size of the change in this PR is large and removed Size: M The size of the change in this PR is medium labels Mar 25, 2026
@Sumit6307 Sumit6307 force-pushed the vfs-profiler-gsoc branch 2 times, most recently from 6cbaa23 to b34527a Compare March 25, 2026 19:36
@Sumit6307
Copy link
Copy Markdown
Contributor Author

Sumit6307 commented Mar 25, 2026

@acassis @cederom Sir Please Review this PR

Comment thread fs/mnemofs/mnemofs_util.c
Comment thread fs/procfs/Kconfig Outdated
Copy link
Copy Markdown
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Thank you @Sumit6307 very nice idea! :-)
  • My remarks noted in the code.
  • We should align the nomenclature PROFILE vs PROFILER (second seems better suited imho), as both names are used for the same functionality. Maybe PERF or PERFPROF would clearly indicate performance profiler?
  • Please also provide simple nuttx/Documentation for the new functionality.

acassis
acassis previously approved these changes Mar 25, 2026
@acassis
Copy link
Copy Markdown
Contributor

acassis commented Mar 25, 2026

@Sumit6307 why are you including mnemofs commit here?

@cederom
Copy link
Copy Markdown
Contributor

cederom commented Mar 25, 2026

@Sumit6307 why are you including mnemofs commit here?

Yup, I would put that into a separate PR too :-P

Comment thread fs/mnemofs/mnemofs.h Outdated
Comment thread fs/vfs/fs_profile.c Outdated
Comment thread fs/vfs/fs_profile.c Outdated
Comment thread fs/procfs/fs_procfs.c Outdated
Comment thread fs/procfs/fs_procfsprofile.c Outdated
Comment thread fs/vfs/fs_open.c Outdated
Comment thread include/nuttx/fs/fs_profile.h Outdated
@xiaoxiang781216
Copy link
Copy Markdown
Contributor

@Sumit6307 why not reuse sched_note syscall to profile fs performance? you can learn from Documentation

@Sumit6307 Sumit6307 requested a review from raiden00pl as a code owner March 26, 2026 06:18
@github-actions github-actions Bot removed Area: File System File System issues Size: L The size of the change in this PR is large labels Mar 26, 2026
Comment thread fs/procfs/fs_procfsprofile.c Outdated
Comment thread commit_msg.txt Outdated
Comment thread fs/vfs/fs_write.c Outdated
Comment thread fs/vfs/fs_read.c Outdated
Comment thread fs/vfs/fs_open.c Outdated
Comment thread fs/vfs/fs_close.c Outdated
@Sumit6307 Sumit6307 force-pushed the vfs-profiler-gsoc branch 2 times, most recently from 14dee63 to 472b99f Compare April 14, 2026 09:54
jerpelea
jerpelea previously approved these changes Apr 14, 2026
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>
@Sumit6307
Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 All final cleanup and refactoring is complete:

  1. Removed all explicit casts in fs_procfsprofile.c by using standard PRIu32 and PRIu64 specifiers.
  2. Deleted commit_msg.txt and test_bits_log.txt from the root.
  3. Corrected argument indentation in the FS_PROFILE_STOP macro calls in all VFS hooks.

The PR is now ready for final review.

@Sumit6307
Copy link
Copy Markdown
Contributor Author

Hi @anchao and @cederom , I’ve updated the PR and addressed the requested changes. Please check and approve if everything looks good.

Copy link
Copy Markdown
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Sumit6307 great work! :-)

@Sumit6307
Copy link
Copy Markdown
Contributor Author

@acassis If everything looks good and correct now, please merge this PR.

@acassis
Copy link
Copy Markdown
Contributor

acassis commented Apr 19, 2026

@acassis If everything looks good and correct now, please merge this PR.

@Sumit6307 yes, but since @anchao added a Change Request, we need an approval from him to merge this PR

@Sumit6307
Copy link
Copy Markdown
Contributor Author

Hi @anchao, I’ve addressed all the requested changes and updated the PR accordingly. Could you please review the latest changes and approve if everything looks good? Once approved, we can proceed with merging. Thanks

@Sumit6307
Copy link
Copy Markdown
Contributor Author

@acassis If everything looks good and correct now, please merge this PR.

@Sumit6307 yes, but since @anchao added a Change Request, we need an approval from him to merge this PR

@acassis
Sir, @anchao hasn’t approved the PR yet. Could you please ask him to check and approve so we can proceed with the merge?

@acassis
Copy link
Copy Markdown
Contributor

acassis commented Apr 22, 2026

@Sumit6307 sure, if the reviewer disappear for few weeks, we can dismiss their Change Request, let way more few days, maybe he is busy

@Sumit6307
Copy link
Copy Markdown
Contributor Author

@Sumit6307 sure, if the reviewer disappear for few weeks, we can dismiss their Change Request, let way more few days, maybe he is busy

Okay Sir @acassis

@Sumit6307
Copy link
Copy Markdown
Contributor Author

@acassis
Hi Sir, just wanted to check if you had a chance to review my GSoC proposal #18645.

I’ve been actively contributing to Apache and the NuttX project and have a good understanding of its structure and workflows.

Also, from your perspective, does my approach align well with what you're looking for in GSoC?

@acassis acassis dismissed anchao’s stale review April 26, 2026 14:50

Dismissed because more than 2 week has passed without reviewer return

@acassis acassis merged commit b2b78d2 into apache:master Apr 26, 2026
16 checks passed
@acassis
Copy link
Copy Markdown
Contributor

acassis commented Apr 26, 2026

@acassis Hi Sir, just wanted to check if you had a chance to review my GSoC proposal #18645.

I’ve been actively contributing to Apache and the NuttX project and have a good understanding of its structure and workflows.

Also, from your perspective, does my approach align well with what you're looking for in GSoC?

Hi @Sumit6307, yes I reviewed your proposal and it was submitted and ranked correctly.

However we don't know many projects will be approved, since Apache Software Foundation reserves only 2 slot for each project.

@Sumit6307
Copy link
Copy Markdown
Contributor Author

@acassis Hi Sir, just wanted to check if you had a chance to review my GSoC proposal #18645.
I’ve been actively contributing to Apache and the NuttX project and have a good understanding of its structure and workflows.
Also, from your perspective, does my approach align well with what you're looking for in GSoC?

Hi @Sumit6307, yes I reviewed your proposal and it was submitted and ranked correctly.

However we don't know many projects will be approved, since Apache Software Foundation reserves only 2 slot for each project.

Hi @acassis Sir,
Thank you for reviewing my proposal and for the clarification.

Since submitting the proposal, I have continued contributing and recently got a few more PRs merged, including:

apache/incubator-seata#7981
#18607

I also have a couple of PRs currently under review which should be merged soon.

I wanted to ask if these recent contributions after proposal submission are also considered during the evaluation process. I’ve been actively contributing across Apache Software Foundation projects and continuing to deepen my understanding of Apache NuttX.

Please let me know if there’s anything else I can improve or work on.

@anchao
Copy link
Copy Markdown
Contributor

anchao commented Apr 27, 2026

@acassis If everything looks good and correct now, please merge this PR.

@Sumit6307 yes, but since @anchao added a Change Request, we need an approval from him to merge this PR

@acassis Sir, @anchao hasn’t approved the PR yet. Could you please ask him to check and approve so we can proceed with the merge?

@Sumit6307 I'm on a short break recently. Congrats on getting this PR merged.

@Sumit6307
Copy link
Copy Markdown
Contributor Author

@acassis If everything looks good and correct now, please merge this PR.

@Sumit6307 yes, but since @anchao added a Change Request, we need an approval from him to merge this PR

@acassis Sir, @anchao hasn’t approved the PR yet. Could you please ask him to check and approve so we can proceed with the merge?

@Sumit6307 I'm on a short break recently. Congrats on getting this PR merged.

@anchao
Thank you,I really appreciate your support and guidance throughout the process

@Sumit6307
Copy link
Copy Markdown
Contributor Author

@acassis
Sir, I contributed as much as I could, understood the codebase, workflow, and project structure, and got 5+ PRs merged in Apache projects.
I gave my full effort, but the verdict was still not selected. I am unable to understand why.

@acassis
Copy link
Copy Markdown
Contributor

acassis commented Apr 30, 2026

@acassis Sir, I contributed as much as I could, understood the codebase, workflow, and project structure, and got 5+ PRs merged in Apache projects. I gave my full effort, but the verdict was still not selected. I am unable to understand why.

This year we had many proposals and candidates and unfortunately ASF receives only about 27 to divide with all projects. And keep in mind that you applied to Multi-user Support project that had a more stronger candidate (Abhishek), he is also a great contributor like you, and his proposal was perfect.

We wanted that all contributors and candidates get selected, but unfortunately ASF have very few slots, compared to amount of projects under their umbrella.

@Sumit6307
Copy link
Copy Markdown
Contributor Author

@acassis Sir, I contributed as much as I could, understood the codebase, workflow, and project structure, and got 5+ PRs merged in Apache projects. I gave my full effort, but the verdict was still not selected. I am unable to understand why.

This year we had many proposals and candidates and unfortunately ASF receives only about 27 to divide with all projects. And keep in mind that you applied to Multi-user Support project that had a more stronger candidate (Abhishek), he is also a great contributor like you, and his proposal was perfect.

We wanted that all contributors and candidates get selected, but unfortunately ASF have very few slots, compared to amount of projects under their umbrella.

@acassis
Sir, I understand the slot limitation, and yes, Abhishek is also a very good contributor. I respect the decision.

I just wanted to say that I also gave my full effort, understood the codebase, contributed consistently, and felt that I was also a deserving candidate, but still I was not selected.

Thank you for explaining this clearly and for guiding me throughout the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Documentation Improvements or additions to documentation Board: simulator Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants