You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Increased dirty_background_ratio and vm_dirty_ratio makes file transfers less accurate #81
As the default values for dirty_background_ratio and vm_dirty_ratio are increased, the file transfers on Gnome (and probably KDE) are very inaccurate as the transfer bar is much more likely to just show the file being copied to memory. It hangs at the end of the transfer during the time that the file is actually being copied to the disk (it does actually hang for few minutes while copying a 1.6 GB file on my system)
The patch is setting vm_dirty_ratio to 50%, which means that if you have 8 GB of RAM it could be 4 GB, which seems way too high imo. Similarly, dirty_background_ratio is set to 20%, which is 1.6 GB.
I think vm_*_ratio options shouldn't be used on today's systems as default. They seem better left to machines with less then a gig of ram.
This goes double for zen since it's supposed to be more desktop focused.
My personal system runs this at init.
# The percentage of total system memory at which ALL dirty pages must be
# commited to disk. Writes after this will block until pdflush is done
##echo 24 > /proc/sys/vm/dirty_ratio
# The percentage of total system memory that can be filled with dirty pages
# waiting to be written to disk by pdflush. Triggering this will not block new writes.
##echo 6 > /proc/sys/vm/dirty_background_ratio
# Both can be instead set bytes
echo $((256*1024*1024)) > /proc/sys/vm/dirty_bytes
echo $((64*1024*1024)) > /proc/sys/vm/dirty_background_bytes
# how long something can be in cache before it needs to be written (2300/100=23s)
echo 2300 > /proc/sys/vm/dirty_expire_centisecs
# how often the kernel wakes up and check to see if work needs to be done
echo 700 > /proc/sys/vm/dirty_writeback_centisecs
There is nothing that can be done to solve this "bug" in Gnome and KDE. When writeback is enabled on the filesystem, the kernel writes to dirty memory and tells the application writing that it is complete. This goes for file managers as well.
The freezing you're experiencing is not freezing, it's the application not being told that writing is done and it sits at 100% until the filesystem is synced. This would be a bug in KDE and Gnome, not a bug in the kernel. For instance, you can copy a large 10gb file on your filesystem to another drive that's slower and the "cp" command will complete. However, if you check iotop or your hard drive light, you will see that it's still writing. You can determine that it's complete by executing the "sync" command and waiting for this command to complete.
This behavior has been in the kernel since writeback was introduced. If you don't want it, you can pick a filesystem that doesn't use writeback. I think that ext4 in ordered mode is more what you're looking for.
And regarding weedy's comment. You can reduce the dirty ratio, but it just begins writes earlier that block the application performing writes, increasing IO wait. With the recent merge for writeback throttling, this will only increase the frequency that you will notice an application performing heavy IO, stall visibly.
Various posts I can find on the lkml actually claim that lower values are better for desktop, and some people seem to get more responsiveness issues with highest values.
This is a general issue with the synchronous IO interface. You can either keep writing to a file and sync at the end, or sync after every write. If you do the latter, you sacrifice a lot of throughput because can't issue further writes to a file while waiting for it to sync.
To solve this properly the kernel would need an IO queue interface of some sort, where the application can be asynchronously notified of intermediate completions.
In any case I think lowering the writeback limits risks throughput too much. 128M/256M was okay for my 840 Pro, but may not be fine on a system with NVMe SSDs.
On the other hand, I don't think we gain much by raising it beyond the default values, either.
In any case I think lowering the writeback limits risks throughput too much. 128M/256M was okay for my 840 Pro, but may not be fine on a system with NVMe SSDs.
And what was the throughput on your 840 Pro? I don't think someone running NVMe is going to immediately cry foul of getting whatever saturated SATA3 MiB/s is. NVMe is super new, no shit you might need to tweak things to get the max throughput/IOPS out of it.
On the flip side systems grinding to a halt because buffers are too full for spinning rust to keep up IS a problem we should look at. Zen started back when what? P4s were new? Zen started because linux mainline tried to be balanced (and still tries to be) for all things. And that includes multi-socket systems with hardware RAID'ed SAS drives. Zen was needed because dinky $500-$800 laptops back then had 5400RPM drives and line no RAM, and life was hard.
I have sandbridge and newer systems, I don't bother putting Zen on them. A couple sysctl tweaks picked out from Zen sources and they run just fine on distro kernels. Hardware has gotten fast enough. I put Zen on older stuff, early i3s, core2, even a P4. There I need EVERY ounce of perf Zen can give me.
And on all of them I use vm_bytes instead of vm_ratio.
I think vm_*_ratio is dumb considering what our user base probably is, and double dumb with how much ZEN_INTERACTIVE raises it. We might need a ZEN_INTERACTIVE_SPIN_RUST where we don't use _ratio and then we can raise (or revert to default) the block queue depth tweaks for people with SSDs.
I think it's easy to underestimate how much writeback really improves performance. A great example is that you're working on a large git project and changing branches incurs a large amount of writes. Yes, your SSD may be super fast, even on a SATA port, but at the end of the day, your system can write and change data faster than your system can output and then write to the SSD.
This brings us back to interactivity. It seems obvious that reducing write buffers will improve interactivity but it's quite the opposite. By having a larger writeback, the application writing data is notified that writing is complete before data is synced to the drive. In fact, it's being written back to (thus writeback), after it's cached in memory. The larger your writeback, the less you rely on the write speed of your drive.
Jens Axboe took the approach that's familiar in fq_codel for QoS with networking in the ethernet buffer. As soon as latencies increase due to a burst or high throughput in one direction, reduce the throughput accordingly until the latency of other requests returns back to a certain deviation.
I understand that you have your own configuration that you've tuned specifically with your systems, but have you tried the current configuration that's available in the 4.7/master branch? We have even reduced the block queue size and NCQ depth as determined by testing to limit the stalling when a single IO device is written to at high speeds and maxes out the dirty page buffer: 574bd2e.
This is not an issue we're ignoring, but is a bug that's upstream that no tuning of the kernel will fix completely. All we can do is mitigate the issue and the current configuration is the result of both @heftig's and my research over multiple years. If you would like to contribute, we're missing measurable metrics that show how I/O latencies are affected when slow devices max out writeback buffers (the most common complaint). These types of numbers will be useful to show kernel developers that there is an issue, and a repeatable test will help them guarantee that a change to help these corner cases doesn't regress in the future.
And a final note, the user base for zen-kernel is probably not dumb. We don't advertise the sources in any sensational way that would attract ricers who would blindly apply the zen kernel patches without knowing what they're getting into. If that was our intent, we would have already configured a bootstrap homepage with flashy animations. But we're not fooling anyone, you can only tune the configuration so far before the algorithms beneath the software need to change. Thus, brought us BFQ, wb-buf-throttle, BFS if you choose to use it, and many other changes we have documented as commits to the sources.
We're always looking for anything new that can objectively improve responsiveness on desktops on laptops. If you find any configuration or patch that reliably improves performance for a large subset of hardware, we'll be happy to try it out and merge it if it works.
Writing or reading from/to a NFS server at 1Gbps produces a lot of freezes on my desktop (all xorg is completely frozen during a few seconds) with a SSD, BFQ and 16GB of RAM and linux 4.8.7.
Reducing vm.dirty_ratio to 3% and vm.dirty_background_ratio to 2% fixes the issue for me.
With some more testing, I found that the culprit was a misconfiguration of the IO schedulers when in use with writeback throttling.
BFQ / CFQ + heavy IO load = poor responsiveness and system freezes
BLK-MQ + heavy IO load = responsive system but new read requests on drives being written to are be delayed until after writing.
BFQ / CFQ + hierarchical scheduling + heavy IO load = responsive system, occasional blip every 30-120 seconds depending on the data being read / written, but completely usable otherwise. I believe this is writeback throttling kicking and each delay that's noticable is also it tuning the writeback speed to not interrupt the rest of the system. I don't believe there's a workaround to this until BFQ is ported to blk-mq (which Paolo mentioned may happen in the next few months).
Best configuration:
CONFIG_BLK_CGROUP=y
CONFIG_CGROUP_WRITEBACK=y
CONFIG_IOSCHED_CFQ=y
CONFIG_CFQ_GROUP_IOSCHED=y
CONFIG_IOSCHED_BFQ=y
CONFIG_BFQ_GROUP_IOSCHED=y
CONFIG_DEFAULT_BFQ=y
# CONFIG_SCSI_MQ_DEFAULT is not set
This is all with the zen-tune configuration, 20% dirty_background_ratio, 50% dirty_ratio.
Test procedure:
Store 100gb of data on /source/on/ssd
For rotational disk 1, execute: rsync -a /source/on/ssd /target/on/rotational1
For rotational disk 2, execute: rsync -a /source/on/ssd /target/on/rotational2
Unless there's any objections, I'll close this issue in the next week.
EDIT: Also committed the following change that increase the max requests in flight to a block to 512 by default (from 32). This completely eliminates the stalls as mentioned above: 3b26688
Activity
weedy commentedon Aug 26, 2016
I think vm_*_ratio options shouldn't be used on today's systems as default. They seem better left to machines with less then a gig of ram.
This goes double for zen since it's supposed to be more desktop focused.
My personal system runs this at init.
damentz commentedon Aug 26, 2016
There is nothing that can be done to solve this "bug" in Gnome and KDE. When writeback is enabled on the filesystem, the kernel writes to dirty memory and tells the application writing that it is complete. This goes for file managers as well.
The freezing you're experiencing is not freezing, it's the application not being told that writing is done and it sits at 100% until the filesystem is synced. This would be a bug in KDE and Gnome, not a bug in the kernel. For instance, you can copy a large 10gb file on your filesystem to another drive that's slower and the "cp" command will complete. However, if you check iotop or your hard drive light, you will see that it's still writing. You can determine that it's complete by executing the "sync" command and waiting for this command to complete.
This behavior has been in the kernel since writeback was introduced. If you don't want it, you can pick a filesystem that doesn't use writeback. I think that ext4 in ordered mode is more what you're looking for.
And regarding weedy's comment. You can reduce the dirty ratio, but it just begins writes earlier that block the application performing writes, increasing IO wait. With the recent merge for writeback throttling, this will only increase the frequency that you will notice an application performing heavy IO, stall visibly.
AnAkkk commentedon Aug 26, 2016
Various posts I can find on the lkml actually claim that lower values are better for desktop, and some people seem to get more responsiveness issues with highest values.
heftig commentedon Aug 26, 2016
This is a general issue with the synchronous IO interface. You can either keep writing to a file and sync at the end, or sync after every write. If you do the latter, you sacrifice a lot of throughput because can't issue further writes to a file while waiting for it to sync.
To solve this properly the kernel would need an IO queue interface of some sort, where the application can be asynchronously notified of intermediate completions.
In any case I think lowering the writeback limits risks throughput too much. 128M/256M was okay for my 840 Pro, but may not be fine on a system with NVMe SSDs.
On the other hand, I don't think we gain much by raising it beyond the default values, either.
weedy commentedon Aug 31, 2016
And what was the throughput on your 840 Pro? I don't think someone running NVMe is going to immediately cry foul of getting whatever saturated SATA3 MiB/s is. NVMe is super new, no shit you might need to tweak things to get the max throughput/IOPS out of it.
On the flip side systems grinding to a halt because buffers are too full for spinning rust to keep up IS a problem we should look at. Zen started back when what? P4s were new? Zen started because linux mainline tried to be balanced (and still tries to be) for all things. And that includes multi-socket systems with hardware RAID'ed SAS drives. Zen was needed because dinky $500-$800 laptops back then had 5400RPM drives and line no RAM, and life was hard.
I have sandbridge and newer systems, I don't bother putting Zen on them. A couple sysctl tweaks picked out from Zen sources and they run just fine on distro kernels. Hardware has gotten fast enough. I put Zen on older stuff, early i3s, core2, even a P4. There I need EVERY ounce of perf Zen can give me.
And on all of them I use vm_bytes instead of vm_ratio.
I think vm_*_ratio is dumb considering what our user base probably is, and double dumb with how much ZEN_INTERACTIVE raises it. We might need a ZEN_INTERACTIVE_SPIN_RUST where we don't use _ratio and then we can raise (or revert to default) the block queue depth tweaks for people with SSDs.
damentz commentedon Aug 31, 2016
I think it's easy to underestimate how much writeback really improves performance. A great example is that you're working on a large git project and changing branches incurs a large amount of writes. Yes, your SSD may be super fast, even on a SATA port, but at the end of the day, your system can write and change data faster than your system can output and then write to the SSD.
This brings us back to interactivity. It seems obvious that reducing write buffers will improve interactivity but it's quite the opposite. By having a larger writeback, the application writing data is notified that writing is complete before data is synced to the drive. In fact, it's being written back to (thus writeback), after it's cached in memory. The larger your writeback, the less you rely on the write speed of your drive.
There is no situation that increasing writeback will reduce performance or reduce interactivity. Reducing the size of the dirty ratio will only cause stalls on the application that is currently writing, preventing it from returning quickly. Yes, there's been a bug in the kernel for a while (or lack of a mitigation), where if the dirty pages max out, the system appears to stall because an application that affects the UI is unable to write new data. That should be solved with the new feature merged as wb-buf-throttle: https://github.com/zen-kernel/zen-kernel/tree/4.7/wb-buf-throttle | https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git/log/?h=wb-buf-throttle | https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git/log/?h=wb-buf-throttle-v4.7.
Jens Axboe took the approach that's familiar in fq_codel for QoS with networking in the ethernet buffer. As soon as latencies increase due to a burst or high throughput in one direction, reduce the throughput accordingly until the latency of other requests returns back to a certain deviation.
I understand that you have your own configuration that you've tuned specifically with your systems, but have you tried the current configuration that's available in the 4.7/master branch? We have even reduced the block queue size and NCQ depth as determined by testing to limit the stalling when a single IO device is written to at high speeds and maxes out the dirty page buffer: 574bd2e.
This is not an issue we're ignoring, but is a bug that's upstream that no tuning of the kernel will fix completely. All we can do is mitigate the issue and the current configuration is the result of both @heftig's and my research over multiple years. If you would like to contribute, we're missing measurable metrics that show how I/O latencies are affected when slow devices max out writeback buffers (the most common complaint). These types of numbers will be useful to show kernel developers that there is an issue, and a repeatable test will help them guarantee that a change to help these corner cases doesn't regress in the future.
And a final note, the user base for zen-kernel is probably not dumb. We don't advertise the sources in any sensational way that would attract ricers who would blindly apply the zen kernel patches without knowing what they're getting into. If that was our intent, we would have already configured a bootstrap homepage with flashy animations. But we're not fooling anyone, you can only tune the configuration so far before the algorithms beneath the software need to change. Thus, brought us BFQ, wb-buf-throttle, BFS if you choose to use it, and many other changes we have documented as commits to the sources.
We're always looking for anything new that can objectively improve responsiveness on desktops on laptops. If you find any configuration or patch that reliably improves performance for a large subset of hardware, we'll be happy to try it out and merge it if it works.
weedy commentedon Sep 11, 2016
I did not see that you merged wb-buf-throttle into 4.7. That's really cool. I wonder if this explains why ntfs-3g brings my system to a crawl now.
I know about block queue and NCQ killing interactivity under multi user/program load. I've had that tweaked for ages.
I guess if you guys are sure about your decisions this can be closed?
net/irda: handle iriap_register_lsap() allocation failure
aruhier commentedon Nov 15, 2016
Writing or reading from/to a NFS server at 1Gbps produces a lot of freezes on my desktop (all xorg is completely frozen during a few seconds) with a SSD, BFQ and 16GB of RAM and linux 4.8.7.
Reducing
vm.dirty_ratioto 3% andvm.dirty_background_ratioto 2% fixes the issue for me.weedy commentedon Nov 15, 2016
@Anthony25 look at using _bytes
aruhier commentedon Nov 15, 2016
@weedy: Ok, thanks!
damentz commentedon Nov 21, 2016
With some more testing, I found that the culprit was a misconfiguration of the IO schedulers when in use with writeback throttling.
Best configuration:
This is all with the zen-tune configuration, 20% dirty_background_ratio, 50% dirty_ratio.
Test procedure:
Store 100gb of data on /source/on/ssd
For rotational disk 1, execute: rsync -a /source/on/ssd /target/on/rotational1
For rotational disk 2, execute: rsync -a /source/on/ssd /target/on/rotational2
Unless there's any objections, I'll close this issue in the next week.
EDIT: Also committed the following change that increase the max requests in flight to a block to 512 by default (from 32). This completely eliminates the stalls as mentioned above: 3b26688
crypto: talitos - fix Kernel Oops on hashing an empty file
crypto: talitos - fix Kernel Oops on hashing an empty file
1 remaining item
dccp: initialize ireq->ir_mark
ipv4: fix uninit-value in ip_route_output_key_hash_rcu()
bpf: sockmap, restore sk_write_space when psock gets dropped
media: vim2m: Fix BUG_ON in vim2m_device_release()
scsi: target: fix hang when multiple threads try to destroy the same …
scsi: target: fix hang when multiple threads try to destroy the same …
btrfs: fix warning when creating a directory with smack enabled
wifi: mac80211: fix memory corruption in minstrel_ht_update_rates()
LoongArch: BPF: Fix sign-extension mov instructions
bpftool: Fix missing pids during link show
bpftool: Fix missing pids during link show
mm/pagewalk: fix usage of pmd_leaf()/pud_leaf() without present check
LoongArch: BPF: Optimize sign-extention mov instructions