Subject: Re: bug#77924: 31.0.50; [Feature branch] Change marker implementation

From: Visuwesh <[email-masked]>
Date: Thu, 24 Apr 2025 15:08:07 +0530

[வியாழன் ஏப்ரல் 24, 2025] Gerd Möllmann wrote:

> Eli Zaretskii <[email-masked]> writes:
>
>> I trust you and Stefan to decide on that.  I myself am not familiar
>> with the elisp-benchmarks suite well enough to have an opinion that is
>> of importance.  From where I stand, the important part is comparing
>> the current master with the branch.
>>
>>> Don't know about the scrolling benchmark. Is what is in elisp-benchmarks
>>> enough? If not, can you please give me a bencnhmark file for what you
>>> want benchmarked?
>>
>> I don't know whether we have it in elisp-benchmarks, but if we don't,
>> then the following should be good enough:
>>
>> (defun scroll-up-benchmark ()
>>   (interactive)
>>   (let ((oldgc gcs-done)
>>         (oldtime (float-time)))
>>     (condition-case nil (while t (scroll-up) (redisplay))
>>       (error (message "GCs: %d Elapsed time: %f seconds"
>>                       (- gcs-done oldgc) (- (float-time) oldtime))))))
>>
>> Evaluate this, then invoke "M-x scroll-up-benchmark" in a large buffer
>> with lots of non-ASCII characters.  Compare the timings between the
>> two versions of Emacs.
>
> elb-scroll from elisp-bechmarks is basically
>
>       (dotimes (_ 10)
>         (elb-smie-mode)
>         (goto-char (point-min))
>         (condition-case nil
>             (while t (scroll-up nil) (redisplay 'force))
>           (end-of-buffer nil))))))
>
> looks similar, but I don't know what elb-smie-mode does.

elb-smie-mode's is Stefan's SMIE demo as a C major-mode AFAIU.

> Seems to have something to do with prog-mode, so maybe this depends on
> the test file being a C file, which might be interesting for Visuwesh.

I commented out (elb-smie-mode) form in the above snippet and that
showed a backtrace which I could not explain.  Replacing the form with
(text-mode) didn't help either.  So I'm running the benchmark with that
form intact, even though the file I'm scrolling through is a text file.
I am running the benchmark currently, and will report the results once
they are done.

Debugger entered--Lisp error: (overflow-error)
  round(-0.0e+NaN)
  (let ((squares (apply #'+ (mapcar #'(lambda (x) (expt x 2)) errs)))) (round (/ (* 100 (sqrt squares)) elapsed)))
  (format "|%2d%%\n" (let ((squares (apply #'+ (mapcar #'(lambda ... ...) errs)))) (round (/ (* 100 (sqrt squares)) elapsed))))
  (insert (format "|%2d%%\n" (let ((squares (apply #'+ (mapcar #'... errs)))) (round (/ (* 100 (sqrt squares)) elapsed)))))
  (let* ((--cl-var-- tests) (test nil) (l nil) (test-elapsed nil) (test-gcs nil) (test-gc-elapsed nil) (test-err nil) (elapsed 0) (gcs 0) (gc-elapsed 0) (errs nil) (--cl-var-- t)) (while (consp --cl-var--) (setq test (car --cl-var--)) (setq l (gethash test res)) (setq test-elapsed (let* ((--cl-var-- l) (x nil) (--cl-var-- 0)) (while (consp --cl-var--) (setq x (car --cl-var--)) (setq --cl-var-- (+ --cl-var-- (car x))) (setq --cl-var-- (cdr --cl-var--))) --cl-var--)) (setq test-gcs (let* ((--cl-var-- l) (x nil) (--cl-var-- 0)) (while (consp --cl-var--) (setq x (car --cl-var--)) (setq --cl-var-- (+ --cl-var-- (car ...))) (setq --cl-var-- (cdr --cl-var--))) --cl-var--)) (setq test-gc-elapsed (let* ((--cl-var-- l) (x nil) (--cl-var-- 0)) (while (consp --cl-var--) (setq x (car --cl-var--)) (setq --cl-var-- (+ --cl-var-- (car ...))) (setq --cl-var-- (cdr --cl-var--))) --cl-var--)) (setq test-err (if (cdr l) (elb-std-deviation (mapcar #'car l)))) (insert (apply #'format "|%s|%.2f|%.2f|%d|%.2f" test (mapcar #'(lambda (x) (/ x runs)) (list (- test-elapsed test-gc-elapsed) test-gc-elapsed test-gcs test-elapsed)))) (insert (format "|%2d%%\n" (if test-err (round (/ (* 100 test-err) test-elapsed)) -0.0))) (setq elapsed (+ elapsed test-elapsed)) (setq gcs (+ gcs test-gcs)) (setq gc-elapsed (+ gc-elapsed test-gc-elapsed)) (setq errs (nconc errs (list (or test-err -0.0)))) (setq --cl-var-- (cdr --cl-var--)) (setq --cl-var-- nil)) (insert "|-\n") (insert (apply #'format "|total|%.2f|%.2f|%d|%.2f" (mapcar #'(lambda (x) (/ x runs)) (list (- elapsed gc-elapsed) gc-elapsed gcs elapsed)))) (insert (format "|%2d%%\n" (let ((squares (apply #'+ (mapcar ... errs)))) (round (/ (* 100 (sqrt squares)) elapsed))))) nil)
  elb--display(("scroll") #<hash-table equal 0/0 0x10e69c524987 ...> 1)
  (while (>= (setq --cl-var-- (1- --cl-var--)) 0) (message "Iteration number: %d" i) (let* ((--cl-var-- tests) (test nil) (entry-point nil) (--cl-var-- t)) (while (consp --cl-var--) (setq test (car --cl-var--)) (setq entry-point (intern (concat "elb-" test "-entry"))) (garbage-collect) (message "Running %s..." test) (let ((time (condition-case err (condition-case nil ... ...) (... ... nil)))) (if time (progn (let* (... ...) (puthash v ... v))))) (setq --cl-var-- (cdr --cl-var--)) (setq --cl-var-- nil)) nil) (elb--display tests res i) (setq i (+ i 1)))
  (let* ((runs (or runs elb-runs)) (--cl-var-- runs) (i 1)) (while (>= (setq --cl-var-- (1- --cl-var--)) 0) (message "Iteration number: %d" i) (let* ((--cl-var-- tests) (test nil) (entry-point nil) (--cl-var-- t)) (while (consp --cl-var--) (setq test (car --cl-var--)) (setq entry-point (intern (concat "elb-" test "-entry"))) (garbage-collect) (message "Running %s..." test) (let ((time (condition-case err ... ...))) (if time (progn (let* ... ...)))) (setq --cl-var-- (cdr --cl-var--)) (setq --cl-var-- nil)) nil) (elb--display tests res i) (setq i (+ i 1))) nil)
  (let ((tests (let ((names 'nil)) (mapatoms #'(lambda (s) (let ... ...))) (sort names #'string-lessp)))) (let* ((runs (or runs elb-runs)) (--cl-var-- runs) (i 1)) (while (>= (setq --cl-var-- (1- --cl-var--)) 0) (message "Iteration number: %d" i) (let* ((--cl-var-- tests) (test nil) (entry-point nil) (--cl-var-- t)) (while (consp --cl-var--) (setq test (car --cl-var--)) (setq entry-point (intern (concat "elb-" test "-entry"))) (garbage-collect) (message "Running %s..." test) (let ((time ...)) (if time (progn ...))) (setq --cl-var-- (cdr --cl-var--)) (setq --cl-var-- nil)) nil) (elb--display tests res i) (setq i (+ i 1))) nil))
  (let* ((native-comp-speed elb-speed) (compilation-safety elb-safety) (compile-function (if (featurep 'native-compile) #'native-compile #'byte-compile-file)) (res (make-hash-table :test #'equal)) (sources (directory-files elb-bench-directory t "\\.el\\'")) (test-sources (if selector (let* ((--cl-var-- sources) (f nil) (--cl-var-- nil)) (while (consp --cl-var--) (setq f (car --cl-var--)) (if (string-match selector f) (progn ...)) (setq --cl-var-- (cdr --cl-var--))) (nreverse --cl-var--)) sources))) (if recompile (progn (mapc #'(lambda (f) (message "Compiling... %s" f) (funcall compile-function f)) test-sources))) (mapc #'(lambda (file) (condition-case err (load file) ((debug error) (message "Error loading: %S" err) nil))) (mapcar (if (and (featurep 'native-compile) (fboundp 'comp-el-to-eln-filename)) #'comp-el-to-eln-filename #'file-name-sans-extension) test-sources)) (let ((tests (let ((names 'nil)) (mapatoms #'(lambda ... ...)) (sort names #'string-lessp)))) (let* ((runs (or runs elb-runs)) (--cl-var-- runs) (i 1)) (while (>= (setq --cl-var-- (1- --cl-var--)) 0) (message "Iteration number: %d" i) (let* ((--cl-var-- tests) (test nil) (entry-point nil) (--cl-var-- t)) (while (consp --cl-var--) (setq test (car --cl-var--)) (setq entry-point (intern ...)) (garbage-collect) (message "Running %s..." test) (let (...) (if time ...)) (setq --cl-var-- (cdr --cl-var--)) (setq --cl-var-- nil)) nil) (elb--display tests res i) (setq i (+ i 1))) nil)))
  (progn (if --cl-rest-- (signal 'wrong-number-of-arguments (list 'elisp-benchmarks-run (+ 3 (length --cl-rest--))))) (let* ((native-comp-speed elb-speed) (compilation-safety elb-safety) (compile-function (if (featurep 'native-compile) #'native-compile #'byte-compile-file)) (res (make-hash-table :test #'equal)) (sources (directory-files elb-bench-directory t "\\.el\\'")) (test-sources (if selector (let* ((--cl-var-- sources) (f nil) (--cl-var-- nil)) (while (consp --cl-var--) (setq f ...) (if ... ...) (setq --cl-var-- ...)) (nreverse --cl-var--)) sources))) (if recompile (progn (mapc #'(lambda (f) (message "Compiling... %s" f) (funcall compile-function f)) test-sources))) (mapc #'(lambda (file) (condition-case err (load file) ((debug error) (message "Error loading: %S" err) nil))) (mapcar (if (and (featurep 'native-compile) (fboundp 'comp-el-to-eln-filename)) #'comp-el-to-eln-filename #'file-name-sans-extension) test-sources)) (let ((tests (let ((names ...)) (mapatoms #'...) (sort names #'string-lessp)))) (let* ((runs (or runs elb-runs)) (--cl-var-- runs) (i 1)) (while (>= (setq --cl-var-- (1- --cl-var--)) 0) (message "Iteration number: %d" i) (let* ((--cl-var-- tests) (test nil) (entry-point nil) (--cl-var-- t)) (while (consp --cl-var--) (setq test ...) (setq entry-point ...) (garbage-collect) (message "Running %s..." test) (let ... ...) (setq --cl-var-- ...) (setq --cl-var-- nil)) nil) (elb--display tests res i) (setq i (+ i 1))) nil))))
  (let* ((recompile (if --cl-rest-- (car-safe (prog1 --cl-rest-- (setq --cl-rest-- (cdr --cl-rest--)))) t)) (runs (car-safe (prog1 --cl-rest-- (setq --cl-rest-- (cdr --cl-rest--)))))) (progn (if --cl-rest-- (signal 'wrong-number-of-arguments (list 'elisp-benchmarks-run (+ 3 (length --cl-rest--))))) (let* ((native-comp-speed elb-speed) (compilation-safety elb-safety) (compile-function (if (featurep 'native-compile) #'native-compile #'byte-compile-file)) (res (make-hash-table :test #'equal)) (sources (directory-files elb-bench-directory t "\\.el\\'")) (test-sources (if selector (let* (... ... ...) (while ... ... ... ...) (nreverse --cl-var--)) sources))) (if recompile (progn (mapc #'(lambda ... ... ...) test-sources))) (mapc #'(lambda (file) (condition-case err (load file) (... ... nil))) (mapcar (if (and (featurep ...) (fboundp ...)) #'comp-el-to-eln-filename #'file-name-sans-extension) test-sources)) (let ((tests (let (...) (mapatoms ...) (sort names ...)))) (let* ((runs (or runs elb-runs)) (--cl-var-- runs) (i 1)) (while (>= (setq --cl-var-- ...) 0) (message "Iteration number: %d" i) (let* (... ... ... ...) (while ... ... ... ... ... ... ... ...) nil) (elb--display tests res i) (setq i (+ i 1))) nil)))))
  elisp-benchmarks-run("elb-scroll" t 100)
  (progn (elisp-benchmarks-run "elb-scroll" t 100))
  eval((progn (elisp-benchmarks-run "elb-scroll" t 100)) t)
  elisp--eval-last-sexp(nil)
  #f(compiled-function () #<bytecode 0xf3e77a510d12>)()
  handler-bind-1(#f(compiled-function () #<bytecode 0xf3e77a510d12>) (error) eval-expression--debug)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)