Skip to content

[parse-speed-byte-compile] Investigating why I cannot reproduce results #1

@pkryger

Description

@pkryger

@errge Thank you for this report. I think it explains what the issue is and your conclusion pretty clearly.

I tried to apply your findings to file stdlib-changes from package package-lint. Since there was no exact example how to

[...] specify fixed utf-8 coding at the top of the saved data file

I went with a first line approach. Here's how my example data looks like:

$ diff --text stdlib-changes{,-coding}
0a1
> ;; -*- coding: utf-8-emacs -*-

Then I performed measurements. First with repeatedly loading data from file with no coding specified:

;; 2.24s on my machine
(let* ((gc-cons-threshold (* 500 1024 1024))
       (fname (expand-file-name "stdlib-changes"))
       (_gcbefore (garbage-collect))
       (measurement
        (benchmark-run 100
          (progn
            (setq my-data (with-temp-buffer (insert-file-contents fname) (read (current-buffer))))
	        (unless (assoc '(24 1) my-data) (error "wrong data")))))
       (_verify (cl-assert (eq 0 (cadr measurement))))
       )
  (car measurement))

Followed by loading data from file with specified coding:

;; 2.77 on my machine
(let* ((gc-cons-threshold (* 500 1024 1024))
       (fname (expand-file-name "stdlib-changes-coding"))
       (_gcbefore (garbage-collect))
       (measurement
        (benchmark-run 100
          (progn
            (setq my-data (with-temp-buffer (insert-file-contents fname) (read (current-buffer))))
	        (unless (assoc '(24 1) my-data) (error "wrong data")))))
       (_verify (cl-assert (eq 0 (cadr measurement))))
       )
  (car measurement))

As you can see, the results I got are exactly opposite what the finding in the report are: loading data from a file with coding specified takes longer than loading data from a file that doesn't specify coding. Would you mind helping me understanding why I am getting such a result?

Please let me know if you think that emacs-devel is a better place to have this discussion. I will move it.

Using Emacs MacPort 30.1.50 from this commit in jdsmith/emacs-mac.

FWIW: I've also repeated the experiment using my own implementation of Google Benchmark of interleaved samples methodology (to be found in my basic-stats package and got similar results, that is lloading file with coding specified is ~20% slower:

(use-package basic-stats
  :vc (:url "https://github.com/pkryger/basic-stats.el.git"
       :rev :newest))

(let ((default-directory "~/tmp"))
  (basic-stats-benchmark
      ((detect
        (package-lint--load-data "data/stdlib-changes"))
       (coding
        (package-lint--load-data "data/stdlib-changes-coding")))))

;; Sample results from my machine:
;; ((coding (repetitions . 36) (total-time . "662.592ms") (mean-time . "18.405ms")
;;          (gc . 0) (gc-time . "0.000s") (mean-time-sans-gc . "18.405ms")
;;          (times (min . "18.158ms") (q1 . "18.244ms") (med . "18.344ms")
;;                 (q3 . "18.555ms") (max . "18.798ms"))
;;          (times-sans-gc (min . "18.158ms") (q1 . "18.244ms") (med . "18.344ms")
;;                         (q3 . "18.555ms") (max . "18.798ms")))
;;  (detect (repetitions . 36) (total-time . "566.451ms") (mean-time . "15.735ms")
;;          (gc . 0) (gc-time . "0.000s") (mean-time-sans-gc . "15.735ms")
;;          (times (min . "15.378ms") (q1 . "15.527ms") (med . "15.703ms")
;;                 (q3 . "15.967ms") (max . "16.101ms"))
;;          (times-sans-gc (min . "15.378ms") (q1 . "15.527ms") (med . "15.703ms")
;;                         (q3 . "15.967ms") (max . "16.101ms"))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions