Subject: Re: bug#4222: calls to char_table_ref slow down 23.1 (vs 22.3)

From: Kenichi Handa <[email-masked]>
Date: Thu, 24 Sep 2009 13:05:18 +0900

In article <[email-masked]>, Kenichi Handa <[email-masked]> writes:

> We still have a problem of slow GC caused by many elements
> of char-tables (mostly because of charset encoders).  My
> idea for fixing it is to somehow distinguish a char-table
> that has only integer or (interned) symbol elements from the
> other normal char-tables, and optimize mark_char_table for
> it.  But, at the moment, I don't have a time to work on it.

I tried to implement a new function mark_charsets that marks
encoder char-tables of charsets in a special way, but it
improved the performance only a few percent.  It means that
the current loop in mark_char_table is fast enough.

By the way, I've misunderstood the output of gprof.

In article <[email-masked]>, Dan Nicolaescu <[email-masked]> writes:

> One big difference is then time/number of calls to mark_objects 
> 129733 vs 18834514, so 145 times more calls to mark_object.
> Do you know where do those come from?

Emacs 22 didn't have the function mark_vectorlike and
mark_object directly handled the marking of Lisp_Vectorlike
by recursive call.  And the number 129733 doesn't include
the number of such recursive calls.  The result of profiling
this execution:

% time LANG=C emacs-22/src/emacs -Q -batch --eval '(dotimes (i 100) (garbage-collect))'

shows this:
[8]     82.9    1.35    0.01  183705+25673200 mark_object <cycle 2> [8]

So the total number of calls is 25856905.  The similar tries
with Emacs 23 and the trunk are:

Emacs-23:
[12]    76.6    1.64    0.00 28911397+8925193 mark_object <cycle 2> [12]
Total number of calls is 37836590.

The trunk:
[12]    64.2    1.13    0.00 14102473+8981954 mark_object <cycle 2> [12]
Total number of calls is 23084427.

It seems that mark_char_table introduced in the trunk works
effectively and leads to less object marking than Emacs 22.

So, I think we can close this thread.

---
Kenichi Handa
[email-masked]