From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: ghe@sdf.org, Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: Redisplay slower in Emacs 28 than Emacs 27
Date: Tue, 08 Dec 2020 20:36:47 +0100 [thread overview]
Message-ID: <87y2i89jjk.fsf@gnus.org> (raw)
In-Reply-To: <87360gaz7o.fsf@gnus.org> (Lars Ingebrigtsen's message of "Tue, 08 Dec 2020 20:12:59 +0100")
Lars Ingebrigtsen <larsi@gnus.org> writes:
> However, if we continue using equal_lists (which compares list members
> with EQ), we can write a new hash function for image.c that just uses
> identity/number values of the elements, and we'd get a nice speed-up.
Here's a stab as a new EQ-ey image spec hashing function:
diff --git a/src/fns.c b/src/fns.c
index e4c9acc316..2512bce5f5 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4640,9 +4640,48 @@ sxhash_bignum (Lisp_Object bignum)
}
+EMACS_UINT
+img_hash (Lisp_Object spec)
+{
+ EMACS_UINT hash = 0;
+
+ while (CONSP (spec))
+ {
+ EMACS_UINT val;
+ Lisp_Object obj = XCAR (spec);
+ spec = XCDR (spec);
+
+ switch (XTYPE (obj))
+ {
+ case_Lisp_Int:
+ val = XUFIXNUM (obj);
+ break;
+
+ case Lisp_Symbol:
+ val = XHASH (obj);
+ break;
+
+ case Lisp_String:
+ val = (EMACS_UINT) SSDATA (obj);
+ break;
+
+ case Lisp_Float:
+ val = sxhash_float (XFLOAT_DATA (obj));
+ break;
+
+ default:
+ val = 0;
+ }
+
+ hash = sxhash_combine (hash, val);
+ }
+ return SXHASH_REDUCE (hash);
+}
+
/* Return a hash code for OBJ. DEPTH is the current depth in the Lisp
structure. Value is an unsigned integer clipped to INTMASK. */
+
EMACS_UINT
sxhash (Lisp_Object obj)
{
diff --git a/src/image.c b/src/image.c
index 5eb4132295..4c586853d8 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1634,6 +1634,7 @@ search_image_cache (struct frame *f, Lisp_Object spec, EMACS_UINT hash,
&& (ignore_colors || (img->face_foreground == foreground
&& img->face_background == background)))
break;
+
return img;
}
@@ -1649,7 +1650,7 @@ uncache_image (struct frame *f, Lisp_Object spec)
can have multiple copies of an image with the same spec. We want
to remove them all to ensure the user doesn't see an old version
of the image when the face changes. */
- while ((img = search_image_cache (f, spec, sxhash (spec), 0, 0, true)))
+ while ((img = search_image_cache (f, spec, img_hash (spec), 0, 0, true)))
{
free_image (f, img);
/* As display glyphs may still be referring to the image ID, we
@@ -2346,7 +2347,7 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id)
eassert (valid_image_p (spec));
/* Look up SPEC in the hash table of the image cache. */
- hash = sxhash (spec);
+ hash = img_hash (spec);
img = search_image_cache (f, spec, hash, foreground, background, true);
if (img && img->load_failed_p)
{
diff --git a/src/lisp.h b/src/lisp.h
index 416c9b0cac..4ca5aeced1 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3595,6 +3595,7 @@ #define CONS_TO_INTEGER(cons, type, var) \
extern char *extract_data_from_object (Lisp_Object, ptrdiff_t *, ptrdiff_t *);
EMACS_UINT hash_string (char const *, ptrdiff_t);
EMACS_UINT sxhash (Lisp_Object);
+EMACS_UINT img_hash (Lisp_Object);
Lisp_Object hashfn_eql (Lisp_Object, struct Lisp_Hash_Table *);
Lisp_Object hashfn_equal (Lisp_Object, struct Lisp_Hash_Table *);
Lisp_Object hashfn_user_defined (Lisp_Object, struct Lisp_Hash_Table *);
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2020-12-08 19:36 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 14:53 Redisplay slower in Emacs 28 than Emacs 27 Gregory Heytings via Emacs development discussions.
2020-12-07 15:04 ` Lars Ingebrigtsen
2020-12-07 15:14 ` Gregory Heytings via Emacs development discussions.
2020-12-07 15:19 ` Lars Ingebrigtsen
2020-12-07 15:28 ` Gregory Heytings via Emacs development discussions.
2020-12-07 15:41 ` Lars Ingebrigtsen
2020-12-07 15:43 ` Gregory Heytings via Emacs development discussions.
2020-12-07 15:45 ` Gregory Heytings via Emacs development discussions.
2020-12-07 16:14 ` Lars Ingebrigtsen
2020-12-07 16:46 ` Gregory Heytings via Emacs development discussions.
2020-12-07 17:30 ` Eli Zaretskii
2020-12-07 18:45 ` Gregory Heytings via Emacs development discussions.
2020-12-07 18:47 ` Lars Ingebrigtsen
2020-12-07 18:49 ` Gregory Heytings via Emacs development discussions.
2020-12-07 20:58 ` Alan Third
2020-12-07 21:24 ` Gregory Heytings via Emacs development discussions.
2020-12-07 21:06 ` Gregory Heytings via Emacs development discussions.
2020-12-07 21:15 ` Lars Ingebrigtsen
2020-12-07 21:23 ` Alan Third
2020-12-07 21:31 ` Lars Ingebrigtsen
2020-12-07 21:47 ` Lars Ingebrigtsen
2020-12-07 21:46 ` Gregory Heytings via Emacs development discussions.
2020-12-07 21:49 ` Gregory Heytings via Emacs development discussions.
2020-12-07 21:59 ` Lars Ingebrigtsen
2020-12-07 22:11 ` Lars Ingebrigtsen
2020-12-07 22:56 ` Gregory Heytings via Emacs development discussions.
2020-12-07 23:02 ` Lars Ingebrigtsen
2020-12-07 23:09 ` Gregory Heytings via Emacs development discussions.
2020-12-07 23:44 ` Lars Ingebrigtsen
2020-12-07 23:47 ` Lars Ingebrigtsen
2020-12-08 0:04 ` Gregory Heytings via Emacs development discussions.
2020-12-07 23:48 ` Lars Ingebrigtsen
2020-12-08 0:17 ` Gregory Heytings via Emacs development discussions.
2020-12-08 0:23 ` Lars Ingebrigtsen
2020-12-08 0:41 ` Lars Ingebrigtsen
2020-12-08 1:21 ` Lars Ingebrigtsen
2020-12-08 17:21 ` João Távora
2020-12-08 14:58 ` Eli Zaretskii
2020-12-08 15:07 ` Lars Ingebrigtsen
2020-12-08 15:19 ` Lars Ingebrigtsen
2020-12-08 16:17 ` Eli Zaretskii
2020-12-08 16:34 ` Lars Ingebrigtsen
2020-12-08 16:56 ` Eli Zaretskii
2020-12-08 17:52 ` Lars Ingebrigtsen
2020-12-08 16:11 ` Eli Zaretskii
2020-12-07 22:23 ` Alan Third
2020-12-07 22:32 ` Lars Ingebrigtsen
2020-12-07 18:50 ` Lars Ingebrigtsen
2020-12-07 19:26 ` Eli Zaretskii
2020-12-08 14:06 ` Lars Ingebrigtsen
2020-12-08 15:50 ` Eli Zaretskii
2020-12-08 15:56 ` Stefan Monnier
2020-12-08 16:21 ` Eli Zaretskii
2020-12-08 16:31 ` Lars Ingebrigtsen
2020-12-08 16:53 ` Eli Zaretskii
2020-12-08 17:29 ` Lars Ingebrigtsen
2020-12-08 17:36 ` Eli Zaretskii
2020-12-08 17:51 ` Lars Ingebrigtsen
2020-12-08 18:03 ` Eli Zaretskii
2020-12-08 18:39 ` Stefan Monnier
2020-12-08 19:12 ` Lars Ingebrigtsen
2020-12-08 19:36 ` Lars Ingebrigtsen [this message]
2020-12-08 20:21 ` Eli Zaretskii
2020-12-08 20:32 ` Lars Ingebrigtsen
2020-12-08 20:35 ` Lars Ingebrigtsen
2020-12-08 20:51 ` Lars Ingebrigtsen
2020-12-08 21:10 ` Alfred M. Szmidt
2020-12-08 21:41 ` Lars Ingebrigtsen
2020-12-08 22:31 ` Alfred M. Szmidt
2020-12-08 21:33 ` Stefan Monnier
2020-12-08 22:46 ` Stefan Monnier
2020-12-08 22:58 ` Lars Ingebrigtsen
2020-12-08 23:10 ` Stefan Monnier
2020-12-08 23:43 ` Lars Ingebrigtsen
2020-12-09 18:49 ` Eli Zaretskii
2020-12-09 21:01 ` Stefan Monnier
2020-12-10 3:36 ` Eli Zaretskii
2020-12-10 16:21 ` Stefan Monnier
2020-12-07 16:06 ` Óscar Fuentes
2020-12-07 16:15 ` Gregory Heytings via Emacs development discussions.
2020-12-07 16:16 ` Eli Zaretskii
2020-12-07 15:21 ` Jean Louis
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y2i89jjk.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=ghe@sdf.org \
--cc=monnier@iro.umontreal.ca \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).