From: Eli Zaretskii <eliz@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>,
Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 65491@debbugs.gnu.org
Subject: bug#65491: [PATCH] Improve performance allocating vectors
Date: Sat, 26 Aug 2023 10:14:28 +0300 [thread overview]
Message-ID: <83bkeumg17.fsf@gnu.org> (raw)
In-Reply-To: <87y1i0iwvu.fsf@localhost> (message from Ihor Radchenko on Thu, 24 Aug 2023 09:59:33 +0000)
> From: Ihor Radchenko <yantar92@posteo.net>
> Date: Thu, 24 Aug 2023 09:59:33 +0000
>
> Following up the bignum performance discussion in
> https://yhetil.org/emacs-devel/87bkfdsmde.fsf@localhost
>
> This patch adds a heuristic that reduces the time spent searching
> `vector_free_lists' when trying to allocate a new vector.
>
> `vector_free_lists' is a rather long array with few hundreds of
> elements. And it does not make sense to check the whole array in
> `allocate_vector_from_block' if we can get information about free vector
> that was recently made available of if we know for sure that no free
> vectors are available (after GC).
>
> In the patch, we start searching `vector_free_lists' no earlier than the
> last known index of the available free vector, or skip the search
> entirely when there is known index (after sweep).
>
> The described approach may sometimes miss free vectors in
> `vector_free_lists', especially if the allocation happens from larger
> vector to smaller. The cost will be slightly higher memory consumption -
> no larger than VECTOR_MAX_FREE_LIST_INDEX extra free vectors.
>
> With the patch, CPU time spent allocating new vectors in the fib.eln
> test from https://yhetil.org/emacs-devel/87bkfdsmde.fsf@localhost drops 10x.
>
> Also, the patch gives a noticeable improvement when running
> elisp-benchmarks (ELPA package). The overall speedup is around 10%
> (including unaffected tests).
>
> No single test gets worse within error margins and the following tests
> get a significant speedup:
>
> - eieio 1.32±0.04 -> 1.04±0.03
> - pack-unpack 0.40±0.00 -> 0.35±0.01
> - pidigits 6.00±0.06 -> 4.08±0.12
>
> pidigits is no surprise as it likely uses bignums.
>
> * Results without the patch
>
> | test | non-gc avg (s) | gc avg (s) | gcs avg | tot avg (s) | tot avg err (s) |
> |--------------------+----------------+------------+---------+-------------+-----------------|
> | bubble | 0.68 | 0.06 | 1 | 0.73 | 0.05 |
> | bubble-no-cons | 1.17 | 0.00 | 0 | 1.17 | 0.07 |
> | bytecomp | 1.64 | 0.32 | 13 | 1.95 | 0.03 |
> | dhrystone | 2.13 | 0.00 | 0 | 2.13 | 0.02 |
> | eieio | 1.19 | 0.13 | 7 | 1.32 | 0.04 |
> | fibn | 0.00 | 0.00 | 0 | 0.00 | 0.00 |
> | fibn-named-let | 1.47 | 0.00 | 0 | 1.47 | 0.04 |
> | fibn-rec | 0.00 | 0.00 | 0 | 0.00 | 0.00 |
> | fibn-tc | 0.00 | 0.00 | 0 | 0.00 | 0.00 |
> | flet | 1.41 | 0.00 | 0 | 1.41 | 0.03 |
> | inclist | 0.84 | 0.00 | 0 | 0.84 | 0.03 |
> | inclist-type-hints | 0.76 | 0.00 | 0 | 0.76 | 0.00 |
> | listlen-tc | 0.12 | 0.00 | 0 | 0.12 | 0.01 |
> | map-closure | 5.25 | 0.00 | 0 | 5.25 | 0.02 |
> | nbody | 1.47 | 0.15 | 1 | 1.62 | 0.07 |
> | pack-unpack | 0.38 | 0.02 | 1 | 0.40 | 0.00 |
> | pack-unpack-old | 1.13 | 0.05 | 3 | 1.19 | 0.03 |
> | pcase | 1.77 | 0.00 | 0 | 1.77 | 0.01 |
> | pidigits | 5.04 | 0.97 | 17 | 6.00 | 0.06 |
> | scroll | 0.58 | 0.00 | 0 | 0.58 | 0.02 |
> | smie | 1.47 | 0.05 | 2 | 1.52 | 0.02 |
> |--------------------+----------------+------------+---------+-------------+-----------------|
> | total | 28.49 | 1.74 | 45 | 30.23 | 0.16 |
>
> * Results with the patch
>
> | test | non-gc avg (s) | gc avg (s) | gcs avg | tot avg (s) | tot avg err (s) |
> |--------------------+----------------+------------+---------+-------------+-----------------|
> | bubble | 0.69 | 0.05 | 1 | 0.74 | 0.07 |
> | bubble-no-cons | 1.03 | 0.00 | 0 | 1.03 | 0.02 |
> | bytecomp | 1.45 | 0.25 | 13 | 1.70 | 0.10 |
> | dhrystone | 1.98 | 0.00 | 0 | 1.98 | 0.05 |
> | eieio | 0.92 | 0.12 | 7 | 1.04 | 0.03 |
> | fibn | 0.00 | 0.00 | 0 | 0.00 | 0.00 |
> | fibn-named-let | 1.45 | 0.00 | 0 | 1.45 | 0.12 |
> | fibn-rec | 0.00 | 0.00 | 0 | 0.00 | 0.00 |
> | fibn-tc | 0.00 | 0.00 | 0 | 0.00 | 0.00 |
> | flet | 1.39 | 0.00 | 0 | 1.39 | 0.07 |
> | inclist | 0.83 | 0.00 | 0 | 0.83 | 0.03 |
> | inclist-type-hints | 0.77 | 0.00 | 0 | 0.77 | 0.03 |
> | listlen-tc | 0.10 | 0.00 | 0 | 0.10 | 0.00 |
> | map-closure | 5.25 | 0.00 | 0 | 5.25 | 0.37 |
> | nbody | 1.45 | 0.16 | 1 | 1.60 | 0.05 |
> | pack-unpack | 0.33 | 0.02 | 1 | 0.35 | 0.01 |
> | pack-unpack-old | 1.07 | 0.06 | 3 | 1.13 | 0.08 |
> | pcase | 1.78 | 0.00 | 0 | 1.78 | 0.05 |
> | pidigits | 3.15 | 0.92 | 17 | 4.08 | 0.12 |
> | scroll | 0.55 | 0.00 | 0 | 0.55 | 0.01 |
> | smie | 1.45 | 0.04 | 2 | 1.49 | 0.06 |
> |--------------------+----------------+------------+---------+-------------+-----------------|
> | total | 25.63 | 1.62 | 45 | 27.25 | 0.45 |
>
Stefan, any comments?
my comment is that the savings are quite small, so it seems, so I'm
not sure we should install this.
next prev parent reply other threads:[~2023-08-26 7:14 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 9:59 bug#65491: [PATCH] Improve performance allocating vectors Ihor Radchenko
2023-08-26 7:14 ` Eli Zaretskii [this message]
2023-08-26 7:27 ` Ihor Radchenko
2023-08-26 7:31 ` Eli Zaretskii
2023-08-26 7:51 ` Ihor Radchenko
2023-08-26 8:07 ` Ihor Radchenko
2023-08-26 9:01 ` Eli Zaretskii
2023-08-26 7:47 ` Ihor Radchenko
2023-08-26 12:01 ` Mattias Engdegård
2023-08-26 14:54 ` Ihor Radchenko
2023-08-26 14:55 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-27 9:54 ` Mattias Engdegård
2023-09-16 14:58 ` Mattias Engdegård
2023-09-16 16:12 ` Eli Zaretskii
2023-09-16 16:17 ` Eli Zaretskii
2023-09-16 16:32 ` Mattias Engdegård
2023-09-16 16:54 ` Eli Zaretskii
2023-09-16 17:03 ` Mattias Engdegård
2023-09-16 17:11 ` Eli Zaretskii
2023-09-17 3:02 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-17 17:02 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18 2:19 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18 2:27 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18 3:08 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18 4:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-16 16:54 ` Mattias Engdegård
2023-09-16 17:09 ` Eli Zaretskii
2023-09-16 17:22 ` Mattias Engdegård
2023-09-16 18:19 ` Eli Zaretskii
2023-09-16 19:04 ` Mattias Engdegård
2023-09-16 19:46 ` Paul Eggert
2023-09-17 5:18 ` Eli Zaretskii
2023-09-17 15:22 ` Paul Eggert
2023-09-17 16:15 ` Eli Zaretskii
2023-09-17 16:37 ` Paul Eggert
2023-09-17 16:44 ` Eli Zaretskii
2023-09-18 16:10 ` Mattias Engdegård
2023-09-18 17:13 ` Eli Zaretskii
2023-09-19 13:28 ` Mattias Engdegård
2023-09-19 14:04 ` Eli Zaretskii
2023-09-19 14:05 ` Mattias Engdegård
2023-09-25 16:06 ` Mattias Engdegård
2023-08-27 16:21 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-28 10:14 ` Ihor Radchenko
2023-08-28 16:32 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-28 12:47 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=83bkeumg17.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=65491@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=yantar92@posteo.net \
/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).