Improve preemptive ENOSPC flushing
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest12 patches 1 replyIn review
- v312 patches 14 repliesSuperseded
- v211 patches 6 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 9 patches | 20 replies | Superseded |
Changes in v4 from the cover letter
- Added some comments.
- Updated the tracepoint for the preemptive flushing to take a bool instead of an int.
- Removed 'inline' from need_preemptive_flushing.
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/12 | btrfs: make flush_space take a enum btrfs_flush_state instead of intfs/ | +2 | 0 replies | |
| 2/12 | btrfs: add a trace point for reserve ticketsfs/ include/ | +40 | 0 replies | |
| 3/12 | btrfs: track ordered bytes instead of just dio ordered bytesfs/ fs/ fs/ +1 more | +18 | 0 replies | |
| 4/12 | btrfs: introduce a FORCE_COMMIT_TRANS flush operationfs/ fs/ include/ | +17 | 0 replies | |
| 5/12 | btrfs: improve preemptive background space flushingfs/ fs/ fs/ | +101 | 0 replies | |
| 6/12 | btrfs: rename need_do_async_reclaimfs/ | +5 | 0 replies | |
| 7/12 | btrfs: check reclaim_size in need_preemptive_reclaimfs/ | +7 | 0 replies | |
| 8/12 | btrfs: rework btrfs_calc_reclaim_metadata_sizefs/ | +20 | 0 replies | |
| 9/12 | btrfs: simplify the logic in need_preemptive_flushingfs/ | +48 | 0 replies | |
| 10/12 | btrfs: implement space clamping for preemptive flushingfs/ fs/ | +53 | 0 replies | |
| 11/12 | btrfs: adjust the flush trace point to include the sourcefs/ include/ | +18 | 0 replies | |
| 12/12 | btrfs: add a trace class for dumping the current ENOSPC statefs/ include/ | +63 | 0 replies |
Reviews trailers per patch
All 12 patches have a Reviewed-by or Acked-by.
| Patch | Nikolay Borisov |
|---|---|
| 1/12 | R-b |
| 2/12 | R-b |
| 3/12 | R-b |
| 4/12 | R-b |
| 5/12 | R-b |
| 6/12 | R-b |
| 7/12 | R-b |
| 8/12 | R-b |
| 9/12 | R-b |
| 10/12 | R-b |
| 11/12 | R-b |
| 12/12 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v4 00/12] Improve preemptive ENOSPC flushing
v3->v4:
- Added some comments.
- Updated the tracepoint for the preemptive flushing to take a bool instead of an int.
- Removed 'inline' from need_preemptive_flushing.
v2->v3:
- Added a cleanup to make sure we pass the right enum around for flush_space().
- Fixed a problem reported by a clang build where I used the wrong enum in the preemptive flushing for flush_space().
- Fixed up some nits pointed out by Nikolay.
v1->v2:
- Added a FORCE_COMMIT_TRANS flush operation so we can keep the flush_space stuff consistent and get all the normal tracepoints.
- Renamed fs_info->dio_bytes to ->ordered_bytes and changed it to count all ordered extents that were pending, not just DIO ordered extents that were pending.
- Reworked the clamping to not apply if we're not doing a lot of delalloc reservations.
- Reworked the preempt flushing loop to be more straightforward.
- Fixed the need_preemptive_flushing() helper to take into account DIO heavy workloads.
--- Original email ---
A while ago Nikolay started digging into a problem where they were seeing an around 20% regression on random writes, and he bisected it down to
btrfs: don't end the transaction for delayed refs in throttle
However this wasn't actually the cause of the problem.
This patch removed the code that would preemptively end the transactions if we were low on space. Because we had just introduced the ticketing code, this was no longer necessary and was causing a lot of transaction commits.
And in Nikolay's testing he validated this, we would see like 100x more transaction commits without that patch than with it, but the write regression clearly appeared when this patch was applied.
The root cause of this is that the transaction commits were essentially happening so quickly that we didn't end up needing to wait on space in the ENOSPC ticketing code as much, and thus were able to write pretty quickly. With this gone, we now were getting a sawtoothy sort of behavior where we'd run up, stop while we flushed metadata space, run some more, stop again etc.
When I implemented the ticketing infrastructure, I was trying to get us out of excessively flushing space because we would sometimes over create block groups, and thus short circuited flushing if we no longer had tickets. This had the side effect of breaking the preemptive flushing code, where we attempted to flush space in the background before we were forced to wait for space.
Enter this patchset. We still have some of this preemption logic sprinkled everywhere, so I've separated it out of the normal ticketed flushing code, and made preemptive flushing it's own thing.
The preemptive flushing logic is more specialized than the standard flushing logic. It attempts to flush in whichever pool has the highest usage. This means that if most of our space is tied up in pinned extents, we'll commit the transaction. If most of the space is tied up in delalloc, we'll flush delalloc, etc.
To test this out I used the fio job that Nikolay used, this needs to be adjusted so the overall IO size is at least 2x the RAM size for the box you are testing
fio --direct=0 --ioengine=sync --thread --directory=/mnt/test --invalidate=1 \
--group_reporting=1 --runtime=300 --fallocate=none --ramp_time=10 \
--name=RandomWrites-async-64512-4k-4 --new_group --rw=randwrite \
--size=2g --numjobs=4 --bs=4k --fsync_on_close=0 --end_fsync=0 \
--filename_format=FioWorkloads.\$jobnumI got the following results
misc-next: bw=13.4MiB/s (14.0MB/s), 13.4MiB/s-13.4MiB/s (14.0MB/s-14.0MB/s), io=4015MiB (4210MB), run=300323-300323msec
pre-throttling: bw=16.9MiB/s (17.7MB/s), 16.9MiB/s-16.9MiB/s (17.7MB/s-17.7MB/s), io=5068MiB (5314MB), run=300069-300069msec my patches: bw=18.0MiB/s (18.9MB/s), 18.0MiB/s-18.0MiB/s (18.9MB/s-18.9MB/s), io=5403MiB (5666MB), run=300001-300001msec
Thanks,
Josef
Josef Bacik (12):
btrfs: make flush_space take a enum btrfs_flush_state instead of int
btrfs: add a trace point for reserve tickets
btrfs: track ordered bytes instead of just dio ordered bytes
btrfs: introduce a FORCE_COMMIT_TRANS flush operation
btrfs: improve preemptive background space flushing
btrfs: rename need_do_async_reclaim
btrfs: check reclaim_size in need_preemptive_reclaim
btrfs: rework btrfs_calc_reclaim_metadata_size
btrfs: simplify the logic in need_preemptive_flushing
btrfs: implement space clamping for preemptive flushing
btrfs: adjust the flush trace point to include the source
btrfs: add a trace class for dumping the current ENOSPC state
fs/btrfs/ctree.h | 4 +- fs/btrfs/disk-io.c | 9 +- fs/btrfs/ordered-data.c | 13 +- fs/btrfs/space-info.c | 295 +++++++++++++++++++++++++++++------ fs/btrfs/space-info.h | 4 + include/trace/events/btrfs.h | 104 +++++++++++- 6 files changed, 362 insertions(+), 67 deletions(-)
Signature · 1 line
2.26.2