unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Antipov <dmantipov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>, Sebastien Vauban <sva-news@mygooglest.com>
Cc: 15876@debbugs.gnu.org
Subject: bug#15876: 24.3.50; Highly degraded performance between rev 114715 and 115006
Date: Mon, 02 Dec 2013 14:45:25 +0400	[thread overview]
Message-ID: <529C64C5.2040509@yandex.ru> (raw)
In-Reply-To: <83haas5y88.fsf@gnu.org>

On 12/01/2013 08:31 PM, Eli Zaretskii wrote:

> Dmitry, can you please look into this?  I'm not familiar enough with
> the font stuff, so I don't see how was the font-spec and its
> font-entities stored in the font cache supposed to be referenced from
> some other Lisp object, to make sure they are marked and not GC'ed.

It should be easy - just use this:

=== modified file 'src/alloc.c'
--- src/alloc.c	2013-12-01 22:33:13 +0000
+++ src/alloc.c	2013-12-02 09:32:55 +0000
@@ -5731,7 +5731,18 @@
    eassert (!VECTOR_MARKED_P (ptr));
    VECTOR_MARK (ptr);		/* Else mark it.  */
    if (size & PSEUDOVECTOR_FLAG)
-    size &= PSEUDOVECTOR_SIZE_MASK;
+    {
+      size &= PSEUDOVECTOR_SIZE_MASK;
+      if (PSEUDOVECTOR_TYPEP (&ptr->header, PVEC_FONT))
+	{
+	  Lisp_Object tmp;
+	  XSETFONT (tmp, ptr);
+	  if (FONT_SPEC_P (tmp))
+	    fprintf (stderr, "mark font-spec\n");
+	  else if (FONT_ENTITY_P (tmp))
+	    fprintf (stderr, "mark font-entity\n");
+	}
+    }

and set breakpoints to fprintf(). I tried this and see that font-spec
objects can be referenced from face caches:

(gdb) bt 3 full
#0  mark_vectorlike (ptr=0x13178b8) at ../../trunk/src/alloc.c:5741
         tmp = {i = 20019389}
         size = 13
         i = 20019389
#1  0x00000000005ec050 in mark_object (arg=...) at ../../trunk/src/alloc.c:6084
         ptr = 0x13178b8
         pvectype = 15
         obj = {i = 20019384}
         cdr_count = 0
#2  0x00000000005eb92b in mark_face_cache (c=0x15049b0) at ../../trunk/src/alloc.c:5839
         face = 0x18d2050
         i = 2
         j = 15
(More stack frames follow...)

I.e. (struct face *)0x18d2050 has font-spec object in lface[15].

But the most of font-spec and font-entity objects are referenced via
staticpro'ed globals Vfontset_table and ft_face_cache. For example:

(gdb) bt 16
#0  mark_vectorlike (ptr=0x129a288) at ../../trunk/src/alloc.c:5741
#1  0x00000000005ec050 in mark_object (arg=...) at ../../trunk/src/alloc.c:6084
#2  0x00000000005eb5f0 in mark_vectorlike (ptr=0x1296428) at ../../trunk/src/alloc.c:5752
#3  0x00000000005ec050 in mark_object (arg=...) at ../../trunk/src/alloc.c:6084
#4  0x00000000005eb5f0 in mark_vectorlike (ptr=0x129a4d0) at ../../trunk/src/alloc.c:5752
#5  0x00000000005ec050 in mark_object (arg=...) at ../../trunk/src/alloc.c:6084
#6  0x00000000005eb725 in mark_char_table (ptr=0x1788060) at ../../trunk/src/alloc.c:5779
#7  0x00000000005eb717 in mark_char_table (ptr=0x12094d0) at ../../trunk/src/alloc.c:5776
#8  0x00000000005eb717 in mark_char_table (ptr=0x13e2578) at ../../trunk/src/alloc.c:5776
#9  0x00000000005eb717 in mark_char_table (ptr=0xd85188) at ../../trunk/src/alloc.c:5776
#10 0x00000000005ec02c in mark_object (arg=...) at ../../trunk/src/alloc.c:6069
#11 0x00000000005eb5f0 in mark_vectorlike (ptr=0xd85080) at ../../trunk/src/alloc.c:5752
#12 0x00000000005ec050 in mark_object (arg=...) at ../../trunk/src/alloc.c:6084
#13 0x00000000005eac4b in Fgarbage_collect () at ../../trunk/src/alloc.c:5489
#14 0x0000000000563500 in maybe_gc () at ../../trunk/src/lisp.h:4462
#15 0x000000000060ec3e in Ffuncall (nargs=2, args=0x7fffffff0790) at ../../trunk/src/eval.c:2756
(gdb) bt 16 full
...
#13 0x00000000005eac4b in Fgarbage_collect () at ../../trunk/src/alloc.c:5489
         nextb = 0x0
         stack_top_variable = 0 '\000'
         i = 1491
         message_p = false
         count = 140
         start = {tv_sec = 1385977872, tv_nsec = 656653658}
         retval = {i = 13914818}
         tot_before = 0
...
(gdb) p staticvec[1491]
$8 = (Lisp_Object *) 0xd25cb0 <Vfontset_table>

> In any case, it seems like they are never marked on Windows, because
> if I set a breakpoint in the line marked below:
>
> 	  /* If font-spec is not marked, most likely all font-entities
> 	     are not marked too.  But we must be sure that nothing is
> 	     marked within OBJ before we really drop it.  */
> 	  for (i = 0; i < size; i++)
> 	    if (VECTOR_MARKED_P (XFONT_ENTITY (AREF (XCDR (obj), i))))
> 	      break;
>
> 	  if (i == size)  <<<<<<<<<<<<<<<<<<<<<
> 	    drop = 1;
> 	}
>
> with a condition i != size, that breakpoint never breaks.

The best way to hit this breakpoint is to run something like:

(defun bloat-font ()
   (interactive)
   (let ((fonts (x-list-fonts "*")))
     (while fonts
       (condition-case nil (set-frame-font (car fonts)) (error nil))
       (setq fonts (cdr fonts))
       (redisplay))))

(This is X-specific; I believe there should be a similar MS-Windows method).

Subtle "triangle example" works just fine for me (with default font used by
GTK3 build and 'emacs -Q' at least).

Also I'm curious how to reproduce this issue with X. In particular, how to
find a font so "heavy" that an attempt to load it creates a lot of Lisp data
(hundreds Kbytes, enough to reach gc_cons_threshold each time)?

Dmitry






  reply	other threads:[~2013-12-02 10:45 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-12 15:32 bug#15876: 24.3.50; Highly degraded performance between rev 114715 and 115006 Sebastien Vauban
2013-11-12 17:11 ` Glenn Morris
     [not found]   ` <wzwqkdfsts.fsf-iW7gFb+/I3LZHJUXO5efmti2O/JbrIOy@public.gmane.org>
2013-11-12 19:13     ` Sebastien Vauban
2013-11-13 11:43       ` Dani Moncayo
     [not found]       ` <mailman.5954.1384343055.10748.bug-gnu-emacs@gnu.org>
2013-11-13 13:58         ` Sebastien Vauban
     [not found]   ` <mailman.5925.1384283656.10748.bug-gnu-emacs@gnu.org>
     [not found]     ` <mailman.5925.1384283656.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-11-13 14:04       ` Sebastien Vauban
2013-11-13 16:11         ` Eli Zaretskii
     [not found]           ` <83fvr01du4.fsf-mXXj517/zsQ@public.gmane.org>
2013-11-13 20:23             ` Sebastien Vauban
2013-11-13 20:35               ` Eli Zaretskii
2013-11-14  3:05               ` Glenn Morris
     [not found]                 ` <jxeh6j1y4x.fsf-iW7gFb+/I3LZHJUXO5efmti2O/JbrIOy@public.gmane.org>
2013-11-14 10:05                   ` Sebastien Vauban
     [not found]                 ` <mailman.6048.1384423574.10748.bug-gnu-emacs@gnu.org>
2013-11-14 10:13                   ` Sebastien Vauban
2013-11-14 17:04                     ` Glenn Morris
     [not found]                   ` <mailman.6048.1384423574.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-11-19 22:52                     ` Sebastien Vauban
2013-11-20  1:47                       ` Stefan Monnier
2013-11-20  3:53                         ` Eli Zaretskii
2013-11-20  3:48                       ` Eli Zaretskii
     [not found]                       ` <mailman.6579.1384912163.10748.bug-gnu-emacs@gnu.org>
     [not found]                         ` <mailman.6579.1384912163.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-11-20  8:48                           ` Sebastien Vauban
     [not found]                   ` <mailman.6575.1384901595.10748.bug-gnu-emacs@gnu.org>
     [not found]                     ` <mailman.6575.1384901595.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-11-20 22:32                       ` Sebastien Vauban
2013-11-21  3:42                         ` Eli Zaretskii
     [not found]                         ` <mailman.6739.1385005456.10748.bug-gnu-emacs@gnu.org>
     [not found]                           ` <mailman.6739.1385005456.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-11-26 20:52                             ` Sebastien Vauban
2013-11-26 21:04                               ` Eli Zaretskii
     [not found]                               ` <mailman.7212.1385499914.10748.bug-gnu-emacs@gnu.org>
     [not found]                                 ` <mailman.7212.1385499914.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-11-29 21:01                                   ` Sebastien Vauban
2013-12-01 16:31                                     ` Eli Zaretskii
2013-12-02 10:45                                       ` Dmitry Antipov [this message]
2013-12-02 11:43                                         ` Dmitry Antipov
2013-12-02 18:00                                           ` Eli Zaretskii
2013-12-02 17:52                                         ` Eli Zaretskii
2013-12-03  9:57                                           ` Dmitry Antipov
2013-12-03 13:16                                             ` Eli Zaretskii
2013-12-03 15:09                                               ` Dmitry Antipov
2013-12-04 17:53                                                 ` Eli Zaretskii
2013-12-05  6:29                                                   ` Dmitry Antipov
2013-12-05 17:36                                                     ` Eli Zaretskii
2013-12-11  6:52                                                       ` Dmitry Antipov
2013-12-11  7:16                                                         ` bug#15876: [SPAM] " Jarek Czekalski
2013-12-11  9:24                                                           ` Dmitry Antipov
2013-12-11 16:28                                                         ` Eli Zaretskii
2013-12-11 18:00                                                           ` Dmitry Antipov
2013-12-11 18:12                                                             ` Eli Zaretskii
2013-12-11 19:50                                                               ` Jan Djärv
2013-12-13 15:22                                                                 ` Eli Zaretskii
2013-12-13 16:12                                                                   ` Dmitry Antipov
2013-12-13 16:45                                                                     ` Stefan Monnier
2013-12-13 18:53                                                                       ` Eli Zaretskii
2013-12-13 18:44                                                                     ` Eli Zaretskii
2013-12-16  8:05                                                                       ` Dmitry Antipov
2013-12-13 16:50                                                                   ` Stefan Monnier
2013-12-13 18:55                                                                     ` Eli Zaretskii
2013-12-14  2:13                                                                       ` Stefan Monnier
2013-12-14  8:47                                                                   ` Jan Djärv
     [not found]                                     ` <mailman.7746.1385915595.10748.bug-gnu-emacs@gnu.org>
     [not found]                                       ` <mailman.7746.1385915595.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-12-01 20:20                                         ` Sebastien Vauban
2013-12-01 20:37                                           ` Eli Zaretskii
     [not found]                                           ` <mailman.7763.1385930292.10748.bug-gnu-emacs@gnu.org>
     [not found]                                             ` <mailman.7763.1385930292.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-12-01 21:51                                               ` Sebastien Vauban
2013-12-02  3:45                                                 ` Eli Zaretskii
     [not found]                                                 ` <mailman.7786.1385955973.10748.bug-gnu-emacs@gnu.org>
     [not found]                                                   ` <mailman.7786.1385955973.10748.bug-gnu-emacs-mXXj517/zsQ@public.gmane.org>
2013-12-02  9:29                                                     ` Sebastien Vauban
2013-11-13 16:52         ` Stefan Monnier
2013-11-14 11:03 ` Jarek Czekalski
2013-11-14 16:35   ` Eli Zaretskii

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=529C64C5.2040509@yandex.ru \
    --to=dmantipov@yandex.ru \
    --cc=15876@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=sva-news@mygooglest.com \
    /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).