#3973: Patch: maildir_check_mailbox()
-------------------------+----------------------
 Reporter:  jaalto       |      Owner:  mutt-dev
     Type:  enhancement  |     Status:  new
 Priority:  minor        |  Milestone:
Component:  mutt         |    Version:
 Keywords:               |
-------------------------+----------------------
 ''This is forward of following post. Please consider investigating and
 contacting the original author.''
 '''A KERNEL DEV'S APPROACH TO IMPROVING MUTT'S PERFORMANCE - PART 2
 '''

 http://www.codeblueprint.co.uk/2017/01/15/a-kernel-devs-approach-to-
 improving2

 (...)I noticed that when mutt locks up top(1) reports it consuming 100%
 CPU, which suggests that we can use the cpu-cycles perf event to gather a
 profile for mutt and figure out where those cycles are going. (...) Below
 is the change I made to mutt’s maildir_check_mailbox() to take into
 account the number of files my the LKML directory when building the hash
 table. With it, I no longer see any lockup when new mail arrives:

 Patch:

 
https://gist.github.com/mfleming/aa29c562bdb32fe938a4e35694f67092/raw/905b295cbea387f9d997cccb116aadab8d998930/gistfile1.txt

 {{{
 diff -r 02bc14ed1569 mh.c
 --- a/mh.c      Tue Dec 08 09:12:09 2015 -0800
 +++ b/mh.c      Sun Jan 15 21:35:48 2017 +0000
 @@ -1908,6 +1908,7 @@
    struct maildir *md;          /* list of messages in the mailbox */
    struct maildir **last, *p;
    int i;
 +  int count = 0;
    HASH *fnames;                        /* hash table for quickly looking
 up the base filename
                                    for a maildir message */
    struct mh_data *data = mh_data (ctx);
 @@ -1945,15 +1946,15 @@
    md = NULL;
    last = &md;
    if (changed & 1)
 -    maildir_parse_dir (ctx, &last, "new", NULL, NULL);
 +    maildir_parse_dir (ctx, &last, "new", &count, NULL);
    if (changed & 2)
 -    maildir_parse_dir (ctx, &last, "cur", NULL, NULL);
 +    maildir_parse_dir (ctx, &last, "cur", &count, NULL);

    /* we create a hash table keyed off the canonical (sans flags) filename
     * of each message we scanned.  This is used in the loop over the
     * existing messages below to do some correlation.
     */
 -  fnames = hash_create (1031, 0);
 +  fnames = hash_create (count, 0);

    for (p = md; p; p = p->next)
    {

 }}}

--
Ticket URL: <https://dev.mutt.org/trac/ticket/3973>
Mutt <http://www.mutt.org/>
The Mutt mail user agent

Reply via email to