Skip to content

Optimize message memmoves by predicting next message size#501

Open
vsoulgard wants to merge 2 commits intoboostorg:developfrom
vsoulgard:feature/462-optimize-packet-read
Open

Optimize message memmoves by predicting next message size#501
vsoulgard wants to merge 2 commits intoboostorg:developfrom
vsoulgard:feature/462-optimize-packet-read

Conversation

@vsoulgard
Copy link

Solves #462

Instead of memmove everything on every call to message_reader::prepare_buffer(), we can use Exponential Moving Average (EMA) formula to predict next message size. If predicted message size fits into buffer, we can avoid memmove.

Callgrind screenshots (boost_mysql_bench_one_big_row_boost) Before: big_row_v1 After: big_row_v4

Before:
Total instructions - 1184758337
Memcpy instructions - 1030331155

After:
Total instructions - 154287054 (x7.6 less)
Memcpy instructions - 485896 (x2120 less)

It's almost free EMA implementation with high predictive power.

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