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

Optimize all_mail_query #31

Open
nickwynja opened this issue Jun 6, 2022 · 8 comments
Open

Optimize all_mail_query #31

nickwynja opened this issue Jun 6, 2022 · 8 comments
Labels
enhancement New feature or request
Milestone

Comments

@nickwynja
Copy link

I currently have ~70k messages in my index which is... notmuch. 🥁

Each time I run mujmap it runs the format!("path:\"{}/**\"", relative_mail_dir.to_str().unwrap()) query, which takes 6+ seconds for me.

NOTMUCH_PROFILE=personal notmuch search path:"jmap/**"  6.19s user 2.07s system 98% cpu 8.355 total

With my basic understanding of how mujmap works, I don't see a straightforward way to use a different query or optimize this query so this can be a place to discuss.

@nickwynja nickwynja changed the title Optimize all_mail_query query Optimize all_mail_query Jun 6, 2022
@nickwynja
Copy link
Author

Looks like lieer always uses lastmod:

qry = "path:%s/** and lastmod:%d..%d" % (self.local.nm_relative, self.local.state.lastmod, rev)

And I can see we use that when merging changes to local messages.

@nickwynja
Copy link
Author

Would it be possible to defer the heavy all_mail_query until we need to do a full sync? And then just query notmuch directly per message instead of local_emails.get(&remote_email.id) and local_emails.contains_key(&x.remote_email.id)?

@elizagamedev
Copy link
Owner

That makes sense to me. I probably should have anticipated that this would not scale well.

@elizagamedev
Copy link
Owner

Would you like to take a shot at the implementation for this fix, if you have the time/rust knowledge?

@nickwynja
Copy link
Author

I don't have much rust experience (or with any other strongly typed language) but I'll give it a shot! Looks like most of this logic is before anything destructive happens so I should be able to try it using --dry-run without blowing anything up.

@elizagamedev
Copy link
Owner

Awesome! Please don't feel too much pressure to get it done just by yourself. If you run in to trouble, let me know. 🙂

@elizagamedev elizagamedev added the enhancement New feature or request label Jun 7, 2022
@nickwynja
Copy link
Author

nickwynja commented Jun 7, 2022 via email

@elizagamedev
Copy link
Owner

I understand. I will add this to the queue for v0.2.1, and once it's implemented, I'll ping you if you'd like to take a look at the code. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants