[v25.3.x] iobuf: fix operator<=> and operator== for string_view comparisons#29477
Merged
rockwotj merged 3 commits intoredpanda-data:v25.3.xfrom Jan 31, 2026
Merged
Conversation
The previous implementation had inverted stop_iteration logic - it stopped when the comparison was equal and continued when not equal, causing incorrect results when the first fragment comparison determined the ordering. Replaced iterator_consumer pattern with a simpler for-each loop over fragments. Added comprehensive tests covering multi-fragment comparisons. Benchmark results (instructions, runtime): - sv_cmp_0000: 49 -> 36 inst (-27%), 2.28ns -> 2.16ns (-5%) - sv_cmp_0001: 87 -> 64 inst (-26%), 3.61ns -> 3.17ns (-12%) - sv_cmp_1024 (different): 121 -> 60 inst (-50%), 4.98ns -> 3.44ns (-31%) - sv_cmp_1024 (same): 256 -> 214 inst (-16%), 10.37ns -> 9.41ns (-9%) Runtime improvements are consistent with instruction count reductions. (cherry picked from commit aad9cff)
Simplify operator== by delegating to the fixed operator<=> implementation. This reduces code duplication and ensures consistent comparison behavior. Benchmark results (instructions, runtime): - sv_eq_0000: 38 -> 30 inst (-21%), 2.30ns -> 1.95ns (-15%) - sv_eq_0001: 83 -> 58 inst (-30%), 3.61ns -> 2.96ns (-18%) - sv_eq_1024 (different): 80 -> 57 inst (-29%), 3.70ns -> 3.25ns (-12%) - sv_eq_1024 (same): 247 -> 209 inst (-15%), 10.50ns -> 9.46ns (-10%) Runtime improvements are consistent with instruction count reductions. (cherry picked from commit 30220a4)
Add sv_eq_* and sv_cmp_* benchmark cases to measure performance of iobuf::operator== and operator<=> against string_view. Uses a templated cmp_bench function with rhs_type parameter to support both iobuf-vs-iobuf and iobuf-vs-string_view comparisons. Tests both single-fragment and fragmented iobufs at sizes 0, 1, 1024. (cherry picked from commit 5752502)
rockwotj
approved these changes
Jan 31, 2026
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.
Backport of PR #29461