Thread (13 messages) 13 messages, 5 authors, 2016-05-27

Re: Major HDD performance degradation on btrfs receive

From: Nazar Mokrynskyi <hidden>
Date: 2016-03-16 03:37:07

It could also be that the disk is bit older and has or is starting to
use its spare sectors.
I do not really think HDD is that old. I've got it brand new less than 
year ago. Here is smartctl output:
nazar-pc@nazar-pc ~> sudo smartctl -a /dev/sda
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.5.0-haswell] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, 
www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Seagate Samsung SpinPoint M9T
Device Model:     ST2000LM003 HN-M201RAD
Serial Number:    S34RJ9CF727799
LU WWN Device Id: 5 0004cf 20dbc7ec5
Firmware Version: 2BC10004
User Capacity:    2 000 398 934 016 bytes [2,00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ATA8-ACS T13/1699-D revision 6
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Wed Mar 16 01:25:17 2016 EET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00)    Offline data collection 
activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0)    The previous self-test 
routine completed
                    without error or no self-test has ever
                    been run.
Total time to complete Offline
data collection:         (23760) seconds.
Offline data collection
capabilities:              (0x5b) SMART execute Offline immediate.
                    Auto Offline data collection on/off support.
                    Suspend Offline collection upon new
                    command.
                    Offline surface scan supported.
                    Self-test supported.
                    No Conveyance Self-test supported.
                    Selective Self-test supported.
SMART capabilities:            (0x0003)    Saves SMART data before 
entering
                    power-saving mode.
                    Supports SMART auto save timer.
Error logging capability:        (0x01)    Error logging supported.
                    General Purpose Logging supported.
Short self-test routine
recommended polling time:      (   1) minutes.
Extended self-test routine
recommended polling time:      ( 396) minutes.
SCT capabilities:            (0x003f)    SCT Status supported.
                    SCT Error Recovery Control supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      
UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x002f   100   100   051 Pre-fail  
Always       -       16
  2 Throughput_Performance  0x0026   252   252   000 Old_age   
Always       -       0
  3 Spin_Up_Time            0x0023   088   086   025 Pre-fail  
Always       -       3760
  4 Start_Stop_Count        0x0032   100   100   000 Old_age   
Always       -       840
  5 Reallocated_Sector_Ct   0x0033   252   252   010 Pre-fail  
Always       -       0
  7 Seek_Error_Rate         0x002e   252   252   051 Old_age   
Always       -       0
  8 Seek_Time_Performance   0x0024   252   252   015 Old_age   
Offline      -       0
  9 Power_On_Hours          0x0032   100   100   000 Old_age   
Always       -       6208
 10 Spin_Retry_Count        0x0032   252   252   051 Old_age   
Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000 Old_age   
Always       -       678
191 G-Sense_Error_Rate      0x0022   100   100   000 Old_age   
Always       -       11
192 Power-Off_Retract_Count 0x0022   252   252   000 Old_age   
Always       -       0
194 Temperature_Celsius     0x0002   053   044   000 Old_age   
Always       -       47 (Min/Max 17/56)
195 Hardware_ECC_Recovered  0x003a   100   100   000 Old_age   
Always       -       0
196 Reallocated_Event_Count 0x0032   252   252   000 Old_age   
Always       -       0
197 Current_Pending_Sector  0x0032   252   252   000 Old_age   
Always       -       0
198 Offline_Uncorrectable   0x0030   252   252   000 Old_age   
Offline      -       0
199 UDMA_CRC_Error_Count    0x0036   200   200   000 Old_age   
Always       -       0
200 Multi_Zone_Error_Rate   0x002a   100   100   000 Old_age   
Always       -       20
223 Load_Retry_Count        0x0032   100   100   000 Old_age   
Always       -       7
225 Load_Cycle_Count        0x0032   100   100   000 Old_age   
Always       -       7035

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 0
Note: revision number not 1 implies that no selective self-test has 
ever been run
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Completed [00% left] (0-65535)
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute 
delay.
gnome-disks says it worked 15 days and 8 minutes
I also almost never look at the backups, and when I do, indeed scanning
through a 1000 snapshots fs on spinning disk takes time. If a script
does that every 15mins, and the fs uses LZO compression and there is
another active partition then you will have to deal with the slowness.
Well, it is not that bad and hard in reality. Every 15 minutes I'm 
transfering 3 diffs. Right now HDD contains 453 subvolumes totally, 34% 
of 359 GiB partition space used. After writing last message I've decided 
to collect diffs for further analysis.

So /home subvolume's diffs ranging from 6 to 270 MiB. Typically 30-40 MiB.

/root subvolume's diffs ranging from 10 KiB to 380 MiB (during software 
updates). Typically 40-80 KiB.

/web (source code here) subvolume's diffs ranging from bytes to 1 MiB, 
typically 150 KiB.

So generally when I'm watching movie or playing some game (not changing 
source code, not updating software and not doing anything that might 
cause significant changes in /home subvolume) I'll get about 30 MiB of 
diff in total. This is not that much for SATA3 HDD, it shouldn't stuck 
for some seconds when everything is so slow that video stops completely 
for few seconds.

Maybe BTRFS construction requires this small diff to make a big party 
all over HDD, I don't know, but there is some problem here for sure.
You could adapt the script or backup method not to search every time,
but to just write the next diff send|receive and only step back and
search if this fails.

Or keeping more 15min snapshots only on SSD and lower the rate of
send|receive them to HDD
I'm not sure what you mean exactly by searching. My first SSD died 
during waking up from suspend mode, it worked perfectly till last 
moment. It was not used for critical data at that time, but now I 
understand clearly that SSD failure can happen at any time. Having RAID0 
of 2 SSDs it 2 times more risky, so I'm not ready to lose anything 
beyond 15 minutes threshold. I'd rather end up having another HDD purely 
for backup purposes.


Interesting question: is there any tool to see the whole picture about 
how btrfs partition is fragmented? I saw many tools for NTFS on Windows 
that show nice picture, but not for Linux filesystems. Saw answer on 
StackOverlow about fsck, but btrfsck doesn't provide similar output.

Also, I can't really run defragmentation anyway since all backups are 
read-only.

Sincerely, Nazar Mokrynskyi
github.com/nazar-pc
Skype: nazar-pc
Diaspora: nazarpc@diaspora.mokrynskyi.com
Tox: A9D95C9AA5F7A3ED75D83D0292E22ACE84BA40E912185939414475AF28FD2B2A5C8EF5261249

On 16.03.16 01:11, Henk Slager wrote:
On Tue, Mar 15, 2016 at 1:47 AM, Nazar Mokrynskyi [off-list ref] wrote:
quoted
Some update since last time (few weeks ago).

All filesystems are mounted with noatime, I've also added mounting
optimization - so there is no problem with remounting filesystem every time,
it is done only once.

Remounting optimization helped by reducing 1 complete snapshot +
send/receive cycle by some seconds, but otherwise it is still very slow when
`btrfs receive` is active.
OK, great that the umount+mount is gone. I think most time is
unfortunately spent in seeks; I think over time and due to various
factors, both free space and files are highly fragmented on your disk.
It could also be that the disk is bit older and has or is starting to
use its spare sectors.
quoted
I'm not considering bcache + btrfs as potential setup because I do not
currently have free SSD for it and basically spending SSD besides HDD for
backup partition feels like a bit of overkill (especially for desktop use).
Yes I think so too; For backup, I am also a bit reluctant to use
bcache. But the big difference is that you do a snapshot transfer
every 15minute while I do that only every 24hour. So I almost dont
care how long the send|receive takes in the middle of the night. I
also almost never look at the backups, and when I do, indeed scanning
through a 1000 snapshots fs on spinning disk takes time. If a script
does that every 15mins, and the fs uses LZO compression and there is
another active partition then you will have to deal with the slowness.
And if the files are mostly small, like source-trees, it gets even
worse. So it is about 100x more creates+deletes of subvolumes. To be
honest, it is just requiring too much from a HDD I think, knowing that
btrfs is CoW. On a fresh fs it might work OK in the beginning, but
over time...

You could adapt the script or backup method not to search every time,
but to just write the next diff send|receive and only step back and
search if this fails.

Or keeping more 15min snapshots only on SSD and lower the rate of
send|receive them to HDD

Another thing you could do is skip the receive step; So just pipe the
15min snapshot diff to a stream file and just leave it on the backup
HDD until you need files from the backup. Only then do a series of
incremental receives of the streams. An every now and then a full
(non-incremental) send.
quoted
My current kernel is 4.5.0 stable, btrfs-tools still 4.4-1 from Ubuntu 16.04
repository as of today.

As I'm reading mailing list there are other folks having similar performance
issues. So can we debug things to find the root cause and fix it at some
point?
Indeed there are multiple reports with similar symptoms. I think it is
not really that one should see it as an error or root cause or some
fault. It is further optimization and then specifically for harddisks.
Or implementing additional concepts just for harddisks. For (parity)
RAID (by btrfs itself, not DM or MD etc), one can exploit parallelism,
but it is not trivial to get that fully optimized for all device
configurations and tasks.
quoted
My C/C++/Kernel/BTRFS knowledges are scarce, which is why some assistance
here is needed from someone more experienced.
It is all about HDD seek times in the first place. There are many
thoughts, articles and benchmarks about this over the years on the
internet, but I just found this one from last year about XFS:
https://lkml.org/lkml/2015/4/29/776
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Attachments

  • smime.p7s [application/pkcs7-signature] 3825 bytes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help