Page MenuHomeFreeBSD

Change blist_alloc()'s allocation policy from first-fit to next-fit
ClosedPublic

Authored by alc on Jun 17 2017, 9:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 1, 3:01 AM
Unknown Object (File)
Tue, Jan 14, 8:32 AM
Unknown Object (File)
Dec 14 2024, 10:45 PM
Unknown Object (File)
Nov 25 2024, 12:31 AM
Unknown Object (File)
Nov 14 2024, 5:39 AM
Unknown Object (File)
Oct 26 2024, 7:21 PM
Unknown Object (File)
Oct 17 2024, 2:13 AM
Unknown Object (File)
Sep 30 2024, 8:13 PM
Subscribers
None

Details

Summary

Change blist_alloc()'s allocation policy from first-fit to next-fit so that disk writes are more likely to be sequential. This change is beneficial on both the solid state and mechanical drives that I've tested. (A similar change in allocation policy was made by Dragonfly BSD not so long ago.)

Increase the width of blst_meta_alloc()'s parameter "skip" and the local variables whose values are derived from it to 64 bits. (This matches the width of the field "skip" that is stored in the structure "blist" and passed to blst_meta_alloc().)

Eliminate a pointless check for a NULL blist_t.

Simplify blst_meta_alloc()'s handling of the ALL-FREE case.

Address nearby style errors.

Test Plan

I've tested this change on one solid state and two mechanical drives.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

alc retitled this revision from Change blist_alloc() to Change blist_alloc()'s allocation policy from first-fit to next-fit.Jun 17 2017, 10:10 PM
alc edited the summary of this revision. (Show Details)
alc edited the test plan for this revision. (Show Details)
alc added reviewers: kib, markj.

Here are the results from the test program that cycles through a physmem + 4 GB anonymous memory mapping on the following device:

ada3 at ahcich4 bus 0 scbus5 target 0 lun 0
ada3: <Samsung SSD 850 PRO 512GB EXM02B6Q> ACS-2 ATA SATA 3.x device
ada3: Serial Number S250NX0H626395F
ada3: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 512bytes)
ada3: Command Queueing enabled
ada3: 488386MB (1000215216 512 byte sectors)
ada3: quirks=0x3<4K,NCQ_TRIM_BROKEN>

First-fit allocation:

len: 38619095040
run 0, 32s.276585056ns
run 1, 181s.419108154ns
run 2, 191s.817094537ns
run 3, 194s.971544762ns
run 4, 195s.463131329ns
run 5, 197s.429856809ns
run 6, 196s.777934962ns
run 7, 197s.896051113ns
run 8, 197s.904393671ns
run 9, 200s.373049926ns

Next-fit allocation:

len: 38619095040
run 0, 32s.829164766ns
run 1, 180s.354998174ns
run 2, 191s.766183886ns
run 3, 191s.574965677ns
run 4, 191s.881390396ns
run 5, 191s.433134603ns
run 6, 191s.595952462ns
run 7, 191s.558809195ns
run 8, 191s.262327156ns
run 9, 191s.221447187ns

markj added inline comments.
kern/subr_blist.c
181

The "skip" parameter to blst_radix_init() is still an int - should the type be updated there as it was for blst_meta_alloc()?

238

This assignment could be made unconditional.

472

This is an unrelated change with no functional impact, right?

This revision is now accepted and ready to land.Jun 18 2017, 2:55 AM
kern/subr_blist.c
472

Right, never mind, I hadn't noticed that you mentioned this in the description.

kern/subr_blist.c
181

Yes. I was planning to address that in a separate change. Also, I don't care for the "1 +" term. This term exists because blst_radix_init() doesn't always account for a terminator.

This revision was automatically updated to reflect the committed changes.