Skip to content

PS-11140 [8.0] rec_get_offsets optimize: avoid redundant dict_table_is_comp() in hot path#5937

Open
wjunLu wants to merge 2 commits into
percona:8.0from
wjunLu:optimize/rec_get_offsets-8.0
Open

PS-11140 [8.0] rec_get_offsets optimize: avoid redundant dict_table_is_comp() in hot path#5937
wjunLu wants to merge 2 commits into
percona:8.0from
wjunLu:optimize/rec_get_offsets-8.0

Conversation

@wjunLu
Copy link
Copy Markdown

@wjunLu wjunLu commented May 7, 2026

Summary

  • Add rec_get_offsets_with_comp() in rem/rec.h and rem/rec.cc, accepting a pre-computed compact (bool) flag to skip the repeated dict_table_is_comp(index->table) call inside the function on every invocation.
  • In page_copy_rec_list_end_to_created_page (page0cur.cc): cache compact once before the record copy loop, then use rec_get_offsets_with_comp() inside it.
  • In row_search_mvcc (row0sel.cc): reuse the existing comp variable at 6 hot-path call sites.

8.0 adaptation notes:

  • iboolbool
  • const char* file, ulint line + #ifdef UNIV_DEBUGut::Location location
  • mem_heap_create_at(size, file, line)mem_heap_create(size, location)
  • rec_get_n_fields_old(rec)rec_get_n_fields_old(rec, index)
  • Implementation placed in rem/rec.h / rem/rec.cc (not rem0rec.h/cc)
  • The locks_ok hunk from 5.7 is not applicable: the semi-consistent read path in 8.0 has been restructured and row_sel_build_committed_vers_for_mysql() already returns updated offsets

…in hot path

Add rec_get_offsets_with_comp() which accepts a pre-computed compact flag,
avoiding repeated dict_table_is_comp(index->table) calls inside the function
on every invocation. Apply the optimization in:
- page_copy_rec_list_end_to_created_page (page0cur.cc): cache compact once
  before the record copy loop.
- row_search_mvcc (row0sel.cc): reuse the existing comp variable at 6 call
  sites in the hot scan path.

Ported from boostdb-patches/0001-rec_get_offsets-optimize.patch
(originally targeting Percona Server 5.7.44-53). Adapted for 8.0:
- ibool -> bool
- file/line -> ut::Location
- mem_heap_create_at -> mem_heap_create(size, location)
- rec_get_n_fields_old(rec) -> rec_get_n_fields_old(rec, index)
- Implementation moved to rem/rec.h and rem/rec.cc
- The locks_ok hunk is not applicable (semi-consistent read path restructured)

Signed-off-by: wjunLu <wjunlu217@gmail.com>
@wjunLu wjunLu changed the title [8.0] rec_get_offsets optimize: avoid redundant dict_table_is_comp() in hot path PS-11140 [8.0] rec_get_offsets optimize: avoid redundant dict_table_is_comp() in hot path May 7, 2026
Reformat function declaration, definition and call sites to satisfy
clang-format-19 style checks flagged by CircleCI.

Signed-off-by: wjunLu <wjunlu217@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant