contrib/hg-test-mode.el
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sat, 13 Apr 2024 23:40:28 +0200
changeset 51592 24844407fa0d
parent 46819 d4ba4d51f85f
permissions -rw-r--r--
perf: clear vfs audit_cache before each run When generating a stream clone, we spend a large amount of time auditing path. Before this changes, the first run was warming the vfs cache for the other runs, leading to a large runtime difference and a "faulty" reported timing for the operation. We now clear this important cache between run to get a more realistic timing. Below are some example of median time change when clearing these cases. The maximum time for a run did not changed significantly. ### data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog # benchmark.name = hg.perf.exchange.stream.generate # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.version = latest no-clearing: 17.289905 cache-clearing: 21.587965 (+24.86%, +4.30) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog no-clearing: 32.670748 cache-clearing: 40.467095 (+23.86%, +7.80) ## data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog no-clearing: 37.838858 cache-clearing: 46.072749 (+21.76%, +8.23) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog no-clearing: 32.969395 cache-clearing: 39.646209 (+20.25%, +6.68) In addition, this significantly reduce the timing difference between the performance command, from the perf extensions and a `real `hg bundle` call producing a stream bundle. Some significant differences remain especially on the "mozilla-try" repositories, but they are now smaller. Note that some of that difference will actually not be attributable to the stream generation (like maybe phases or branch map computation). Below are some benchmarks done on a currently draft changeset fixing some unrelated slowness in `hg bundle` (34a78972af409d1ff37c29e60f6ca811ad1a457d) ### data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default hg.perf.exchange.stream.generate: 21.587965 hg.command.bundle: 24.301799 (+12.57%, +2.71) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 40.467095 hg.command.bundle: 44.831317 (+10.78%, +4.36) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 39.646209 hg.command.bundle: 45.395258 (+14.50%, +5.75) ## data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog hg.perf.exchange.stream.generate: 46.072749 hg.command.bundle: 55.882608 (+21.29%, +9.81) ## data-env-vars.name = mozilla-try-2023-03-22-zlib-general-delta hg.perf.exchange.stream.generate: 334.716708 hg.command.bundle: 377.856767 (+12.89%, +43.14) ## data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 302.972301 hg.command.bundle: 326.098755 (+7.63%, +23.13)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22081
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     1
;; hg-test-mode.el - Major mode for editing Mercurial tests
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     2
;;
46819
d4ba4d51f85f contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents: 41788
diff changeset
     3
;; Copyright 2014 Olivia Mackall <olivia@selenic.com>
22081
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     4
;; "I have no idea what I'm doing"
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     5
;;
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     6
;; This software may be used and distributed according to the terms of the
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     7
;; GNU General Public License version 2 or any later version.
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     8
;;
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     9
;; To enable, add something like the following to your .emacs:
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    10
;;
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    11
;; (if (file-exists-p "~/hg/contrib/hg-test-mode.el")
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    12
;;    (load "~/hg/contrib/hg-test-mode.el"))
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    13
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    14
(defvar hg-test-mode-hook nil)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    16
(defvar hg-test-mode-map
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    17
  (let ((map (make-keymap)))
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    18
    (define-key map "\C-j" 'newline-and-indent)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    19
    map)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    20
  "Keymap for hg test major mode")
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    21
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    22
(add-to-list 'auto-mode-alist '("\\.t\\'" . hg-test-mode))
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    23
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    24
(defconst hg-test-font-lock-keywords-1
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    25
  (list
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    26
   '("^  \\(\\$\\|>>>\\) " 1 font-lock-builtin-face)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    27
   '("^  \\(>\\|\\.\\.\\.\\) " 1 font-lock-constant-face)
22125
7fce964be27d hg-test-mode: make exit code highlight work again
Matt Mackall <mpm@selenic.com>
parents: 22109
diff changeset
    28
   '("^  \\([[][0-9]+[]]\\)$" 1 font-lock-warning-face)
22109
feab93a24e81 hg-test-mode: don't highlight variables in output
Matt Mackall <mpm@selenic.com>
parents: 22092
diff changeset
    29
   '("^  \\(.*?\\)\\(\\( [(][-a-z]+[)]\\)*\\)$" 1 font-lock-string-face)
22092
6e5ff8e26af6 hg-test-mode: colorize HGFOO and TESTFOO environment variables
Matt Mackall <mpm@selenic.com>
parents: 22081
diff changeset
    30
   '("\\$?\\(HG\\|TEST\\)\\w+=?" . font-lock-variable-name-face)
22081
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    31
   '("^  \\(.*?\\)\\(\\( [(][-a-z]+[)]\\)+\\)$" 2 font-lock-type-face)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    32
   '("^#.*" . font-lock-preprocessor-face)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    33
   '("^\\([^ ].*\\)$" 1 font-lock-comment-face)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    34
   )
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    35
  "Minimal highlighting expressions for hg-test mode")
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    36
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    37
(defvar hg-test-font-lock-keywords hg-test-font-lock-keywords-1
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    38
  "Default highlighting expressions for hg-test mode")
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    39
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    40
(defvar hg-test-mode-syntax-table
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    41
  (let ((st (make-syntax-table)))
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    42
    (modify-syntax-entry ?\" "w" st) ;; disable standard quoting
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    43
    st)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    44
"Syntax table for hg-test mode")
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    45
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    46
(defun hg-test-mode ()
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    47
  (interactive)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    48
  (kill-all-local-variables)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    49
  (use-local-map hg-test-mode-map)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    50
  (set-syntax-table hg-test-mode-syntax-table)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    51
  (set (make-local-variable 'font-lock-defaults) '(hg-test-font-lock-keywords))
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    52
  (setq major-mode 'hg-test-mode)
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    53
  (setq mode-name "hg-test")
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    54
  (run-hooks 'hg-test-mode-hook))
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    55
41785
b6a757de2fff contrib: add compilation-mode linking for our test output
Augie Fackler <augie@google.com>
parents: 22125
diff changeset
    56
(with-eval-after-load "compile"
41786
b6c062bb4be3 contrib: also linkify tracebacks in compilation output when using hg-test-mode
Augie Fackler <augie@google.com>
parents: 41785
diff changeset
    57
  ;; Link to Python sources in tracebacks in .t failures.
b6c062bb4be3 contrib: also linkify tracebacks in compilation output when using hg-test-mode
Augie Fackler <augie@google.com>
parents: 41785
diff changeset
    58
  (add-to-list 'compilation-error-regexp-alist-alist
b6c062bb4be3 contrib: also linkify tracebacks in compilation output when using hg-test-mode
Augie Fackler <augie@google.com>
parents: 41785
diff changeset
    59
               '(hg-test-output-python-tb
b6c062bb4be3 contrib: also linkify tracebacks in compilation output when using hg-test-mode
Augie Fackler <augie@google.com>
parents: 41785
diff changeset
    60
                 "^\\+ +File ['\"]\\([^'\"]+\\)['\"], line \\([0-9]+\\)," 1 2))
b6c062bb4be3 contrib: also linkify tracebacks in compilation output when using hg-test-mode
Augie Fackler <augie@google.com>
parents: 41785
diff changeset
    61
  (add-to-list 'compilation-error-regexp-alist 'hg-test-output-python-tb)
41785
b6a757de2fff contrib: add compilation-mode linking for our test output
Augie Fackler <augie@google.com>
parents: 22125
diff changeset
    62
  ;; Link to source files in test-check-code.t violations.
b6a757de2fff contrib: add compilation-mode linking for our test output
Augie Fackler <augie@google.com>
parents: 22125
diff changeset
    63
  (add-to-list 'compilation-error-regexp-alist-alist
b6a757de2fff contrib: add compilation-mode linking for our test output
Augie Fackler <augie@google.com>
parents: 22125
diff changeset
    64
               '(hg-test-check-code-output
b6a757de2fff contrib: add compilation-mode linking for our test output
Augie Fackler <augie@google.com>
parents: 22125
diff changeset
    65
                 "\\+  \\([^:\n]+\\):\\([0-9]+\\):$" 1 2))
b6a757de2fff contrib: add compilation-mode linking for our test output
Augie Fackler <augie@google.com>
parents: 22125
diff changeset
    66
  (add-to-list 'compilation-error-regexp-alist 'hg-test-check-code-output))
b6a757de2fff contrib: add compilation-mode linking for our test output
Augie Fackler <augie@google.com>
parents: 22125
diff changeset
    67
41788
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    68
(defun hg-test-mode--test-one-error-line-regexp (test)
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    69
  (erase-buffer)
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    70
  (setq compilation-locs (make-hash-table))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    71
  (insert (car test))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    72
  (compilation-parse-errors (point-min) (point-max))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    73
  (let ((msg (get-text-property 1 'compilation-message)))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    74
    (should msg)
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    75
    (let ((loc (compilation--message->loc msg))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    76
          (line (nth 1 test))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    77
          (file (nth 2 test)))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    78
      (should (equal (compilation--loc->line loc) line))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    79
      (should (equal (caar (compilation--loc->file-struct loc)) file)))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    80
      msg))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    81
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    82
(require 'ert)
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    83
(ert-deftest hg-test-mode--compilation-mode-support ()
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    84
  "Test hg-specific compilation-mode regular expressions"
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    85
  (require 'compile)
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    86
  (with-temp-buffer
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    87
    (font-lock-mode -1)
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    88
    (mapc 'hg-test-mode--test-one-error-line-regexp
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    89
          '(
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    90
            ("+  contrib/debugshell.py:37:" 37 "contrib/debugshell.py")
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    91
            ("+    File \"/tmp/hg/mercurial/commands.py\", line 3115, in help_"
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    92
             3115 "/tmp/hg/mercurial/commands.py")
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    93
            ("+    File \"mercurial/dispatch.py\", line 225, in dispatch"
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    94
             225 "mercurial/dispatch.py")))))
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    95
19979b8b87e2 tests: add test for hg-test-mode emacs code
Augie Fackler <augie@google.com>
parents: 41786
diff changeset
    96
22081
ed426b011612 contrib: add emacs mode for *.t files
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    97
(provide 'hg-test-mode)