Commit Graph

1347 Commits

Author SHA1 Message Date
dc0ad7dabe mu-store: cosmetics 2026-08-20 15:05:28 -07:00
8914004970 Work around xapian bug
https://trac.xapian.org/ticket/850
2026-08-20 15:05:28 -07:00
31835200bd New incremental cleanup strategy: 63%-88% faster
This change adds a new cleanup mode that avoids cleanup having
re-traverse the directories the index pass just looked at.
Additionally, we efficiently query the Xapian database by walking the
term list instead of doing multiple point-wise path lookups.

I'd noticed that most of my time in mu's cleanup pass consisted of
B-tree lookups in Xapian (one 8KB pread64 at a time).  The point
lookups forced Xapian to traverse from the root of the B-tree to the
leaf for every single message.  Additionally, in order to join on the
message path, we had to do *another* B-tree traversal after locating
each message term.  Now we just walk the terms in order, which is much
more efficient, as we touch each B-tree node only once.

On my system, with 1371861 total messages, the total time of mu
index (no lazy check):

--nocleanup: 3.6s
incremental cleanup: 4.2s (0.6s in cleanup)
legacy cleanup: 5.2s (1.6s in cleanup)

With the new mode, we save 1.0s of the 1.6s cleanup, so we're
~63% faster.

But the incremental cleanup works even better with lazy checking.
If I enable --lazy-check, dirty only my INBOX (360778 messages), and
run index, I get:

--nocleanup: 0.9s
incremental cleanup: 1.1s (0.2s in cleanup)
legacy cleanup: 2.5s (1.6s in cleanup)

We save 1.4s out of 1.6s for ~88% speedup.

This change also fixes a timestamp bug: we should be storing
the *start* time of the index pass in metadata, not the end time, so
that on the next index pass, we notice messages that arrived between
the two times.

All tests pass.  You can set the environment variable
MU_NO_INCREMENTAL_CLEANUP to use the legacy cleanup path instead.
2026-08-20 15:05:28 -07:00
c0253e075e mu-query-parser: update comment 2026-08-20 15:05:28 -07:00
db7bd7a900 mu-utils: replace #define with constexpr for MU_COLOR_ 2026-08-20 15:05:28 -07:00
85f4a4b80a utils: fix typo 2026-08-20 15:05:28 -07:00
ab6017d5a9 utils: rework MU_ENABLE_BITOPS using C++20 code
Instead of macros, we using C++20 concepts to define the helpers to deal with
bitops on enum-class conveniently.

x# Please enter the commit message for your changes. Lines starting
2026-08-20 15:05:28 -07:00
911ade8b73 sexp.hh: silence compiler warnings
Seems they only happen in C++20 mode, not when compiling C++23 mode. So assuming
these are false alarms (old code anyway)
2026-08-20 15:05:28 -07:00
06b4625e61 build: bump to 1.14.0-pre1, bump some required versions
Bump the required versions of some libraries / emacs slightly so we can get rid
of some special-casing and work-arounds. These are mostly based on Ubuntu 24.04
LTS, which is rather conservative; so should hopefully not inconvenience any
users.

- compiler: we now require C++20 instead of C++17
- glib & friends: 2.60 => 2.80
- xapian: 1.4 => 1.4.22
- emacs 26.3 => 28.1

Ubuntu 24.04 actually has Emacs 29.3, but that'd perhaps be too big a jump.
2026-08-20 15:05:28 -07:00
341585ad66 test-store: disable bad test
The "expected-to-fail" test actually passes when root.
2026-08-20 15:05:28 -07:00
dc5bbd9884 labels: improve logging for import
Clear up the code a bit using the new logging functions.

Don't log a failure for "plan A" as an error, it just scares user unnecessarily.
2026-08-20 15:04:27 -07:00
f66b58cd41 utils: rework logging functions
Use a general mu_log which does the formatting, and specific mu_debug, mu_info
etc., to call it.
2026-08-20 15:04:27 -07:00
410ff46881 improve invoking external commands
- don't make assumptions on where programs live (i.e., /bin/sh, /bin/rm,
/bin/mv) are not universal
- dont invoke shell when unnecessary
- improve error-handling
2026-08-20 15:04:27 -07:00
9f69055ef9 test-mu-store: bump timeout in test
Seems some systems are quite slow, so bump the time-out.

Fixes #2886.
2026-08-20 15:04:27 -07:00
804b1180fe mu-server: improve error message for temp-file
Make it clear what exactly could not be created.
2026-08-20 15:04:27 -07:00
9b3e21081e test-mu-message: use join_path for test-path
We were not doing that correctly, missing a "/" between dirname and filename.
2026-08-20 15:04:27 -07:00
5f7686a767 test-utils: fix some clang-tidy warnings 2026-08-20 15:04:27 -07:00
ad327d3acb test-utils: use remove_directory 2026-08-20 15:04:27 -07:00
d258c77661 utils/file: rework remove_directory, add test
Make remove_directory not much less ugly, but at least more robust, e.g., when
the "rm" binary is not at /bin/rm

Add unit test
2026-08-20 15:04:27 -07:00
4acf708eb9 logging: don't g_message with --quiet
When `--quiet` is passed (and not --debug), do not log with g_message at
startup.
2026-08-20 15:04:27 -07:00
976b6210fc message: ensure message text is valid utf8
Seems this is not guaranteed, so convert if needed.
2026-08-20 15:04:27 -07:00
5c6642c9b9 utils: add utf8_clean helper
To morph text into valid utf8 if it isn't already.
2026-08-20 15:04:27 -07:00
056540b8e8 utils: avoid fmt:gmtime/fmt::localtime
They've been deprecated and give build warnings with new enough libfmt.
2026-08-20 15:04:26 -07:00
652b5ccbea labels: tighten labels regexp 2026-08-20 15:04:26 -07:00
461e4f83fe store-test: add more label tests
Ensure removal affects the labels cache.
2026-08-20 15:04:26 -07:00
c547cde73e store: remove some _unlocked functions, update clear_labels
They don't add much value, let's remove.

Rework clear_labels in terms of update_labels.
2026-08-20 15:04:26 -07:00
33ab0acc8d store: update labels when removing messages
This does make removing a bit slower...
2026-08-20 15:04:26 -07:00
3a12c69b10 mu: refactor labels code
Split labels-cache and store-labels.
2026-08-20 15:04:26 -07:00
124b371850 labels: allow restoring cache-map
E.g. with unexpected termination for mu it is possible that the
labels-cache (i.e., the one that is used for auto-completion) gets disconnected
from reality.

Add a --restore option to `mu label list` to restore the actual labels from the
labels seen in the store.
2026-08-20 15:04:26 -07:00
bb399bc37a store: implement serialize method, use it
For triggering saving the contacts / labels caches.
2026-08-20 15:04:26 -07:00
c074c138f8 store: improve label handling
In particular, clear_labels

And some cosmetics
2026-08-20 15:04:26 -07:00
bf2f4ce57d server: add label handler
For handling mu4e label update requests.
2026-08-20 15:04:26 -07:00
2fa973ec90 mu-label: allow more characters
reduce the number of "taboo" characters in labels.

update docs.
2026-08-20 15:04:26 -07:00
76b9000588 mu-document: improve sexp updating
Ensure the cached message sexp gets updated in all cases where it's necessary.
2026-08-20 15:04:26 -07:00
d07a5bc2c1 labels: implement parse_delta_labels
Convenience function for parsing a series of delta labels; add tests as well.
2026-08-20 15:04:26 -07:00
543c43f078 Replace "the the " with "the " 2026-08-20 15:04:26 -07:00
5a6ca68846 mu4e/server: get cached list of labels
This will be useful with label commands.
2026-08-20 15:04:26 -07:00
5378f321f4 utils: add set_thread_name
With HAVE_PTHREAD_SETNAME_NP
2026-08-20 15:04:25 -07:00
02a0dc4333 mu-server: implement exposing the socket-path
Add the scm-socket-path to the ping-properties we expose for mu4e.
2025-08-24 11:54:08 +03:00
cacac82070 mu-query-results: add decrement operators
So we can easily iterator from end->begin
2025-08-22 07:58:59 +03:00
8c706a77db mu-init: automatic export labels with --reinit
When re-initializing the store, automatically write the labels to a file in mu's
cache, so user can later import them.
2025-08-16 16:20:33 +03:00
a6b1f47a30 labels: refactor import/export to mu-store-labels
Move the import/export code to 'lib'.
2025-08-16 12:18:21 +03:00
f504289a02 labels: ensure c++17 compatibility
This broke the build earlier.
2025-08-16 08:43:41 +03:00
46fa4f2aa2 mu: add 'label' command + manpage + tests
Add a label command and document it.
2025-08-15 21:03:19 +03:00
1e628dfcab store: add support for modifying and listing labels and caching
Add methods update_labels, clear_labels which update or clear the labels for a
message in the store, and update the cache with the overall counts of labels.

Add a LabelsCache to keep track of the counts and labels_map() to retrieve that
map.
2025-08-15 21:02:24 +03:00
552bb3a7c8 message: add support for labels + tests
Labels are strings associated with messages, which can be used for searching
them.
2025-08-15 21:02:24 +03:00
34d3bf2e28 tests: only build when needed
Build the tests lazily, i.e., not before `meson test`. This helps with
build-times.
2025-08-15 21:01:05 +03:00
8d3b65c5d8 utils: refactor count_nl from mu-cmd-find
And update users.
Please enter the commit message for your changes. Lines starting
2025-07-27 19:39:23 +03:00
28ea23a2a3 contacts-cache: cosmetics 2025-07-27 19:39:23 +03:00
33958cd0f7 fmt: prefer system package if found
mu embeds a "vendored" subset of the libfmt package under thirdparty; but it's
better to use the system-package if the user has one.

So, use the system package if found or user -Duse-embedded-fmt=true is
specified.
2025-07-24 19:55:27 +03:00