[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some thoughts about Emacs performance

From: Arthur Miller
Subject: Re: Some thoughts about Emacs performance
Date: Fri, 09 Feb 2024 00:53:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

>Robert Boyer <robertstephenboyer@gmail.com> writes:
>> Emacs 27.1 has a 'sort' function that takes longer than stable-sort of
>> SBCL. Maybe
>> by a factor of 2. See also my attached file 'ms.lisp'.
>> There may be a lot that can be improved in Emacs'
>> handling of cl-loop, setf, elt, or cl-random.
>When comparing Elisp and SBCL, it is more fair to compare
>native-compiler Elisp rather than byte-compiled.
>Then, both codes are compiled to machine code.

The sort is implemented in C, so it does not matter so much, but I did compiled
to native with comp-speed 3, and I have replaced cl-random (lisp) call with call
to random (C).

What I have seen was that on first few runs, sbcl was faster.

Definitely not as a drammatic difference as in Robert's test,
but SBCL was still somewhat faster:


(benchmark 1 '(setq foo (make-random-array (expt 10 n))))
Elapsed time: 0.097354s (0.053204s in 1 GCs)

(benchmark 1 '(sort foo '<))
Elapsed time: 0.271281s

CL-USER> (time (defparameter foo (make-random-array (expt 10 n))))

Evaluation took:
  0.020 seconds of real time
  0.015625 seconds of total run time (0.000000 user, 0.015625 system)
  80.00% CPU
  50,840,363 processor cycles
  8,000,016 bytes consed

CL-USER> (time (progn (stable-sort foo '<) nil))

Evaluation took:
  0.165 seconds of real time
  0.125000 seconds of total run time (0.109375 user, 0.015625 system)
  75.76% CPU
  413,349,272 processor cycles
  8,000,016 bytes consed

That was consistent for few times. However, after some time, Emacs was beating
SBCL in sorting.

Emacs for sort was varying 0.015 ~ 0.02; mostly ~0.017.

SBCL, was varying 0.065 ~ 0.085, mostly ~0.065.

For array creation, SBCL is beating Emacs, every time, by a magnitude. Emacs was
around 0.1 ~ 0.12, while SBCL was 0.017 ~ 0.022

Speeds were quite stable for both Emacs and SBCL in later runs.

Unfortunately I only have access to older sbcl version on Windows;
I have seen from the mailing list that they have been working on the sort
implementation so it will be exciting to see what they have come up with.

Emacs version:

GNU Emacs 29.2 (build 2, x86_64-w64-mingw32) of 2024-02-01 (build from GNU ftp
server 29.2_1 for Windows OS - can't build myself configure script fails)

CPU: 13th Gen Intel(R) Core(TM) i5-1345U   1.60 GHz
RAM: 16 GB
OS: Win 11 build 22H2

$ sbcl --version
SBCL 2.3.2

reply via email to

[Prev in Thread] Current Thread [Next in Thread]