all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: 37321@debbugs.gnu.org
Subject: bug#37321: 27.0.50; Excessive gc in a use case (el-search)
Date: Sat, 07 Sep 2019 16:23:42 +0200	[thread overview]
Message-ID: <87sgp84235.fsf@web.de> (raw)
In-Reply-To: <87lfv1pm5x.fsf@web.de> (Michael Heerdegen's message of "Fri, 06 Sep 2019 15:52:10 +0200")

Michael Heerdegen <michael_heerdegen@web.de> writes:

> M-x el-search-emacs-elisp-sources 'pcase M-RET

I found the culprit.  It's this simple function:

#+begin_src emacs-lisp
(defun el-search--flatten-tree (tree)
  "Return a list of `el-search--atomic-p' objects in TREE."
  (let ((elements ())
        (walked-objects ;to avoid infinite recursion for circular TREEs
         (make-hash-table :test #'eq))
         (gc-cons-percentage 0.8)
        ) ;Why is binding it here more effective than binding it more top-level?
    (cl-labels ((walker (object)
                        (if (el-search--atomic-p object)
                            (push object elements)
                          (unless (gethash object walked-objects)
                            (puthash object t walked-objects)
                            (if (consp object)
                                (progn
                                  (while (consp object)
                                    (walker (car object))
                                    (setq object (cdr object))
                                    (if (gethash object walked-objects)
                                        (setq object nil)
                                      (puthash object t walked-objects)))
                                  (when object ;dotted list
                                    (walker object)))
                              (cl-loop for elt being the elements of object do (walker elt)))))))
      (walker tree)
      elements)))
#+end_src

I've put a lot of work in optimizing el-searching speed.  It now mainly
depends of effectiveness of gc, mostly in the above function.  When I
wrote it I noticed that it worked best when binding gc-cons-percentage
to a value of 0.8 (inside the function, see the code).  But now this
binding slows the thing down as hell.  When I remove the binding,
searching is fast again, but it still takes twice as long as in the past
when 0.8 worked.

I've no clue about how gc works and how the above function can be
optimized, and if gc is expected to be that slow now with the
gc-cons-percentage binding in effect.  Advice appreciated.

TIA,

Michael.





  reply	other threads:[~2019-09-07 14:23 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 13:52 bug#37321: 27.0.50; Excessive gc in a use case (el-search) Michael Heerdegen
2019-09-07 14:23 ` Michael Heerdegen [this message]
2019-09-07 15:30   ` Michael Heerdegen
2019-09-08  1:11 ` Paul Eggert
2019-09-08 14:52   ` Michael Heerdegen
2019-09-08 15:25     ` Michael Heerdegen
2019-09-14  8:04       ` Paul Eggert
2019-09-14  8:37         ` Eli Zaretskii
2019-09-14  8:52           ` Paul Eggert
2019-09-14  9:57             ` Eli Zaretskii
2019-09-14 17:57               ` Paul Eggert
2019-09-14 18:16                 ` Eli Zaretskii
2019-09-15  4:33             ` Richard Stallman
2019-09-16 23:53         ` Michael Heerdegen
2019-09-17  0:55           ` Paul Eggert
2019-09-21  0:41             ` Michael Heerdegen
2019-09-21  0:46               ` Michael Heerdegen
2019-09-21  6:19                 ` Paul Eggert
2019-09-17 12:47           ` Noam Postavsky
2019-09-21  0:44             ` Michael Heerdegen
2019-09-25  9:42         ` Michael Heerdegen
2019-09-25 20:37           ` Paul Eggert
2019-09-26 11:42             ` Michael Heerdegen
2019-09-26 12:14               ` Eli Zaretskii
2019-09-26 13:03                 ` Michael Heerdegen
2019-10-08  8:43                 ` Michael Heerdegen
2019-10-08  9:09                   ` Eli Zaretskii
2019-10-08  9:11                     ` Michael Heerdegen
2019-10-08  9:19                       ` Eli Zaretskii
2019-10-08 11:12                         ` Michael Heerdegen
2019-10-08 12:11                           ` Eli Zaretskii
2019-10-08 12:38                             ` Michael Heerdegen
2019-10-08 13:03                               ` Eli Zaretskii
2019-10-09 14:47                                 ` Michael Heerdegen
2019-10-09 15:33                                   ` Eli Zaretskii
2019-10-09 20:53                                     ` Paul Eggert
2019-10-10 10:58                                     ` Michael Heerdegen
2019-10-08  9:22                       ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgp84235.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=37321@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.