milli icon indicating copy to clipboard operation
milli copied to clipboard

Speed up debug builds

Open loiclec opened this issue 3 years ago • 17 comments
trafficstars

Note: this draft PR is based on https://github.com/meilisearch/milli/pull/601 , for no particular reason.

What does this PR do?

Make a series of changes with the goal of speeding up debug builds:

  1. Add an all_languages feature which compiles charabia with its default features activated. The all_languages feature is activated by default. But running:
cargo build --no-default-features

on milli is now much faster.

  1. Reduce the debug optimisation level from 3 to 0, except for a few critical dependencies.

  2. Compile the build dependencies quicker as well. Previously, all build dependencies were compiled with opt-level = 3. Now, only the critical build dependencies are compiled with optimisations.

  3. Reduce the amount of code generated by the documents! macro

  4. Make the "progress update" closure provided to indexing functions a trait object instead of a generic parameter. This avoids monomorphising the indexing code multiple times needlessly.

Results

Initial build times on my computer before and after these changes:

cargo check cargo check --no-default-features cargo test cargo test --lib cargo test --no-default-features cargo test --lib --no-default-features
before 1m05s 1m05s 2m06s 1m47s 2m06 1m47s
after 28.9s 13.1s 40s 38s 23s 21s

loiclec avatar Aug 11 '22 15:08 loiclec

Build failed:

bors[bot] avatar Aug 17 '22 09:08 bors[bot]

lets retry, bors merge

ManyTheFish avatar Aug 17 '22 09:08 ManyTheFish

Build failed:

bors[bot] avatar Aug 17 '22 10:08 bors[bot]

This is an issue with Cargo and the crates index. bors merge

Kerollmops avatar Aug 17 '22 12:08 Kerollmops

Merge conflict.

bors[bot] avatar Aug 17 '22 12:08 bors[bot]

I rebased it on top of main, let's try again haha

bors merge

loiclec avatar Aug 17 '22 12:08 loiclec

Build failed:

  • Tests on windows-latest

bors[bot] avatar Aug 17 '22 12:08 bors[bot]

Nice!

LLVM ERROR: IO failure on output stream: no space on device
error: could not compile `lindera-ipadic`

bors merge

Kerollmops avatar Aug 17 '22 14:08 Kerollmops

haha! @irevoire it's your turn to try afterwards!

loiclec avatar Aug 17 '22 14:08 loiclec

Build failed:

bors[bot] avatar Aug 17 '22 14:08 bors[bot]

@loiclec Is this PR making the library bigger or what? 😂

Kerollmops avatar Aug 17 '22 14:08 Kerollmops

I was starting to wonder as well. Since it is compiled with opt-level = 0, the binary will be bigger indeed :/ I'll check on my computer if it seems excessive or not.

loiclec avatar Aug 17 '22 14:08 loiclec

On my computer (macOS, so not necessarily the same), there doesn't seem to be any significant difference between the size of the target/ folder before and after the PR. So I am still confused as to why it fails :( Let's hope the CI was just having a bad day?

bors merge pretty please 🥺🙏

loiclec avatar Aug 18 '22 10:08 loiclec

Merge conflict.

bors[bot] avatar Aug 18 '22 10:08 bors[bot]

Build failed:

bors[bot] avatar Aug 18 '22 11:08 bors[bot]

nooooo 😭 I guess there really is something about that PR that makes rustc on Windows sad

loiclec avatar Aug 18 '22 11:08 loiclec

but it worked here 🤔 image

irevoire avatar Aug 18 '22 11:08 irevoire

I've rebased the branch on main so it's ready to merge again :-)

loiclec avatar Oct 12 '22 07:10 loiclec

Hey @loiclec, could it be possible to deactivate the default features of Charabia when it is compiled in debug? Most of the time, we don't need to have full language support activated during the development phase.

ManyTheFish avatar Oct 12 '22 09:10 ManyTheFish

This message is sent automatically

Thank you for contributing to Meilisearch. If you are participating in Hacktoberfest, and you would like to receive some gift from Meilisearch too, please complete this form.

meili-bot avatar Oct 12 '22 09:10 meili-bot