Re: [PATCH 1/2] CLI/new: add mtime-opt option

Subject: Re: [PATCH 1/2] CLI/new: add mtime-opt option

Date: Sun, 29 Apr 2018 19:20:40 +0300

To: David Bremner, David Bremner, notmuch@notmuchmail.org

Cc:

From: Jani Nikula


On Sun, 29 Apr 2018, David Bremner <david@tethera.net> wrote:
> This option, on by default, controls whether mtimes are used to
> optimize the scanning of directories. The intent is to turn this
> optimization off for certain tests.
> ---
>  notmuch-new.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/notmuch-new.c b/notmuch-new.c
> index c4345705..099bbbae 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -47,6 +47,7 @@ typedef struct {
>      int output_is_a_tty;
>      enum verbosity verbosity;
>      bool debug;
> +    bool mtime_opt;
>      const char **new_tags;
>      size_t new_tags_length;
>      const char **ignore_verbatim;
> @@ -527,7 +528,7 @@ add_files (notmuch_database_t *notmuch,
>       * mistakenly return the total number of directory entries, since
>       * that only inflates the count beyond 2.
>       */
> -    if (directory && fs_mtime == db_mtime && st.st_nlink == 2) {
> +    if (directory && state->mtime_opt && fs_mtime == db_mtime && st.st_nlink == 2) {
>  	/* There's one catch: pass 1 below considers symlinks to
>  	 * directories to be directories, but these don't increase the
>  	 * file system link count.  So, only bail early if the
> @@ -618,7 +619,7 @@ add_files (notmuch_database_t *notmuch,
>       * being discovered until the clock catches up and the directory
>       * is modified again).
>       */
> -    if (directory && fs_mtime == db_mtime)
> +    if (directory && state->mtime_opt && fs_mtime == db_mtime)
>  	goto DONE;
>  
>      /* If the database has never seen this directory before, we can
> @@ -771,7 +772,7 @@ add_files (notmuch_database_t *notmuch,
>       * the database because a message could be delivered later in this
>       * same second.  This may lead to unnecessary re-scans, but it
>       * avoids overlooking messages. */
> -    if (fs_mtime != stat_time)
> +    if (state->mtime_opt && fs_mtime != stat_time)
>  	_filename_list_add (state->directory_mtimes, path)->mtime = fs_mtime;

I don't think we should skip this part. We've done a full scan now, so
we should record that in the database so a subsequent scan doesn't have
to.

>  
>    DONE:
> @@ -1053,6 +1054,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
>      add_files_state_t add_files_state = {
>  	.verbosity = VERBOSITY_NORMAL,
>  	.debug = false,
> +	.mtime_opt = true,
>  	.output_is_a_tty = isatty (fileno (stdout)),
>      };
>      struct timeval tv_start;
> @@ -1073,6 +1075,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])
>  	{ .opt_bool = &quiet, .name = "quiet" },
>  	{ .opt_bool = &verbose, .name = "verbose" },
>  	{ .opt_bool = &add_files_state.debug, .name = "debug" },
> +	{ .opt_bool = &add_files_state.mtime_opt, .name = "mtime-opt" },

--full-scan? --force? --force-scan?

I think we've had people ask how they can have notmuch scan some
directories again, for some reason or another. Maybe to test their
ignores, and they can't have notmuch rescan the directory without
touching it. IMHO --no-mtime-opt doesn't sound very intuitive for that
purpose.

Otherwise, seems like a thing we should add.

BR,
Jani.

>  	{ .opt_bool = &hooks, .name = "hooks" },
>  	{ .opt_inherit = notmuch_shared_indexing_options },
>  	{ .opt_inherit = notmuch_shared_options },
> -- 
> 2.17.0
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: