Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise read planning #487

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Optimise read planning #487

merged 1 commit into from
Dec 12, 2024

Conversation

kjnilsson
Copy link
Contributor

@kjnilsson kjnilsson commented Dec 11, 2024

Previously we had to do do a linear search through the list of
segment reference to find which file to read a given entry from.

This commit introduced a new module ra_lol which is a
"list of list" type of ordered data structure that replaces
the use of a plain list.

ra_lol keeps data in a list of 64 entry sized "rows" which
subtantially reduces the amount of work needed to find a
given segment ref as we first scan each row to find the
row with the segref in then we can find the fixed size row.

Even a server with 4096 segment only need to scan at most
128 to find any given entry.

This commit also fixes a few issues in segref compaction
and changes the type of the segment ref to a {ra_range:range(), filename()}
to work better with the ra_range module.

Fixes #486

@kjnilsson kjnilsson force-pushed the opt-read-planning branch 2 times, most recently from 9ed2089 to e5445cf Compare December 11, 2024 14:35
@kjnilsson kjnilsson changed the title Opt read planning Optimise read planning Dec 11, 2024
@kjnilsson kjnilsson added this to the 2.16.0 milestone Dec 11, 2024
@kjnilsson kjnilsson marked this pull request as ready for review December 11, 2024 15:04
@kjnilsson kjnilsson force-pushed the opt-read-planning branch 2 times, most recently from 0dcab3e to 79a1d39 Compare December 11, 2024 17:02
@the-mikedavis
Copy link
Member

minor: there were two typos I edited in the PR description that I think exist in the commit message as well

src/ra_lol.erl Outdated Show resolved Hide resolved
src/ra_lol.erl Outdated Show resolved Hide resolved
src/ra_log_reader.erl Outdated Show resolved Hide resolved
Previously we had to do do a linear search through the list of
segment reference to find which file to read a given entry from.

This commit introduced a new module ra_lol which is a
"list of list" type of ordered data structure that replaces
the use of a plain list.

ra_lol keeps data in a list of 64 entry sized "rows" which
subtantially reduces the amount of work needed to find a
given segment ref as we first scan each row to find the
row with the segref in then we can find the fixed size row.

Even a server with 4096 segment only need to scan at most
128 to find any given entry.

This commit also fixes a few issues in segref compaction
and changes the type of the segment ref to a {ra_range:range(), filename()}
to work better with the ra_range module.
@kjnilsson kjnilsson merged commit bb89b61 into main Dec 12, 2024
7 checks passed
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.

Optimise segment sparse reads for external readers.
2 participants