Skip to content

PS-11161 [8.4]: mem_root_deque performance optimizations (part 1).#5950

Merged
dlenev merged 1 commit into
percona:release-8.4.9-9from
dlenev:ps-11161-step-1-8.4
May 18, 2026
Merged

PS-11161 [8.4]: mem_root_deque performance optimizations (part 1).#5950
dlenev merged 1 commit into
percona:release-8.4.9-9from
dlenev:ps-11161-step-1-8.4

Conversation

@dlenev
Copy link
Copy Markdown
Contributor

@dlenev dlenev commented May 15, 2026

Reduce target size of mem_root_deque block to 256 bytes from 1Kb.

In the majority of cases mem_root_deque is used to store pointers (e.g. to Item objects), hence the 1kB block can store up to 128 elements for 64-bit arch.
OTOH in many cases the number of elements which is really used in mem_root_deque is much lower. For example, for many queries number of fields in SELECT list is far smaller than 64.

This means that in many cases the bigger part of such a 1kB block is just wasted. Taking into account that there are 5-10 of mem_root_deque instances even for fairly simple queries the effect of such waste becomes more pronounced - allocating these extra unnecessary 5-10Kb on main MEM_ROOT can trigger it to request another block from malloc(). And the latter has small but visible impact on performance in some of sysbench tests.

Reduce target size of mem_root_deque block to 256 bytes from 1Kb.

In the majority of cases mem_root_deque is used to store pointers
(e.g. to Item objects), hence the 1kB block can store up to 128
elements for 64-bit arch.
OTOH in many cases the number of elements which is really used in
mem_root_deque is much lower. For example, for many queries number
of fields in SELECT list is far smaller than 64.

This means that in many cases the bigger part of such a 1kB block
is just wasted. Taking into account that there are 5-10 of
mem_root_deque instances even for fairly simple queries the effect
of such waste becomes more pronounced - allocating these extra
unnecessary 5-10Kb on main MEM_ROOT can trigger it to request
another block from malloc(). And the latter has small but visible
impact on performance in some of sysbench tests.
@dlenev dlenev requested review from inikep and percona-ysorokin May 15, 2026 18:07
@dlenev
Copy link
Copy Markdown
Contributor Author

dlenev commented May 17, 2026

Here are Jenkins results for this patch: https://ps80.cd.percona.com/view/8.0%20+%208.4%20parallel%20MTR/job/percona-server-8.x-pipeline-parallel-mtr/1136/#showFailuresLink - they look OK to me as these failures also present in other runs for pristine release-8.4.9-9 tree.

Copy link
Copy Markdown
Collaborator

@inikep inikep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dlenev dlenev merged commit 753d18b into percona:release-8.4.9-9 May 18, 2026
21 checks passed
@dlenev dlenev deleted the ps-11161-step-1-8.4 branch May 18, 2026 07:58
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.

2 participants