Add make perf and fd table constant lookup test#70
Draft
ChuWeiChang wants to merge 3 commits into
Draft
Conversation
host_to_vfd stayed MULTI even after all but one VFD aliasing a host FD had closed, breaking reverse lookups for the survivor. Add host_fd_refs to track share counts: on close, decrement and, when the count falls to 1, search for the surviving VFD and restore a direct mapping instead of leaving MULTI in place. Change-Id: I196608b0dfe31492786928f71ba4a1e4801fc532
Introduce a dedicated check-perf build target that compiles the unit test runner with -O2 -DKBOX_PERF_ONLY, suppressing TEST_REGISTER so only PERF_REGISTER benchmarks execute. The perf binary is kept separate from the unit test binary (test-perf vs test-runner) so running check-perf does not invalidate check-unit's build artifact. Change-Id: I55d7ff64b981dbbcf248b6ab675fd2c86147b165
00004d6 to
000098f
Compare
Benchmark kbox_fd_table_find_by_host_fd across table sizes of 64 to 16384 entries. Assert that per-lookup latency stays within 2x of the baseline at N=64, verifying that the host_to_vfd reverse map added in the O(1) refactor holds its constant-time characteristic. Change-Id: Ibcb7188e2c444f4636f669e73aeacd3980f04b84
000098f to
0000542
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(This PR is built on top of #68. Please review/merge that one first)
This PR serve as the reference for #38 (comment)
Resolve test gap 3 in #38:
Add a
check-perfbuild target that compiles the unit test suite with-O2 -DKBOX_PERF_ONLYin a separatebinary (
test-perf), keeping it independent from the check-unit artifact. Sanitizer and debug flags are stripped fromPERF_TEST_CFLAGSso timings reflect optimized production code.Add a benchmark that exercises
kbox_fd_table_find_by_host_fdfor both present and absent host FDs across table sizes {64, 256, 1024, 4096, 16384} and asserts that per-lookup latency stays within 2x of the N=64 baseline.Results
The lookup time is flat across all table sizes — present lookups stay in the 1.59–1.87 ns range and absent lookups stay in the 1.29–1.39 ns range regardless of whether the table has 64 or 16384 entries, adhering to O(1) signature.
Summary by cubic
Adds a perf-only test runner (
check-perf) and an O(1) reverse-lookup benchmark for the FD table, plus a fix that correctly downgradesMULTImappings when aliases close. Covers test gap 3 in #38 and runs in CI without sanitizers to reflect production timing.New Features
make check-perf: builds a separatetests/unit/test-perfwith-O2 -DKBOX_PERF_ONLY(no sanitizers/debug) so only perf benchmarks run; included inmake checkand a new CIperf-testsjob.kbox_fd_table_find_by_host_fdacross {64, 256, 1024, 4096, 16384}; asserts present/absent lookups stay ≤2x the N=64 baseline.Bug Fixes
host_fd_refs[]and updaterev_host_set/clearto maintain counts and downgrade fromMULTIto the surviving VFD when one alias remains; counters initialized inkbox_fd_table_init.test-fd-table-refcount.c) ensures reverse lookup returns the survivor after other aliases close.Written for commit 0000542. Summary will update on new commits.
Review in cubic