Page MenuHomeFreeBSD

radix_trie: avoid code duplication in insert
ClosedPublic

Authored by dougm on Jun 30 2023, 7:20 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 10:41 PM
Unknown Object (File)
Tue, Apr 30, 11:58 AM
Unknown Object (File)
Tue, Apr 23, 2:06 AM
Unknown Object (File)
Mar 20 2024, 1:32 AM
Unknown Object (File)
Mar 17 2024, 7:03 AM
Unknown Object (File)
Mar 17 2024, 7:03 AM
Unknown Object (File)
Mar 17 2024, 7:03 AM
Unknown Object (File)
Jan 14 2024, 9:19 AM
Subscribers

Details

Summary

Two cases in the insert routine are written differently, when they're really doing the same thing. Writing that case only once saves 208 bytes in the compiled vm_radix_insert code.

Test Plan

I have successfully booted a kernel with it.

A pair of 'make buildworld' tests counted function calls and cycles spent on vm_radix_insert.

old
vm.radix.ins_cycles: 80079998931
vm.radix.ins_calls: 344880306
cycles/call: 232.19649698118744

new
vm.radix.ins_cycles: 78438877181
vm.radix.ins_calls: 344817853
cycles/call: 227.47916472004715

Peter, can you test this please?

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dougm requested review of this revision.Jun 30 2023, 7:20 AM
dougm created this revision.
sys/kern/subr_pctrie.c
406

After this change, both pctrie_keydiff and pctrie_node_get are invoked only once.
They could just be eliminated and inlined here.

dougm edited the summary of this revision. (Show Details)

Update after introducing popmaps.

Restore some lines changed to avoid long lines.

dougm edited the test plan for this revision. (Show Details)
dougm added a subscriber: pho.

I ran test with D40807.id124308.diff for 15 hours without seeing any issues. This on:

FreeBSD mercat1.netperf.freebsd.org 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n264058-5fee12e18967d-dirty: Sat Jul  8 16:35:55 CEST 2023     pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO amd64

Improve comments. Adhere to line-wrap style.

This revision is now accepted and ready to land.Jul 9 2023, 8:00 PM
This revision was automatically updated to reflect the committed changes.