[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Redisplay slower in Emacs 28 than Emacs 27
From: |
Lars Ingebrigtsen |
Subject: |
Re: Redisplay slower in Emacs 28 than Emacs 27 |
Date: |
Tue, 08 Dec 2020 20:36:47 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
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
- Re: Redisplay slower in Emacs 28 than Emacs 27, (continued)
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Eli Zaretskii, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Eli Zaretskii, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Eli Zaretskii, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Stefan Monnier, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27,
Lars Ingebrigtsen <=
- Re: Redisplay slower in Emacs 28 than Emacs 27, Eli Zaretskii, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Alfred M. Szmidt, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Alfred M. Szmidt, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Stefan Monnier, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Stefan Monnier, 2020/12/08
- Re: Redisplay slower in Emacs 28 than Emacs 27, Lars Ingebrigtsen, 2020/12/08