Page MenuHomeFreeBSD

radix_trie: avoid code duplication in insert
ClosedPublic

Authored by dougm on Jun 30 2023, 7:20 AM.
Tags
None
Referenced Files
F84360198: D40807.diff
Wed, May 22, 8:54 PM
Unknown Object (File)
Tue, May 21, 1:00 AM
Unknown Object (File)
Tue, May 21, 1:00 AM
Unknown Object (File)
Tue, May 21, 1:00 AM
Unknown Object (File)
Sun, May 19, 9:48 AM
Unknown Object (File)
Tue, May 14, 11:25 AM
Unknown Object (File)
Sat, May 11, 7:22 AM
Unknown Object (File)
Mon, May 6, 11:17 PM
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

Lint
Lint Skipped
Unit
Tests Skipped

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.