Heavy writes to USB3 SSD causing network latency spikes

Open
#3,028 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
c, linux

Research direction

Reproduce heavy writes to the USB3 SSD while monitoring SSH responsiveness and ICMP ping latency. Compare ext4 with f2fs and xfs, and test the reported vm.dirty_ratio and vm.dirty_background_ratio adjustments. The issue does not identify kernel files or tests, and completion would require determining whether the latency spikes are an actionable kernel bug.

Written by the indexing model from the issue text.

Description

While debugging my issue with a USB3-SATA controller (#3026) I found that heavy writes to an USB3 SSD are causing some kernel threads to spike the CPU and increase network latency, which is observable because of the noticeable lag in the SSH session and can be confirmed with an ICMP ping.

I'm not exactly sure if this is a bug or normal behaviour for linux, and unfortunately I don't have similar low-power devices to test their behaviour in USB3 write-heavy situations.

The issue can be toned down a bit by adjusting vm.dirty_ratio and vm.dirty_background_ratio, however it's still significant.

What's weird is it doesn't seem to affect the network when the SSD is formatted to f2fs, and is less serious with xfs (smaller latency spikes and less frequently).

The attached screenshot shows writing to an ext4 formatted USB3 SSD. The latency spikes are not caused by an unrelated network issue, there's a gigabit ethernet link between the Pi and the computer.

System
Raspi 4 4GB with a Samsung EVO+ 64GiB micro SD.
Running the latest Raspbian system and firmware.

root@raspberrypi:~# uname -a
Linux raspberrypi 4.19.56-v7l+ #1242 SMP Wed Jun 26 17:41:03 BST 2019 armv7l GNU/Linux
root@raspberrypi:~# /opt/vc/bin/vcgencmd version
Jun 26 2019 17:42:42
Copyright (c) 2012 Broadcom
version 1186f932808ed601ddd583a30a3ce055477b1a26 (clean) (release) (start)

Screenshot

Dominant language
C
Stars
13.2k
Forks
5.5k
Avg merge
2d 21h
Merged PRs (30d)
21

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/linux

All issues in raspberrypi/linux

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.