Skip to content

tools/cephfs: add new cephfs-tool - #67032

Merged
batrick merged 3 commits into
ceph:mainfrom
batrick:cephfs-bench
Apr 15, 2026
Merged

batrick merged 3 commits into
ceph:mainfrom
batrick:cephfs-bench

Conversation

@batrick

@batrick batrick commented Jan 21, 2026 •

Copy link
Copy Markdown
Member

This patch introduces cephfs-tool, a new standalone C++ utility designed to interact directly with libcephfs.

While the tool is architected to support various subcommands in the future, the initial implementation focuses on a bench command to measure library performance. This allows developers and administrators to benchmark the userspace library isolated from FUSE or Kernel client overheads.

Key features include:

  • Multi-threaded Read/Write throughput benchmarking.
  • Configurable block sizes, file counts, and fsync intervals.
  • Detailed statistical reporting (Mean, Std Dev, Min/Max) for throughput and IOPS.
  • Support for specific CephFS user/group impersonation (UID/GID) via ceph_mount_perms_set.

As an example test on a "trial" sepia machine against the new LRC, I used a command like:

pdonnell@trial154:~$ env CEPH_ARGS="--log-to-stderr=false --log-to-file=false --log-file=/tmp/bench.log" ./cephfs-tool -c ~/ceph.conf -k ~/keyring -i scratch --filesystem scratch  bench --root-path=/pdonnell --files 256 --size=$(( 128 * 2 ** 20 )) --threads=8 --iterations 3
Benchmark Configuration:
  Threads: 8 | Iterations: 3
  Files: 256 | Size: 134217728
  Filesystem: scratch
  Root: /pdonnell
  Subdirectory: bench_run_d942
  UID: -1
  GID: -1

--- Iteration 1 of 3 ---
Starting Write Phase...
  Write: 2761.97 MB/s, 21.5779 files/s (11.864s)
Starting Read Phase...
  Read:  2684.36 MB/s, 20.9716 files/s (12.207s)

--- Iteration 2 of 3 ---
Starting Write Phase...
  Write: 2698.51 MB/s, 21.0821 files/s (12.143s)
Starting Read Phase...
  Read:  2682.16 MB/s, 20.9544 files/s (12.217s)

--- Iteration 3 of 3 ---
Starting Write Phase...
  Write: 2720.69 MB/s, 21.2554 files/s (12.044s)
Starting Read Phase...
  Read:  2695.18 MB/s, 21.0561 files/s (12.158s)

*** Final Report ***

Write Throughput Statistics (3 runs):
  Mean:    2727.06 MB/s
  Std Dev: 26.2954 MB/s
  Min:     2698.51 MB/s
  Max:     2761.97 MB/s

Read Throughput Statistics (3 runs):
  Mean:    2687.24 MB/s
  Std Dev: 5.68904 MB/s
  Min:     2682.16 MB/s
  Max:     2695.18 MB/s

File Creates Statistics (3 runs):
  Mean:    21.3051 files/s
  Std Dev: 0.205433 files/s
  Min:     21.0821 files/s
  Max:     21.5779 files/s

File Reads (Opens) Statistics (3 runs):
  Mean:    20.994 files/s
  Std Dev: 0.0444456 files/s
  Min:     20.9544 files/s
  Max:     21.0561 files/s

Cleaning up...

For a 25Gb NIC, this is just about saturating the sticker bandwidth with a single shared mount and 8 threads. For a per-thread mount:

pdonnell@trial154:~$ env CEPH_ARGS="--log-to-stderr=false --log-to-file=false --log-file=/tmp/bench.log" ./cephfs-tool -c ~/ceph.conf -k ~/keyring -i scratch --filesystem scratch  bench --root-path=/pdonnell --files 256 --size=$(( 128 * 2 ** 20 )) --threads=8 --iterations 3 --per-thread-mount
Benchmark Configuration:
  Threads: 8 | Iterations: 3
  Files: 256 | Size: 134217728
  Filesystem: scratch
  Root: /pdonnell
  Subdirectory: bench_run_9d1c
  UID: -1
  GID: -1

--- Iteration 1 of 3 ---
Starting Write Phase...
  Write: 2691.2 MB/s, 21.025 files/s (12.176s)
Starting Read Phase...
  Read:  2486.76 MB/s, 19.4278 files/s (13.177s)

--- Iteration 2 of 3 ---
Starting Write Phase...
  Write: 2688.77 MB/s, 21.006 files/s (12.187s)
Starting Read Phase...
  Read:  2496.42 MB/s, 19.5033 files/s (13.126s)

--- Iteration 3 of 3 ---
Starting Write Phase...
  Write: 2692.08 MB/s, 21.0319 files/s (12.172s)
Starting Read Phase...
  Read:  2488.27 MB/s, 19.4396 files/s (13.169s)
*** Final Report ***

Write Throughput Statistics (3 runs):
  Mean:    2690.68 MB/s
  Std Dev: 1.40086 MB/s
  Min:     2688.77 MB/s
  Max:     2692.08 MB/s

Read Throughput Statistics (3 runs):
  Mean:    2490.48 MB/s
  Std Dev: 4.24374 MB/s
  Min:     2486.76 MB/s
  Max:     2496.42 MB/s

File Creates Statistics (3 runs):
  Mean:    21.0209 files/s
  Std Dev: 0.0109442 files/s
  Min:     21.006 files/s
  Max:     21.0319 files/s

File Reads (Opens) Statistics (3 runs):
  Mean:    19.4569 files/s
  Std Dev: 0.0331542 files/s
  Min:     19.4278 files/s
  Max:     19.5033 files/s

Cleaning up...

Or to measure file create performance:

pdonnell@trial154:~$ env CEPH_ARGS="--log-to-stderr=false --log-to-file=false --log-file=/tmp/bench.log" ./cephfs-tool -c ~/ceph.conf -k ~/keyring -i scratch --filesystem scratch  bench --root-path=/pdonnell --files=$(( 2 ** 16 )) --size=$(( 0 * 2 ** 20 )) --threads=8 --iterations 3
Benchmark Configuration:
  Threads: 8 | Iterations: 3
  Files: 65536 | Size: 0
  Filesystem: scratch
  Root: /pdonnell
  Subdirectory: bench_run_d435
  UID: -1
  GID: -1

--- Iteration 1 of 3 ---
Starting Write Phase...
  Write: 3974.77 files/s (16.488s)
Starting Read Phase...
  Read:  14537.7 files/s (4.508s)
Cleaning up for next iteration...

--- Iteration 2 of 3 ---
Starting Write Phase...
  Write: 4167.1 files/s (15.727s)
Starting Read Phase...
  Read:  13636.3 files/s (4.806s)
Cleaning up for next iteration...

--- Iteration 3 of 3 ---
Starting Write Phase...
  Write: 3863.7 files/s (16.962s)
Starting Read Phase...
  Read:  14972.8 files/s (4.377s)

*** Final Report ***

File Creates Statistics (3 runs):
  Mean:    4001.86 files/s
  Std Dev: 125.337 files/s
  Min:     3863.7 files/s
  Max:     4167.1 files/s

File Reads (Opens) Statistics (3 runs):
  Mean:    14382.3 files/s
  Std Dev: 556.594 files/s
  Min:     13636.3 files/s
  Max:     14972.8 files/s

Cleaning up...

Here is the current help text:

Usage: cephfs-bench [general-options] <command> [command-options]

Commands:
  bench      Run IO benchmark

Allowed options:

General Options:
  -h [ --help ]                   Produce help message
  -c [ --conf ] arg               Ceph config file path
  -i [ --id ] arg (=admin)        Client ID
  -k [ --keyring ] arg            Path to keyring file
  --filesystem arg                CephFS filesystem name to mount
  --uid arg (=-1)                 User ID to mount as
  --gid arg (=-1)                 Group ID to mount as

Benchmark Options (used with 'bench' command):
  --threads arg (=1)              Number of threads
  --iterations arg (=1)           Number of iterations
  --files arg (=100)              Total number of files
  --size arg (=4MB)               File size (e.g. 4MB, 0 for creates only)
  --block-size arg (=4MB)         IO block size (e.g. 1MB)
  --fsync-every arg (=0)          Call fsync every N bytes
  --prefix arg (=benchmark_)      Filename prefix
  --dir-prefix arg (=bench_run_)  Directory prefix
  --root-path arg (=/)            Root path in CephFS
  --per-thread-mount              Use separate mount per thread
  --no-cleanup                    Disable cleanup of files

AI-Assisted: significant portions of this code were AI-generated through a dozens of iterative prompts.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@batrick
batrick requested a review from a team January 21, 2026 18:28
@batrick
batrick requested a review from a team as a code owner January 21, 2026 18:39
@batrick

batrick commented Jan 21, 2026

Copy link
Copy Markdown
Member Author

Comment thread doc/cephfs/cephfs-tool.rst Resolved
Comment thread doc/cephfs/cephfs-tool.rst Resolved
@batrick
batrick force-pushed the cephfs-bench branch 2 times, most recently from 95e82da to b834547 Compare January 22, 2026 12:45
@batrick

batrick commented Jan 22, 2026

Copy link
Copy Markdown
Member Author

jenkins test make check

@batrick

batrick commented Jan 22, 2026

Copy link
Copy Markdown
Member Author

jenkins test make check arm64

@batrick

batrick commented Jan 22, 2026

Copy link
Copy Markdown
Member Author

jenkins test api

@github-actions github-actions Bot added the tests label Jan 23, 2026
@batrick
batrick force-pushed the cephfs-bench branch 2 times, most recently from bd55c42 to 3151eae Compare January 23, 2026 20:51
}

double elapsed_sec = duration_cast<milliseconds>(end_time - start_time).count() / 1000.0;
double w_rate = (double)total_write_bytes / 1024.0 / 1024.0 / elapsed_sec;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could a very fast test result in elapsed_sec == 0?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it's pretty unlikely to be exactly 0. In any case, it would be harmless as w_rate would just be an erroneous value of +inf.

@vshankar

Copy link
Copy Markdown
Contributor

This is a nice addition 👍

I will do a detailed review shortly, so, I am posting couple of things that come up seeing this

  • Should we just call the tool cephfs-bench? cephfs-tool is nice, but I want to avoid any kind of confusion with offline tools (cephfs-journal-tool, etc..). The tool introduced here has a bench param, but I want to be more explicit in naming.
  • What do you think about running this with qa suite, maybe, when we are cutting release so as to catch any client/mds side perf regression that might have sneaked in?

@batrick

batrick commented Feb 23, 2026

Copy link
Copy Markdown
Member Author

This is a nice addition 👍

I will do a detailed review shortly, so, I am posting couple of things that come up seeing this

* Should we just call the tool cephfs-bench? cephfs-tool is nice, but I want to avoid any kind of confusion with offline tools (cephfs-journal-tool, etc..). The tool introduced here has a bench param, but I want to be more explicit in naming.

I chose this name to somewhat mirror what rados is doing. Instead of continuing to add more "tools" I felt it'd be better to have a swiss-army knife tool (but not for data recovery).

For example, I foresee this would be an appropriate location for:

  • Initiating and monitoring scrubs (rather than using the tell interface)
  • Certain performance analysis of the MDS(s)
  • A potential alternative to cephfs-shell for some admin operations (no python)
* What do you think about running this with qa suite, maybe, when we are cutting release so as to catch any client/mds side perf regression that might have sneaked in?

Sure

@batrick

batrick commented Feb 23, 2026

Copy link
Copy Markdown
Member Author

jenkins test api

@bill-scales

Copy link
Copy Markdown
Contributor

Should we just call the tool cephfs-bench? cephfs-tool is nice, but I want to avoid any kind of confusion with offline tools (cephfs-journal-tool, etc..).

The tool introduced here has a bench param, but I want to be more explicit in naming. I chose this name to somewhat mirror what rados is doing. Instead of continuing to add more "tools" I felt it'd be better to have a swiss-army knife tool (but not for data recovery).

How about just calling it "cephfs"? That would match the convention of the "rbd" and "rados" commands

@anthonyeleven

Copy link
Copy Markdown
Contributor

How about just calling it "cephfs"? That would match the convention of the "rbd" and "rados" commands

We already have commands of the form "ceph fs", IMHO this would be confusing and prone to error.

Now, if it were integrated into the CLI as "ceph fs" subcommands....

batrick added 2 commits April 14, 2026 08:48
This patch introduces `cephfs-tool`, a new standalone C++ utility
designed to interact directly with `libcephfs`.

While the tool is architected to support various subcommands in the
future, the initial implementation focuses on a `bench` command to
measure library performance. This allows developers and administrators
to benchmark the userspace library isolated from FUSE or Kernel client
overheads.

Key features include:
* Multi-threaded Read/Write throughput benchmarking.
* Configurable block sizes, file counts, and fsync intervals.
* Detailed statistical reporting (Mean, Std Dev, Min/Max) for throughput and IOPS.
* Support for specific CephFS user/group impersonation (UID/GID) via `ceph_mount_perms_set`.

As an example test on a "trial" sepia machine against the new LRC, I
used a command like:

    pdonnell@trial154:~$ env CEPH_ARGS="--log-to-stderr=false --log-to-file=false --log-file=/tmp/bench.log" ./cephfs-tool -c ~/ceph.conf -k ~/keyring -i scratch --filesystem scratch  bench --root-path=/pdonnell --files 256 --size=$(( 128 * 2 ** 20 )) --threads=8 --iterations 3
    Benchmark Configuration:
      Threads: 8 | Iterations: 3
      Files: 256 | Size: 134217728
      Filesystem: scratch
      Root: /pdonnell
      Subdirectory: bench_run_d942
      UID: -1
      GID: -1

    --- Iteration 1 of 3 ---
    Starting Write Phase...
      Write: 2761.97 MB/s, 21.5779 files/s (11.864s)
    Starting Read Phase...
      Read:  2684.36 MB/s, 20.9716 files/s (12.207s)

    --- Iteration 2 of 3 ---
    Starting Write Phase...
      Write: 2698.51 MB/s, 21.0821 files/s (12.143s)
    Starting Read Phase...
      Read:  2682.16 MB/s, 20.9544 files/s (12.217s)

    --- Iteration 3 of 3 ---
    Starting Write Phase...
      Write: 2720.69 MB/s, 21.2554 files/s (12.044s)
    Starting Read Phase...
      Read:  2695.18 MB/s, 21.0561 files/s (12.158s)

    *** Final Report ***

    Write Throughput Statistics (3 runs):
      Mean:    2727.06 MB/s
      Std Dev: 26.2954 MB/s
      Min:     2698.51 MB/s
      Max:     2761.97 MB/s

    Read Throughput Statistics (3 runs):
      Mean:    2687.24 MB/s
      Std Dev: 5.68904 MB/s
      Min:     2682.16 MB/s
      Max:     2695.18 MB/s

    File Creates Statistics (3 runs):
      Mean:    21.3051 files/s
      Std Dev: 0.205433 files/s
      Min:     21.0821 files/s
      Max:     21.5779 files/s

    File Reads (Opens) Statistics (3 runs):
      Mean:    20.994 files/s
      Std Dev: 0.0444456 files/s
      Min:     20.9544 files/s
      Max:     21.0561 files/s

    Cleaning up...

For a 25Gb NIC, this is just about saturating the sticker bandwidth with
a single shared mount and 8 threads. For a per-thread mount:

    pdonnell@trial154:~$ env CEPH_ARGS="--log-to-stderr=false --log-to-file=false --log-file=/tmp/bench.log" ./cephfs-tool -c ~/ceph.conf -k ~/keyring -i scratch --filesystem scratch  bench --root-path=/pdonnell --files 256 --size=$(( 128 * 2 ** 20 )) --threads=8 --iterations 3 --per-thread-mount
    Benchmark Configuration:
      Threads: 8 | Iterations: 3
      Files: 256 | Size: 134217728
      Filesystem: scratch
      Root: /pdonnell
      Subdirectory: bench_run_9d1c
      UID: -1
      GID: -1

    --- Iteration 1 of 3 ---
    Starting Write Phase...
      Write: 2691.2 MB/s, 21.025 files/s (12.176s)
    Starting Read Phase...
      Read:  2486.76 MB/s, 19.4278 files/s (13.177s)

    --- Iteration 2 of 3 ---
    Starting Write Phase...
      Write: 2688.77 MB/s, 21.006 files/s (12.187s)
    Starting Read Phase...
      Read:  2496.42 MB/s, 19.5033 files/s (13.126s)

    --- Iteration 3 of 3 ---
    Starting Write Phase...
      Write: 2692.08 MB/s, 21.0319 files/s (12.172s)
    Starting Read Phase...
      Read:  2488.27 MB/s, 19.4396 files/s (13.169s)
    *** Final Report ***

    Write Throughput Statistics (3 runs):
      Mean:    2690.68 MB/s
      Std Dev: 1.40086 MB/s
      Min:     2688.77 MB/s
      Max:     2692.08 MB/s

    Read Throughput Statistics (3 runs):
      Mean:    2490.48 MB/s
      Std Dev: 4.24374 MB/s
      Min:     2486.76 MB/s
      Max:     2496.42 MB/s

    File Creates Statistics (3 runs):
      Mean:    21.0209 files/s
      Std Dev: 0.0109442 files/s
      Min:     21.006 files/s
      Max:     21.0319 files/s

    File Reads (Opens) Statistics (3 runs):
      Mean:    19.4569 files/s
      Std Dev: 0.0331542 files/s
      Min:     19.4278 files/s
      Max:     19.5033 files/s

    Cleaning up...

Or to measure file create performance:

    pdonnell@trial154:~$ env CEPH_ARGS="--log-to-stderr=false --log-to-file=false --log-file=/tmp/bench.log" ./cephfs-tool -c ~/ceph.conf -k ~/keyring -i scratch --filesystem scratch  bench --root-path=/pdonnell --files=$(( 2 ** 16 )) --size=$(( 0 * 2 ** 20 )) --threads=8 --iterations 3
    Benchmark Configuration:
      Threads: 8 | Iterations: 3
      Files: 65536 | Size: 0
      Filesystem: scratch
      Root: /pdonnell
      Subdirectory: bench_run_d435
      UID: -1
      GID: -1

    --- Iteration 1 of 3 ---
    Starting Write Phase...
      Write: 3974.77 files/s (16.488s)
    Starting Read Phase...
      Read:  14537.7 files/s (4.508s)
    Cleaning up for next iteration...

    --- Iteration 2 of 3 ---
    Starting Write Phase...
      Write: 4167.1 files/s (15.727s)
    Starting Read Phase...
      Read:  13636.3 files/s (4.806s)
    Cleaning up for next iteration...

    --- Iteration 3 of 3 ---
    Starting Write Phase...
      Write: 3863.7 files/s (16.962s)
    Starting Read Phase...
      Read:  14972.8 files/s (4.377s)

    *** Final Report ***

    File Creates Statistics (3 runs):
      Mean:    4001.86 files/s
      Std Dev: 125.337 files/s
      Min:     3863.7 files/s
      Max:     4167.1 files/s

    File Reads (Opens) Statistics (3 runs):
      Mean:    14382.3 files/s
      Std Dev: 556.594 files/s
      Min:     13636.3 files/s
      Max:     14972.8 files/s

    Cleaning up...

Here is the current help text:

    Usage: cephfs-bench [general-options] <command> [command-options]

    Commands:
      bench      Run IO benchmark

    Allowed options:

    General Options:
      -h [ --help ]                   Produce help message
      -c [ --conf ] arg               Ceph config file path
      -i [ --id ] arg (=admin)        Client ID
      -k [ --keyring ] arg            Path to keyring file
      --filesystem arg                CephFS filesystem name to mount
      --uid arg (=-1)                 User ID to mount as
      --gid arg (=-1)                 Group ID to mount as

    Benchmark Options (used with 'bench' command):
      --threads arg (=1)              Number of threads
      --iterations arg (=1)           Number of iterations
      --files arg (=100)              Total number of files
      --size arg (=4MB)               File size (e.g. 4MB, 0 for creates only)
      --block-size arg (=4MB)         IO block size (e.g. 1MB)
      --fsync-every arg (=0)          Call fsync every N bytes
      --prefix arg (=benchmark_)      Filename prefix
      --dir-prefix arg (=bench_run_)  Directory prefix
      --root-path arg (=/)            Root path in CephFS
      --per-thread-mount              Use separate mount per thread
      --no-cleanup                    Disable cleanup of files

AI-Assisted: significant portions of this code were AI-generated through a dozens of iterative prompts.
Signed-off-by: Patrick Donnelly <[email protected]>
AI-Assisted: this doc was generated from the help text / inital commit memssage
Signed-off-by: Patrick Donnelly <[email protected]>
@batrick

batrick commented Apr 14, 2026

Copy link
Copy Markdown
Member Author

(trivial rebase)

@batrick

batrick commented Apr 14, 2026

Copy link
Copy Markdown
Member Author

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fantastic ❤️

@batrick
batrick merged commit 49753d2 into ceph:main Apr 15, 2026
6 checks passed
@batrick
batrick deleted the cephfs-bench branch April 15, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants