Page MenuHomeFreeBSD

Gather writes to larger chunks (MAXPHYS) instead of issuing them in sectors.
ClosedPublic

Authored by delphij on Apr 20 2020, 12:01 AM.

Details

Summary

Gather writes to larger chunks (MAXPHYS) instead of issuing them in
sectors.

On my SanDisk Cruzer Blade 16GB USB stick this made formatting much faster:

x before
+ after
+--------------------------------------------------------------------------+
|+                                                                         |
|+                                                                      x  |
|+                                                                      x x|
|A                                                                      MA||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         15.89         16.38            16         16.09     0.2570992
+   3          0.32          0.37          0.35    0.34666667   0.025166115
Difference at 95.0% confidence
        -15.7433 +/- 0.414029
        -97.8455% +/- 0.25668%
        (Student's t, pooled s = 0.182665)

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Tested on a hard drive; this reduced the time for format by 2/3:

x before
+ after
+------------------------------------------------------------+
|+++                                                       xx|
||A|                                                       AM|
+------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3          7.24          7.33          7.29     7.2866667   0.045092498
+   3          2.36          2.49           2.4     2.4166667   0.066583281
Difference at 95.0% confidence
	-4.87 +/- 0.128884
	-66.8344% +/- 1.50101%
	(Student's t, pooled s = 0.0568624)
sbin/newfs_msdos/mkfs_msdos.c
759–760 ↗(On Diff #70794)

This requires that MAXPHYS % bpb.bpbBytesPerSec == 0 right? Do we check that anywhere?

delphij added inline comments.
sbin/newfs_msdos/mkfs_msdos.c
759–760 ↗(On Diff #70794)

No, but bpbBytesPerSec has to be greater than the buffer size (I don't think that would ever happen, though).

delphij marked an inline comment as done.

Round down chunksize if it's not fully aligned.

Instead of padding the buffer, assert that they always fit as the specification requires
sector size to be one of 512, 1024, 2048 or 4096 bytes.

ministat graph for time savings.

x before
+ after
+--------------------------------------------------------------------------+
|+                                                                         |
|+                                                                      x  |
|+                                                                      x x|
|A                                                                      MA||
+--------------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   3         15.89         16.38            16         16.09     0.2570992
+   3          0.32          0.37          0.35    0.34666667   0.025166115
Difference at 95.0% confidence
	-15.7433 +/- 0.414029
	-97.8455% +/- 0.25668%
	(Student's t, pooled s = 0.182665)
This revision is now accepted and ready to land.Jul 4 2020, 3:22 PM