Skip to content

Optimize the force rebuild flow#116

Merged
Kerollmops merged 1 commit intomainfrom
optimize-graph-rebuild
Jan 5, 2026
Merged

Optimize the force rebuild flow#116
Kerollmops merged 1 commit intomainfrom
optimize-graph-rebuild

Conversation

@Kerollmops
Copy link
Collaborator

We tested the force_build method to rebuild the entire graph at Meilisearch, but we have some performance concerns.

We can see that most of the time spent rebuilding is actually deleting the just-inserted "updated" items from the database in a massive operation. Before calling the actual build method, we mark all items as updated so that we can use the build method as before and iterate over all updated items, deleting those entries to determine which items were just touched.

However, in the case of a complete rebuild, we can optimize this by simply indicating that no items were deleted and all items were inserted. In this PR, I introduce a relink_all_items boolean that can be handled by the build method as an optimization to avoid fetching and deleting the "updated" markers. This specific part consumed more than 63% of the reindexing time (2h20min over 3h30min).

I'm not sure about the terminology I used here, but the optimization seems essential to me. I am performing a benchmark today and will update the Meilisearch PR with the new measurements soon 👀

We should find a better, and possibly breaking, format or way to store the set of updated or deleted items, as LMDB is not performant enough to in-place delete database entries. I would either use a completely separate database to store updates or update a bitmap in a specific entry. The positive aspect of this breaking change is that it should not impact Meilisearch, as the behavior only changes during indexation, and any changes to the database made during this time are cleaned up afterward.

@Kerollmops Kerollmops force-pushed the optimize-graph-rebuild branch from 02ca250 to 8166cd6 Compare December 24, 2025 10:04
@Kerollmops Kerollmops marked this pull request as ready for review December 24, 2025 10:05
Copy link
Owner

@nnethercott nnethercott left a comment

Choose a reason for hiding this comment

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

LGTM

@Kerollmops Kerollmops merged commit 4e57a0e into main Jan 5, 2026
9 checks passed
@Kerollmops Kerollmops deleted the optimize-graph-rebuild branch January 5, 2026 09:56
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