2012-08-22 06:38:59 +00:00
|
|
|
|
;;; profiler.el --- UI and helper functions for Emacs's native profiler -*- lexical-binding: t -*-
|
|
|
|
|
|
2024-01-02 01:47:10 +00:00
|
|
|
|
;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Tomohiro Matsuyama <tomo@cx4a.org>
|
|
|
|
|
;; Keywords: lisp
|
|
|
|
|
|
2013-03-30 16:52:28 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2012-08-22 06:38:59 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
2013-03-30 16:52:28 +00:00
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2012-08-22 06:38:59 +00:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2013-01-19 23:59:48 +00:00
|
|
|
|
;; See Info node `(elisp)Profiling'.
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(require 'cl-lib)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defgroup profiler nil
|
|
|
|
|
"Emacs profiler."
|
|
|
|
|
:group 'lisp
|
2012-10-06 20:30:26 +00:00
|
|
|
|
:version "24.3"
|
2012-08-22 06:38:59 +00:00
|
|
|
|
:prefix "profiler-")
|
|
|
|
|
|
2020-12-22 12:06:21 +00:00
|
|
|
|
(defconst profiler-version "28.1")
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
2012-10-02 06:30:40 +00:00
|
|
|
|
(defcustom profiler-sampling-interval 1000000
|
|
|
|
|
"Default sampling interval in nanoseconds."
|
2024-03-21 23:40:20 +00:00
|
|
|
|
:type 'natnum)
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
2012-08-22 06:38:59 +00:00
|
|
|
|
;;; Utilities
|
|
|
|
|
|
|
|
|
|
(defun profiler-ensure-string (object)
|
2012-08-23 12:11:12 +00:00
|
|
|
|
(cond ((stringp object)
|
|
|
|
|
object)
|
|
|
|
|
((symbolp object)
|
|
|
|
|
(symbol-name object))
|
|
|
|
|
((numberp object)
|
|
|
|
|
(number-to-string object))
|
|
|
|
|
(t
|
|
|
|
|
(format "%s" object))))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-format-percent (number divisor)
|
2015-07-31 17:12:37 +00:00
|
|
|
|
(format "%d%%" (floor (* 100.0 number) divisor)))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-format-number (number)
|
|
|
|
|
"Format NUMBER in human readable string."
|
|
|
|
|
(if (and (integerp number) (> number 0))
|
2013-06-21 00:53:33 +00:00
|
|
|
|
(cl-loop with i = (% (1+ (floor (log number 10))) 3)
|
2012-09-30 22:21:25 +00:00
|
|
|
|
for c in (append (number-to-string number) nil)
|
|
|
|
|
if (= i 0)
|
|
|
|
|
collect ?, into s
|
|
|
|
|
and do (setq i 3)
|
|
|
|
|
collect c into s
|
|
|
|
|
do (cl-decf i)
|
|
|
|
|
finally return
|
2024-03-21 23:40:20 +00:00
|
|
|
|
(apply #'string (if (eq (car s) ?,) (cdr s) s)))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(profiler-ensure-string number)))
|
|
|
|
|
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(defun profiler-format (fmt &rest args)
|
2012-08-22 06:49:34 +00:00
|
|
|
|
(cl-loop for (width align subfmt) in fmt
|
|
|
|
|
for arg in args
|
2012-08-22 12:38:39 +00:00
|
|
|
|
for str = (cond
|
|
|
|
|
((consp subfmt)
|
2024-03-21 23:40:20 +00:00
|
|
|
|
(apply #'profiler-format subfmt arg))
|
2012-08-22 12:38:39 +00:00
|
|
|
|
((stringp subfmt)
|
|
|
|
|
(format subfmt arg))
|
|
|
|
|
((and (symbolp subfmt)
|
|
|
|
|
(fboundp subfmt))
|
|
|
|
|
(funcall subfmt arg))
|
|
|
|
|
(t
|
|
|
|
|
(profiler-ensure-string arg)))
|
2012-08-22 06:49:34 +00:00
|
|
|
|
for len = (length str)
|
2020-12-22 12:06:21 +00:00
|
|
|
|
if (zerop width)
|
|
|
|
|
collect str into frags
|
|
|
|
|
else
|
2012-08-22 06:49:34 +00:00
|
|
|
|
if (< width len)
|
2013-10-09 03:32:35 +00:00
|
|
|
|
collect (progn (put-text-property (max 0 (- width 2)) len
|
|
|
|
|
'invisible 'profiler str)
|
2024-03-21 23:40:20 +00:00
|
|
|
|
str)
|
|
|
|
|
into frags
|
2012-08-22 06:49:34 +00:00
|
|
|
|
else
|
|
|
|
|
collect
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(let ((padding (make-string (max 0 (- width len)) ?\s)))
|
2012-08-22 06:49:34 +00:00
|
|
|
|
(cl-ecase align
|
|
|
|
|
(left (concat str padding))
|
|
|
|
|
(right (concat padding str))))
|
|
|
|
|
into frags
|
|
|
|
|
finally return (apply #'concat frags)))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
|
|
|
|
;;; Backtraces
|
|
|
|
|
|
2024-08-14 12:48:43 +00:00
|
|
|
|
(defun profiler-fixup-entry (entry)
|
|
|
|
|
(if (symbolp entry)
|
|
|
|
|
entry
|
|
|
|
|
(substring-no-properties (help-fns-function-name entry))))
|
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-fixup-backtrace (backtrace)
|
2024-08-14 12:48:43 +00:00
|
|
|
|
(apply #'vector (mapcar #'profiler-fixup-entry backtrace)))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Logs
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
;; The C code returns the log in the form of a hash-table where the keys are
|
|
|
|
|
;; vectors (of size profiler-max-stack-depth, holding truncated
|
|
|
|
|
;; backtraces, where the first element is the top of the stack) and
|
|
|
|
|
;; the values are integers (which count how many times this backtrace
|
|
|
|
|
;; has been seen, multiplied by a "weight factor" which is either the
|
2012-09-30 22:21:25 +00:00
|
|
|
|
;; sampling-interval or the memory being allocated).
|
|
|
|
|
|
|
|
|
|
(defun profiler-compare-logs (log1 log2)
|
|
|
|
|
"Compare LOG1 with LOG2 and return diff."
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(let ((newlog (make-hash-table :test 'equal)))
|
|
|
|
|
;; Make a copy of `log1' into `newlog'.
|
|
|
|
|
(maphash (lambda (backtrace count) (puthash backtrace count newlog))
|
|
|
|
|
log1)
|
|
|
|
|
(maphash (lambda (backtrace count)
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(puthash backtrace (- (gethash backtrace log1 0) count)
|
|
|
|
|
newlog))
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
log2)
|
|
|
|
|
newlog))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-fixup-log (log)
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(let ((newlog (make-hash-table :test 'equal)))
|
|
|
|
|
(maphash (lambda (backtrace count)
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(puthash (profiler-fixup-backtrace backtrace)
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
count newlog))
|
|
|
|
|
log)
|
|
|
|
|
newlog))
|
2012-08-23 12:11:12 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
|
|
|
|
;;; Profiles
|
|
|
|
|
|
|
|
|
|
(cl-defstruct (profiler-profile (:type vector)
|
|
|
|
|
(:constructor profiler-make-profile))
|
|
|
|
|
(tag 'profiler-profile)
|
|
|
|
|
(version profiler-version)
|
|
|
|
|
;; - `type' has a value indicating the kind of profile (`memory' or `cpu').
|
|
|
|
|
;; - `log' indicates the profile log.
|
|
|
|
|
;; - `timestamp' has a value giving the time when the profile was obtained.
|
|
|
|
|
;; - `diff-p' indicates if this profile represents a diff between two profiles.
|
|
|
|
|
type log timestamp diff-p)
|
|
|
|
|
|
|
|
|
|
(defun profiler-compare-profiles (profile1 profile2)
|
|
|
|
|
"Compare PROFILE1 with PROFILE2 and return diff."
|
|
|
|
|
(unless (eq (profiler-profile-type profile1)
|
|
|
|
|
(profiler-profile-type profile2))
|
|
|
|
|
(error "Can't compare different type of profiles"))
|
|
|
|
|
(profiler-make-profile
|
|
|
|
|
:type (profiler-profile-type profile1)
|
|
|
|
|
:timestamp (current-time)
|
|
|
|
|
:diff-p t
|
|
|
|
|
:log (profiler-compare-logs
|
|
|
|
|
(profiler-profile-log profile1)
|
|
|
|
|
(profiler-profile-log profile2))))
|
|
|
|
|
|
|
|
|
|
(defun profiler-fixup-profile (profile)
|
|
|
|
|
"Fixup PROFILE so that the profile could be serialized into file."
|
|
|
|
|
(profiler-make-profile
|
|
|
|
|
:type (profiler-profile-type profile)
|
|
|
|
|
:timestamp (profiler-profile-timestamp profile)
|
|
|
|
|
:diff-p (profiler-profile-diff-p profile)
|
|
|
|
|
:log (profiler-fixup-log (profiler-profile-log profile))))
|
|
|
|
|
|
|
|
|
|
(defun profiler-write-profile (profile filename &optional confirm)
|
|
|
|
|
"Write PROFILE into file FILENAME."
|
2012-08-23 12:11:12 +00:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(let (print-level print-length)
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(print (profiler-fixup-profile profile)
|
|
|
|
|
(current-buffer)))
|
2012-08-23 12:11:12 +00:00
|
|
|
|
(write-file filename confirm)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-read-profile (filename)
|
|
|
|
|
"Read profile from file FILENAME."
|
|
|
|
|
;; FIXME: tag and version check
|
2012-08-23 12:11:12 +00:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents filename)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(read (current-buffer))))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2013-01-20 02:39:59 +00:00
|
|
|
|
(defun profiler-running-p (&optional mode)
|
|
|
|
|
"Return non-nil if the profiler is running.
|
|
|
|
|
Optional argument MODE means only check for the specified mode (cpu or mem)."
|
|
|
|
|
(cond ((eq mode 'cpu) (and (fboundp 'profiler-cpu-running-p)
|
|
|
|
|
(profiler-cpu-running-p)))
|
|
|
|
|
((eq mode 'mem) (profiler-memory-running-p))
|
|
|
|
|
(t (or (profiler-running-p 'cpu)
|
|
|
|
|
(profiler-running-p 'mem)))))
|
|
|
|
|
|
2019-06-27 18:18:20 +00:00
|
|
|
|
(defvar profiler-cpu-log nil)
|
|
|
|
|
(defvar profiler-memory-log nil)
|
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-cpu-profile ()
|
|
|
|
|
"Return CPU profile."
|
2019-06-27 18:18:20 +00:00
|
|
|
|
(profiler-make-profile
|
|
|
|
|
:type 'cpu
|
|
|
|
|
:timestamp (current-time)
|
|
|
|
|
:log profiler-cpu-log))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-memory-profile ()
|
|
|
|
|
"Return memory profile."
|
2019-06-27 18:18:20 +00:00
|
|
|
|
(profiler-make-profile
|
|
|
|
|
:type 'memory
|
|
|
|
|
:timestamp (current-time)
|
|
|
|
|
:log profiler-memory-log))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
2012-08-23 12:11:12 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
;;; Calltrees
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-08-22 06:49:34 +00:00
|
|
|
|
(cl-defstruct (profiler-calltree (:constructor profiler-make-calltree))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
entry
|
2012-08-23 12:11:12 +00:00
|
|
|
|
(count 0) (count-percent "")
|
2012-08-22 06:38:59 +00:00
|
|
|
|
parent children)
|
|
|
|
|
|
|
|
|
|
(defun profiler-calltree-leaf-p (tree)
|
|
|
|
|
(null (profiler-calltree-children tree)))
|
|
|
|
|
|
|
|
|
|
(defun profiler-calltree-count< (a b)
|
|
|
|
|
(cond ((eq (profiler-calltree-entry a) t) t)
|
|
|
|
|
((eq (profiler-calltree-entry b) t) nil)
|
|
|
|
|
(t (< (profiler-calltree-count a)
|
|
|
|
|
(profiler-calltree-count b)))))
|
|
|
|
|
|
|
|
|
|
(defun profiler-calltree-count> (a b)
|
|
|
|
|
(not (profiler-calltree-count< a b)))
|
|
|
|
|
|
|
|
|
|
(defun profiler-calltree-depth (tree)
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(let ((d 0))
|
|
|
|
|
(while (setq tree (profiler-calltree-parent tree))
|
|
|
|
|
(cl-incf d))
|
|
|
|
|
d))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-calltree-find (tree entry)
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Return a child tree of ENTRY under TREE."
|
|
|
|
|
(let (result (children (profiler-calltree-children tree)))
|
|
|
|
|
(while (and children (null result))
|
|
|
|
|
(let ((child (car children)))
|
2013-09-11 01:43:07 +00:00
|
|
|
|
(when (function-equal (profiler-calltree-entry child) entry)
|
2012-08-23 12:11:12 +00:00
|
|
|
|
(setq result child))
|
|
|
|
|
(setq children (cdr children))))
|
|
|
|
|
result))
|
|
|
|
|
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(defun profiler-calltree-walk (calltree function)
|
|
|
|
|
(funcall function calltree)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(dolist (child (profiler-calltree-children calltree))
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(profiler-calltree-walk child function)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-calltree-build-1 (tree log &optional reverse)
|
2013-10-09 03:32:35 +00:00
|
|
|
|
;; This doesn't try to stitch up partial backtraces together.
|
|
|
|
|
;; We still use it for reverse calltrees, but for forward calltrees, we use
|
|
|
|
|
;; profiler-calltree-build-unified instead now.
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(maphash
|
|
|
|
|
(lambda (backtrace count)
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(let ((node tree)
|
|
|
|
|
(max (length backtrace)))
|
|
|
|
|
(dotimes (i max)
|
|
|
|
|
(let ((entry (aref backtrace (if reverse i (- max i 1)))))
|
|
|
|
|
(when entry
|
|
|
|
|
(let ((child (profiler-calltree-find node entry)))
|
|
|
|
|
(unless child
|
|
|
|
|
(setq child (profiler-make-calltree
|
|
|
|
|
:entry entry :parent node))
|
|
|
|
|
(push child (profiler-calltree-children node)))
|
|
|
|
|
(cl-incf (profiler-calltree-count child) count)
|
|
|
|
|
(setq node child)))))))
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
log))
|
2012-08-23 12:11:12 +00:00
|
|
|
|
|
2013-10-09 03:32:35 +00:00
|
|
|
|
|
|
|
|
|
(define-hash-table-test 'profiler-function-equal #'function-equal
|
Use a dedicated type to represent interpreted-function values
Change `function` so that when evaluating #'(lambda ...)
we return an object of type `interpreted-function` rather than
a list starting with one of `lambda` or `closure`.
The new type reuses the existing PVEC_CLOSURE (nee PVEC_COMPILED)
tag and tries to align the corresponding elements:
- the arglist, the docstring, and the interactive-form go in the
same slots as for byte-code functions.
- the body of the function goes in the slot used for the bytecode string.
- the lexical context goes in the slot used for the constants of
bytecoded functions.
The first point above means that `help-function-arglist`,
`documentation`, and `interactive-form`s don't need to
distinguish interpreted and bytecode functions any more.
Main benefits of the change:
- We can now reliably distinguish a list from a function value.
- `cl-defmethod` can dispatch on `interactive-function` and `closure`.
Dispatch on `function` also works now for interpreted functions but still
won't work for functions represented as lists or as symbols, of course.
- Function values are now self-evaluating. That was alrready the case
when byte-compiled, but not when interpreted since
(eval '(closure ...)) signals a void-function error.
That also avoids false-positive warnings about "don't quote your lambdas"
when doing things like `(mapcar ',func ...)`.
* src/eval.c (Fmake_interpreted_closure): New function.
(Ffunction): Use it and change calling convention of
`Vinternal_make_interpreted_closure_function`.
(FUNCTIONP, Fcommandp, eval_sub, funcall_general, funcall_lambda)
(Ffunc_arity, lambda_arity): Simplify.
(funcall_lambda): Adjust to new representation.
(syms_of_eval): `defsubr` the new function. Remove definition of `Qclosure`.
* lisp/emacs-lisp/cconv.el (cconv-make-interpreted-closure):
Change calling convention and use `make-interpreted-closure`.
* src/data.c (Fcl_type_of): Distinguish `byte-code-function`s from
`interpreted-function`s.
(Fclosurep, finterpreted_function_p): New functions.
(Fbyte_code_function_p): Don't be confused by `interpreted-function`s.
(Finteractive_form, Fcommand_modes): Simplify.
(syms_of_data): Define new type symbols and `defsubr` the two
new functions.
* lisp/emacs-lisp/cl-print.el (cl-print-object) <interpreted-function>:
New method.
* lisp/emacs-lisp/oclosure.el (oclosure): Refine the parent
to be `closure`.
(oclosure--fix-type, oclosure-type): Simplify.
(oclosure--copy, oclosure--get, oclosure--set): Adjust to
new representation.
* src/callint.c (Fcall_interactively): Adjust to new representation.
* src/lread.c (bytecode_from_rev_list):
* lisp/simple.el (function-documentation):
* lisp/help.el (help-function-arglist): Remove the old `closure` case
and adjust the byte-code case so it handles `interpreted-function`s.
* lisp/emacs-lisp/cl-preloaded.el (closure): New type.
(byte-code-function): Add it as a parent.
(interpreted-function): Adjust parent (the type itself was already
added earlier by accident).
* lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function): Adjust to
new representation.
(byte-compile): Use `interpreted-function-p`.
* lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Adjust to
new representation.
(side-effect-free-fns): Add `interpreted-function-p` and `closurep`.
* src/profiler.c (trace_hash, ffunction_equal): Simplify.
* lisp/profiler.el (profiler-function-equal): Simplify.
* lisp/emacs-lisp/nadvice.el (advice--interactive-form-1):
Use `interpreted-function-p`; adjust to new representation; and take
advantage of the fact that function values are now self-evaluating.
* lisp/emacs-lisp/lisp-mode.el (closure):
Remove `lisp-indent-function` property.
* lisp/emacs-lisp/disass.el (disassemble-internal): Adjust to
new representation.
* lisp/emacs-lisp/edebug.el (edebug--strip-instrumentation):
Use `interpreted-function-p`.
* lisp/emacs-lisp/comp-common.el (comp-known-type-specifiers):
Add `closurep` and `interpreted-function-p`.
* test/lisp/help-fns-tests.el (help-fns-test-lisp-defun): Adjust to
more precise type info in `describe-function`.
* test/lisp/erc/resources/erc-d/erc-d-tests.el (erc-d--render-entries):
Use `interpreted-function-p`.
* test/lisp/emacs-lisp/macroexp-resources/vk.el (vk-f4, vk-f5):
Don't hardcode function values.
* doc/lispref/functions.texi (Anonymous Functions): Don't suggest that
function values are lists. Reword "self-quoting" to reflect the
fact that #' doesn't return the exact same object. Update examples
with the new shape of the return value.
* doc/lispref/variables.texi (Lexical Binding):
* doc/lispref/lists.texi (Rearrangement):
* doc/lispref/control.texi (Handling Errors): Update examples to reflect
new representation of function values.
2024-03-11 20:12:26 +00:00
|
|
|
|
(lambda (f) (if (closurep f) (aref f 1) f)))
|
2013-10-09 03:32:35 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-calltree-build-unified (tree log)
|
|
|
|
|
;; Let's try to unify all those partial backtraces into a single
|
|
|
|
|
;; call tree. First, we record in fun-map all the functions that appear
|
|
|
|
|
;; in `log' and where they appear.
|
|
|
|
|
(let ((fun-map (make-hash-table :test 'profiler-function-equal))
|
|
|
|
|
(parent-map (make-hash-table :test 'eq))
|
|
|
|
|
(leftover-tree (profiler-make-calltree
|
2020-09-17 08:54:09 +00:00
|
|
|
|
:entry '... :parent tree)))
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(push leftover-tree (profiler-calltree-children tree))
|
|
|
|
|
(maphash
|
|
|
|
|
(lambda (backtrace _count)
|
|
|
|
|
(let ((max (length backtrace)))
|
|
|
|
|
;; Don't record the head elements in there, since we want to use this
|
|
|
|
|
;; fun-map to find parents of partial backtraces, but parents only
|
|
|
|
|
;; make sense if they have something "above".
|
|
|
|
|
(dotimes (i (1- max))
|
|
|
|
|
(let ((f (aref backtrace i)))
|
|
|
|
|
(when f
|
|
|
|
|
(push (cons i backtrace) (gethash f fun-map)))))))
|
|
|
|
|
log)
|
|
|
|
|
;; Then, for each partial backtrace, try to find a parent backtrace
|
|
|
|
|
;; (i.e. a backtrace that describes (part of) the truncated part of
|
|
|
|
|
;; the partial backtrace). For a partial backtrace like "[f3 f2 f1]" (f3
|
|
|
|
|
;; is deeper), any backtrace that includes f1 could be a parent; and indeed
|
|
|
|
|
;; the counts of this partial backtrace could each come from a different
|
|
|
|
|
;; parent backtrace (some of which may not even be in `log'). So we should
|
|
|
|
|
;; consider each backtrace that includes f1 and give it some percentage of
|
|
|
|
|
;; `count'. But we can't know for sure what percentage to give to each
|
|
|
|
|
;; possible parent.
|
|
|
|
|
;; The "right" way might be to give a percentage proportional to the counts
|
|
|
|
|
;; already registered for that parent, or some such statistical principle.
|
|
|
|
|
;; But instead, we will give all our counts to a single "best
|
|
|
|
|
;; matching" parent. So let's look for the best matching parent, and store
|
|
|
|
|
;; the result in parent-map.
|
|
|
|
|
;; Using the "best matching parent" is important also to try and avoid
|
|
|
|
|
;; stitching together backtraces that can't possibly go together.
|
|
|
|
|
;; For example, when the head is `apply' (or `mapcar', ...), we want to
|
|
|
|
|
;; make sure we don't just use any parent that calls `apply', since most of
|
|
|
|
|
;; them would never, in turn, cause apply to call the subsequent function.
|
|
|
|
|
(maphash
|
|
|
|
|
(lambda (backtrace _count)
|
|
|
|
|
(let* ((max (1- (length backtrace)))
|
|
|
|
|
(head (aref backtrace max))
|
|
|
|
|
(best-parent nil)
|
|
|
|
|
(best-match (1+ max))
|
|
|
|
|
(parents (gethash head fun-map)))
|
|
|
|
|
(pcase-dolist (`(,i . ,parent) parents)
|
|
|
|
|
(when t ;; (<= (- max i) best-match) ;Else, it can't be better.
|
|
|
|
|
(let ((match max)
|
|
|
|
|
(imatch i))
|
|
|
|
|
(cl-assert (>= match imatch))
|
|
|
|
|
(cl-assert (function-equal (aref backtrace max)
|
|
|
|
|
(aref parent i)))
|
|
|
|
|
(while (progn
|
|
|
|
|
(cl-decf imatch) (cl-decf match)
|
|
|
|
|
(when (> imatch 0)
|
|
|
|
|
(function-equal (aref backtrace match)
|
|
|
|
|
(aref parent imatch)))))
|
|
|
|
|
(when (< match best-match)
|
|
|
|
|
(cl-assert (<= (- max i) best-match))
|
|
|
|
|
;; Let's make sure this parent is not already our child: we
|
|
|
|
|
;; don't want cycles here!
|
|
|
|
|
(let ((valid t)
|
|
|
|
|
(tmp-parent parent))
|
|
|
|
|
(while (setq tmp-parent
|
|
|
|
|
(if (eq tmp-parent backtrace)
|
|
|
|
|
(setq valid nil)
|
|
|
|
|
(cdr (gethash tmp-parent parent-map)))))
|
|
|
|
|
(when valid
|
|
|
|
|
(setq best-match match)
|
|
|
|
|
(setq best-parent (cons i parent))))))))
|
|
|
|
|
(puthash backtrace best-parent parent-map)))
|
|
|
|
|
log)
|
|
|
|
|
;; Now we have a single parent per backtrace, so we have a unified tree.
|
|
|
|
|
;; Let's build the actual call-tree from it.
|
|
|
|
|
(maphash
|
|
|
|
|
(lambda (backtrace count)
|
|
|
|
|
(let ((node tree)
|
|
|
|
|
(parents (list (cons -1 backtrace)))
|
|
|
|
|
(tmp backtrace)
|
|
|
|
|
(max (length backtrace)))
|
|
|
|
|
(while (setq tmp (gethash tmp parent-map))
|
|
|
|
|
(push tmp parents)
|
|
|
|
|
(setq tmp (cdr tmp)))
|
|
|
|
|
(when (aref (cdar parents) (1- max))
|
|
|
|
|
(cl-incf (profiler-calltree-count leftover-tree) count)
|
|
|
|
|
(setq node leftover-tree))
|
|
|
|
|
(pcase-dolist (`(,i . ,parent) parents)
|
|
|
|
|
(let ((j (1- max)))
|
|
|
|
|
(while (> j i)
|
|
|
|
|
(let ((f (aref parent j)))
|
|
|
|
|
(cl-decf j)
|
|
|
|
|
(when f
|
|
|
|
|
(let ((child (profiler-calltree-find node f)))
|
|
|
|
|
(unless child
|
|
|
|
|
(setq child (profiler-make-calltree
|
|
|
|
|
:entry f :parent node))
|
|
|
|
|
(push child (profiler-calltree-children node)))
|
|
|
|
|
(cl-incf (profiler-calltree-count child) count)
|
|
|
|
|
(setq node child)))))))))
|
|
|
|
|
log)))
|
|
|
|
|
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(defun profiler-calltree-compute-percentages (tree)
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(let ((total-count 0))
|
2012-09-24 21:15:53 +00:00
|
|
|
|
;; FIXME: the memory profiler's total wraps around all too easily!
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(dolist (child (profiler-calltree-children tree))
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(cl-incf total-count (profiler-calltree-count child)))
|
|
|
|
|
(unless (zerop total-count)
|
|
|
|
|
(profiler-calltree-walk
|
|
|
|
|
tree (lambda (node)
|
|
|
|
|
(setf (profiler-calltree-count-percent node)
|
|
|
|
|
(profiler-format-percent (profiler-calltree-count node)
|
|
|
|
|
total-count)))))))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-08-22 06:49:34 +00:00
|
|
|
|
(cl-defun profiler-calltree-build (log &key reverse)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(let ((tree (profiler-make-calltree)))
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(if reverse
|
|
|
|
|
(profiler-calltree-build-1 tree log reverse)
|
|
|
|
|
(profiler-calltree-build-unified tree log))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(profiler-calltree-compute-percentages tree)
|
|
|
|
|
tree))
|
|
|
|
|
|
|
|
|
|
(defun profiler-calltree-sort (tree predicate)
|
|
|
|
|
(let ((children (profiler-calltree-children tree)))
|
|
|
|
|
(setf (profiler-calltree-children tree) (sort children predicate))
|
|
|
|
|
(dolist (child (profiler-calltree-children tree))
|
|
|
|
|
(profiler-calltree-sort child predicate))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Report rendering
|
|
|
|
|
|
|
|
|
|
(defcustom profiler-report-closed-mark "+"
|
|
|
|
|
"An indicator of closed calltrees."
|
2024-03-21 23:40:20 +00:00
|
|
|
|
:type 'string)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defcustom profiler-report-open-mark "-"
|
|
|
|
|
"An indicator of open calltrees."
|
2024-03-21 23:40:20 +00:00
|
|
|
|
:type 'string)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defcustom profiler-report-leaf-mark " "
|
|
|
|
|
"An indicator of calltree leaves."
|
2024-03-21 23:40:20 +00:00
|
|
|
|
:type 'string)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defvar profiler-report-cpu-line-format
|
2020-12-22 16:57:46 +00:00
|
|
|
|
'((17 right ((12 right)
|
2020-12-22 12:06:21 +00:00
|
|
|
|
(5 right)))
|
|
|
|
|
(1 left "%s")
|
|
|
|
|
(0 left)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defvar profiler-report-memory-line-format
|
2020-12-22 12:06:21 +00:00
|
|
|
|
'((20 right ((15 right profiler-format-number)
|
|
|
|
|
(5 right)))
|
|
|
|
|
(1 left "%s")
|
|
|
|
|
(0 left)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defvar-local profiler-report-profile nil
|
|
|
|
|
"The current profile.")
|
2012-08-23 12:11:12 +00:00
|
|
|
|
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(defvar-local profiler-report-reversed nil
|
2021-09-22 18:26:40 +00:00
|
|
|
|
"Non-nil if calltree is rendered in bottom-up.
|
2021-09-14 06:43:18 +00:00
|
|
|
|
Do not touch this variable directly.")
|
2012-08-23 12:11:12 +00:00
|
|
|
|
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(defvar-local profiler-report-order nil
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"The value can be `ascending' or `descending'.
|
|
|
|
|
Do not touch this variable directly.")
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-report-make-entry-part (entry)
|
2012-08-23 12:11:12 +00:00
|
|
|
|
(let ((string (cond
|
|
|
|
|
((eq entry t)
|
|
|
|
|
"Others")
|
2024-08-17 17:35:07 +00:00
|
|
|
|
;; When we save profile data into a file, the function
|
|
|
|
|
;; objects are replaced with their "names". When we see
|
|
|
|
|
;; a string here, that's presumably why, so just print
|
|
|
|
|
;; it as-is.
|
|
|
|
|
((stringp entry) entry)
|
2024-03-21 23:40:20 +00:00
|
|
|
|
(t (propertize (help-fns-function-name entry)
|
|
|
|
|
;; Override the `button-map' which
|
|
|
|
|
;; otherwise adds RET, mouse-1, and TAB
|
|
|
|
|
;; bindings we don't want. :-(
|
|
|
|
|
'keymap '(make-sparse-keymap)
|
|
|
|
|
'follow-link "\r"
|
|
|
|
|
;; FIXME: The help-echo code gets confused
|
|
|
|
|
;; by the `follow-link' property and rewrites
|
|
|
|
|
;; `mouse-2' to `mouse-1' :-(
|
|
|
|
|
'help-echo "\
|
2012-10-27 09:54:04 +00:00
|
|
|
|
mouse-2: jump to definition\n\
|
2024-03-21 23:40:20 +00:00
|
|
|
|
RET: expand or collapse")))))
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(propertize string 'profiler-entry entry)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-report-make-name-part (tree)
|
|
|
|
|
(let* ((entry (profiler-calltree-entry tree))
|
|
|
|
|
(depth (profiler-calltree-depth tree))
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(indent (make-string (* (1- depth) 1) ?\s))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(mark (if (profiler-calltree-leaf-p tree)
|
|
|
|
|
profiler-report-leaf-mark
|
|
|
|
|
profiler-report-closed-mark))
|
|
|
|
|
(entry (profiler-report-make-entry-part entry)))
|
|
|
|
|
(format "%s%s %s" indent mark entry)))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-header-line-format (fmt &rest args)
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(let* ((header (apply #'profiler-format fmt args))
|
Use string-replace instead of replace-regexp-in-string
`string-replace` is easier to understand, less error-prone, much
faster, and results in shorter Lisp and byte code. Use it where
applicable and obviously safe (erring on the conservative side).
* admin/authors.el (authors-scan-change-log):
* lisp/autoinsert.el (auto-insert-alist):
* lisp/calc/calc-prog.el (calc-edit-macro-combine-alg-ent)
(calc-edit-macro-combine-ext-command)
(calc-edit-macro-combine-var-name):
* lisp/calc/calc-units.el (math-make-unit-string):
* lisp/calendar/cal-html.el (cal-html-comment):
* lisp/calendar/cal-tex.el (cal-tex-comment):
* lisp/calendar/icalendar.el (icalendar--convert-string-for-export)
(icalendar--convert-string-for-import):
* lisp/calendar/iso8601.el (iso8601--concat-regexps)
(iso8601--full-time-match, iso8601--combined-match):
* lisp/calendar/time-date.el (format-seconds):
* lisp/calendar/todo-mode.el (todo-filter-items-filename):
* lisp/cedet/cedet-files.el (cedet-directory-name-to-file-name)
(cedet-file-name-to-directory-name):
* lisp/comint.el (comint-watch-for-password-prompt):
* lisp/dired-aux.el (dired-do-chmod):
* lisp/dired-x.el (dired-man):
* lisp/dired.el (dired-insert-directory, dired-goto-file-1):
* lisp/emacs-lisp/comp.el (comp-c-func-name):
* lisp/emacs-lisp/re-builder.el (reb-copy):
* lisp/erc/erc-dcc.el (erc-dcc-unquote-filename):
* lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy)
(erc-update-mode-line-buffer, erc-message-english-PART):
* lisp/files.el (make-backup-file-name-1, files--transform-file-name)
(read-file-modes):
* lisp/fringe.el (fringe-mode):
* lisp/gnus/gnus-art.el (gnus-button-handle-info-url):
* lisp/gnus/gnus-group.el (gnus-group-completing-read):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-ical):
* lisp/gnus/gnus-mlspl.el (gnus-group-split-fancy):
* lisp/gnus/gnus-search.el (gnus-search-query-parse-date)
(gnus-search-transform-expression, gnus-search-run-search):
* lisp/gnus/gnus-start.el (gnus-dribble-enter):
* lisp/gnus/gnus-sum.el (gnus-summary-refer-article):
* lisp/gnus/gnus-util.el (gnus-mode-string-quote):
* lisp/gnus/message.el (message-put-addresses-in-ecomplete)
(message-parse-mailto-url, message-mailto-1):
* lisp/gnus/mml-sec.el (mml-secure-epg-sign):
* lisp/gnus/mml-smime.el (mml-smime-epg-verify):
* lisp/gnus/mml2015.el (mml2015-epg-verify):
* lisp/gnus/nnmaildir.el (nnmaildir--system-name)
(nnmaildir-request-list, nnmaildir-retrieve-groups)
(nnmaildir-request-group, nnmaildir-retrieve-headers):
* lisp/gnus/nnrss.el (nnrss-node-text):
* lisp/gnus/spam-report.el (spam-report-gmane-internal)
(spam-report-user-mail-address):
* lisp/ibuffer.el (name):
* lisp/image-dired.el (image-dired-pngnq-thumb)
(image-dired-pngcrush-thumb, image-dired-optipng-thumb)
(image-dired-create-thumb-1):
* lisp/info.el (Info-set-mode-line):
* lisp/international/mule-cmds.el (describe-language-environment):
* lisp/mail/rfc2231.el (rfc2231-parse-string):
* lisp/mail/rfc2368.el (rfc2368-parse-mailto-url):
* lisp/mail/rmail.el (rmail-insert-inbox-text)
(rmail-simplified-subject-regexp):
* lisp/mail/rmailout.el (rmail-output-body-to-file):
* lisp/mail/undigest.el (rmail-digest-rfc1153):
* lisp/man.el (Man-default-man-entry):
* lisp/mouse.el (minor-mode-menu-from-indicator):
* lisp/mpc.el (mpc--debug):
* lisp/net/browse-url.el (browse-url-mail):
* lisp/net/eww.el (eww-update-header-line-format):
* lisp/net/newst-backend.el (newsticker-save-item):
* lisp/net/rcirc.el (rcirc-sentinel):
* lisp/net/soap-client.el (soap-decode-date-time):
* lisp/nxml/rng-cmpct.el (rng-c-literal-2-re):
* lisp/nxml/xmltok.el (let*):
* lisp/obsolete/nnir.el (nnir-run-swish-e, nnir-run-hyrex)
(nnir-run-find-grep):
* lisp/play/dunnet.el (dun-doassign):
* lisp/play/handwrite.el (handwrite):
* lisp/proced.el (proced-format-args):
* lisp/profiler.el (profiler-report-header-line-format):
* lisp/progmodes/gdb-mi.el (gdb-mi-quote):
* lisp/progmodes/make-mode.el (makefile-bsdmake-rule-action-regex)
(makefile-make-font-lock-keywords):
* lisp/progmodes/prolog.el (prolog-guess-fill-prefix):
* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
* lisp/progmodes/sql.el (sql-remove-tabs-filter, sql-str-literal):
* lisp/progmodes/which-func.el (which-func-current):
* lisp/replace.el (query-replace-read-from)
(occur-engine, replace-quote):
* lisp/select.el (xselect--encode-string):
* lisp/ses.el (ses-export-tab):
* lisp/subr.el (shell-quote-argument):
* lisp/term/pc-win.el (msdos-show-help):
* lisp/term/w32-win.el (w32--set-selection):
* lisp/term/xterm.el (gui-backend-set-selection):
* lisp/textmodes/picture.el (picture-tab-search):
* lisp/thumbs.el (thumbs-call-setroot-command):
* lisp/tooltip.el (tooltip-show-help-non-mode):
* lisp/transient.el (transient-format-key):
* lisp/url/url-mailto.el (url-mailto):
* lisp/vc/log-edit.el (log-edit-changelog-ours-p):
* lisp/vc/vc-bzr.el (vc-bzr-status):
* lisp/vc/vc-hg.el (vc-hg--glob-to-pcre):
* lisp/vc/vc-svn.el (vc-svn-after-dir-status):
* lisp/xdg.el (xdg-desktop-strings):
* test/lisp/electric-tests.el (defun):
* test/lisp/term-tests.el (term-simple-lines):
* test/lisp/time-stamp-tests.el (formatz-mod-del-colons):
* test/lisp/wdired-tests.el (wdired-test-bug32173-01)
(wdired-test-unfinished-edit-01):
* test/src/json-tests.el (json-parse-with-custom-null-and-false-objects):
Use `string-replace` instead of `replace-regexp-in-string`.
2021-08-08 16:58:46 +00:00
|
|
|
|
(escaped (string-replace "%" "%%" header)))
|
2021-01-01 09:28:16 +00:00
|
|
|
|
(concat
|
|
|
|
|
(propertize " "
|
2020-12-22 16:57:46 +00:00
|
|
|
|
'display '(space :align-to 0)
|
2021-01-01 09:28:16 +00:00
|
|
|
|
'face 'fixed-pitch)
|
2020-12-22 16:57:46 +00:00
|
|
|
|
escaped)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-report-line-format (tree)
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(let ((diff-p (profiler-profile-diff-p profiler-report-profile))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(name-part (profiler-report-make-name-part tree))
|
|
|
|
|
(count (profiler-calltree-count tree))
|
|
|
|
|
(count-percent (profiler-calltree-count-percent tree)))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(profiler-format (cl-ecase (profiler-profile-type profiler-report-profile)
|
|
|
|
|
(cpu profiler-report-cpu-line-format)
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(memory profiler-report-memory-line-format))
|
|
|
|
|
(if diff-p
|
|
|
|
|
(list (if (> count 0)
|
|
|
|
|
(format "+%s" count)
|
|
|
|
|
count)
|
|
|
|
|
"")
|
2020-12-22 12:06:21 +00:00
|
|
|
|
(list count count-percent))
|
|
|
|
|
" "
|
|
|
|
|
name-part)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-report-insert-calltree (tree)
|
|
|
|
|
(let ((line (profiler-report-line-format tree)))
|
|
|
|
|
(insert (propertize (concat line "\n") 'calltree tree))))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-insert-calltree-children (tree)
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(mapc #'profiler-report-insert-calltree
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(profiler-calltree-children tree)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Report mode
|
|
|
|
|
|
2022-11-02 14:43:35 +00:00
|
|
|
|
(defvar-keymap profiler-report-mode-map
|
|
|
|
|
:doc "Keymap for `profiler-report-mode'."
|
|
|
|
|
"n" #'profiler-report-next-entry
|
|
|
|
|
"p" #'profiler-report-previous-entry
|
|
|
|
|
;; I find it annoying more than helpful to not be able to navigate
|
|
|
|
|
;; normally with the cursor keys. --Stef
|
|
|
|
|
;; "<down>" #'profiler-report-next-entry
|
|
|
|
|
;; "<up>" #'profiler-report-previous-entry
|
|
|
|
|
"RET" #'profiler-report-toggle-entry
|
|
|
|
|
"TAB" #'profiler-report-toggle-entry
|
|
|
|
|
"i" #'profiler-report-toggle-entry
|
|
|
|
|
"f" #'profiler-report-find-entry
|
|
|
|
|
"j" #'profiler-report-find-entry
|
|
|
|
|
"d" #'profiler-report-describe-entry
|
|
|
|
|
"C" #'profiler-report-render-calltree
|
|
|
|
|
"B" #'profiler-report-render-reversed-calltree
|
|
|
|
|
"A" #'profiler-report-ascending-sort
|
|
|
|
|
"D" #'profiler-report-descending-sort
|
|
|
|
|
"=" #'profiler-report-compare-profile
|
|
|
|
|
"C-x C-w" #'profiler-report-write-profile
|
|
|
|
|
"<follow-link>" 'mouse-face
|
|
|
|
|
"<mouse-2>" #'profiler-report-find-entry
|
|
|
|
|
|
|
|
|
|
:menu
|
|
|
|
|
'("Profiler"
|
|
|
|
|
["Next Entry" profiler-report-next-entry :active t
|
|
|
|
|
:help "Move to next entry"]
|
|
|
|
|
["Previous Entry" profiler-report-previous-entry :active t
|
|
|
|
|
:help "Move to previous entry"]
|
|
|
|
|
"--"
|
|
|
|
|
["Toggle Entry" profiler-report-toggle-entry
|
|
|
|
|
:active (profiler-report-calltree-at-point)
|
|
|
|
|
:help "Expand or collapse the current entry"]
|
|
|
|
|
["Find Entry" profiler-report-find-entry
|
|
|
|
|
;; FIXME should deactivate if not on a known function.
|
|
|
|
|
:active (profiler-report-calltree-at-point)
|
|
|
|
|
:help "Find the definition of the current entry"]
|
|
|
|
|
["Describe Entry" profiler-report-describe-entry
|
|
|
|
|
:active (profiler-report-calltree-at-point)
|
|
|
|
|
:help "Show the documentation of the current entry"]
|
|
|
|
|
"--"
|
|
|
|
|
["Show Calltree" profiler-report-render-calltree
|
|
|
|
|
:active profiler-report-reversed
|
|
|
|
|
:help "Show calltree view"]
|
|
|
|
|
["Show Reversed Calltree" profiler-report-render-reversed-calltree
|
|
|
|
|
:active (not profiler-report-reversed)
|
|
|
|
|
:help "Show reversed calltree view"]
|
|
|
|
|
["Sort Ascending" profiler-report-ascending-sort
|
|
|
|
|
:active (not (eq profiler-report-order 'ascending))
|
|
|
|
|
:help "Sort calltree view in ascending order"]
|
|
|
|
|
["Sort Descending" profiler-report-descending-sort
|
|
|
|
|
:active (not (eq profiler-report-order 'descending))
|
|
|
|
|
:help "Sort calltree view in descending order"]
|
|
|
|
|
"--"
|
|
|
|
|
["Compare Profile..." profiler-report-compare-profile :active t
|
|
|
|
|
:help "Compare current profile with another"]
|
|
|
|
|
["Write Profile..." profiler-report-write-profile :active t
|
|
|
|
|
:help "Write current profile to a file"]
|
|
|
|
|
"--"
|
|
|
|
|
["Start Profiler" profiler-start :active (not (profiler-running-p))
|
|
|
|
|
:help "Start profiling"]
|
|
|
|
|
["Stop Profiler" profiler-stop :active (profiler-running-p)
|
|
|
|
|
:help "Stop profiling"]
|
|
|
|
|
["New Report" profiler-report :active (profiler-running-p)
|
|
|
|
|
:help "Make a new report"]))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-make-buffer-name (profile)
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(format "*%s-Profiler-Report %s*"
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(cl-ecase (profiler-profile-type profile) (cpu 'CPU) (memory 'Memory))
|
|
|
|
|
(format-time-string "%Y-%m-%d %T" (profiler-profile-timestamp profile))))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-setup-buffer-1 (profile)
|
|
|
|
|
"Make a buffer for PROFILE and return it."
|
|
|
|
|
(let* ((buf-name (profiler-report-make-buffer-name profile))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(buffer (get-buffer-create buf-name)))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(profiler-report-mode)
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(setq profiler-report-profile profile
|
2012-08-22 06:38:59 +00:00
|
|
|
|
profiler-report-reversed nil
|
|
|
|
|
profiler-report-order 'descending))
|
|
|
|
|
buffer))
|
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-setup-buffer (profile)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Make a buffer for PROFILE with rendering the profile and return it."
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(let ((buffer (profiler-report-setup-buffer-1 profile)))
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(profiler-report-render-calltree))
|
|
|
|
|
buffer))
|
|
|
|
|
|
2019-07-30 10:04:21 +00:00
|
|
|
|
(defun profiler--xref-backend () 'elisp)
|
|
|
|
|
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(define-derived-mode profiler-report-mode special-mode "Profiler-Report"
|
|
|
|
|
"Profiler Report Mode."
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(add-to-invisibility-spec '(profiler . t))
|
2019-07-30 10:04:21 +00:00
|
|
|
|
(add-hook 'xref-backend-functions #'profiler--xref-backend nil t)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(setq buffer-read-only t
|
|
|
|
|
buffer-undo-list t
|
|
|
|
|
truncate-lines t))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Report commands
|
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-calltree-at-point (&optional point)
|
|
|
|
|
(get-text-property (or point (point)) 'calltree))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-report-move-to-entry ()
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(let ((point (next-single-property-change
|
|
|
|
|
(line-beginning-position) 'profiler-entry)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(if point
|
|
|
|
|
(goto-char point)
|
|
|
|
|
(back-to-indentation))))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-next-entry ()
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Move cursor to next entry."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(profiler-report-move-to-entry))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-previous-entry ()
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Move cursor to previous entry."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(forward-line -1)
|
|
|
|
|
(profiler-report-move-to-entry))
|
|
|
|
|
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(defun profiler-report-expand-entry (&optional full)
|
|
|
|
|
"Expand entry at point.
|
|
|
|
|
With a prefix argument, expand the whole subtree."
|
|
|
|
|
(interactive "P")
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(when (search-forward (concat profiler-report-closed-mark " ")
|
|
|
|
|
(line-end-position) t)
|
|
|
|
|
(let ((tree (profiler-report-calltree-at-point)))
|
|
|
|
|
(when tree
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(replace-match (concat profiler-report-open-mark " "))
|
|
|
|
|
(forward-line)
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(let ((first (point))
|
|
|
|
|
(last (copy-marker (point) t)))
|
|
|
|
|
(profiler-report-insert-calltree-children tree)
|
|
|
|
|
(when full
|
|
|
|
|
(goto-char first)
|
|
|
|
|
(while (< (point) last)
|
|
|
|
|
(profiler-report-expand-entry)
|
|
|
|
|
(forward-line 1))))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
t))))))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-collapse-entry ()
|
2012-10-05 05:57:24 +00:00
|
|
|
|
"Collapse entry at point."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(when (search-forward (concat profiler-report-open-mark " ")
|
|
|
|
|
(line-end-position) t)
|
|
|
|
|
(let* ((tree (profiler-report-calltree-at-point))
|
|
|
|
|
(depth (profiler-calltree-depth tree))
|
|
|
|
|
(start (line-beginning-position 2))
|
|
|
|
|
d)
|
|
|
|
|
(when tree
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(let ((inhibit-read-only t))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(replace-match (concat profiler-report-closed-mark " "))
|
|
|
|
|
(while (and (eq (forward-line) 0)
|
|
|
|
|
(let ((child (get-text-property (point) 'calltree)))
|
|
|
|
|
(and child
|
|
|
|
|
(numberp (setq d (profiler-calltree-depth child)))))
|
|
|
|
|
(> d depth)))
|
|
|
|
|
(delete-region start (line-beginning-position)))))
|
|
|
|
|
t)))
|
|
|
|
|
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(defun profiler-report-toggle-entry (&optional arg)
|
2021-09-14 06:43:18 +00:00
|
|
|
|
"Expand entry at point if the tree is collapsed, otherwise collapse.
|
|
|
|
|
With prefix argument, expand all subentries below entry at
|
|
|
|
|
point."
|
2013-10-09 03:32:35 +00:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(or (profiler-report-expand-entry arg)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(profiler-report-collapse-entry)))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-find-entry (&optional event)
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Find entry at point."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive (list last-nonmenu-event))
|
2012-11-20 00:57:23 +00:00
|
|
|
|
(with-current-buffer
|
|
|
|
|
(if event (window-buffer (posn-window (event-start event)))
|
|
|
|
|
(current-buffer))
|
|
|
|
|
(and event (setq event (event-end event))
|
|
|
|
|
(posn-set-point event))
|
2024-03-21 23:40:20 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-line 0)
|
|
|
|
|
(let ((eol (pos-eol)))
|
|
|
|
|
(forward-button 1)
|
|
|
|
|
(if (> (point) eol)
|
|
|
|
|
(error "No entry found")
|
|
|
|
|
(push-button))))))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-report-describe-entry ()
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Describe entry at point."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(let ((tree (profiler-report-calltree-at-point)))
|
|
|
|
|
(when tree
|
|
|
|
|
(let ((entry (profiler-calltree-entry tree)))
|
|
|
|
|
(require 'help-fns)
|
|
|
|
|
(describe-function entry)))))
|
|
|
|
|
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(cl-defun profiler-report-render-calltree-1
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(profile &key reverse (order 'descending))
|
|
|
|
|
(let ((calltree (profiler-calltree-build
|
|
|
|
|
(profiler-profile-log profile)
|
|
|
|
|
:reverse reverse)))
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(setq header-line-format
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(cl-ecase (profiler-profile-type profile)
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(cpu
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(profiler-report-header-line-format
|
2012-09-30 22:21:25 +00:00
|
|
|
|
profiler-report-cpu-line-format
|
2020-12-22 18:34:24 +00:00
|
|
|
|
(list "Samples" "%") " " " Function"))
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(memory
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(profiler-report-header-line-format
|
|
|
|
|
profiler-report-memory-line-format
|
2020-12-22 18:34:24 +00:00
|
|
|
|
(list "Bytes" "%") " " " Function"))))
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
(let ((predicate (cl-ecase order
|
|
|
|
|
(ascending #'profiler-calltree-count<)
|
|
|
|
|
(descending #'profiler-calltree-count>))))
|
|
|
|
|
(profiler-calltree-sort calltree predicate))
|
|
|
|
|
(let ((inhibit-read-only t))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(erase-buffer)
|
|
|
|
|
(profiler-report-insert-calltree-children calltree)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(profiler-report-move-to-entry))))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-rerender-calltree ()
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(profiler-report-render-calltree-1 profiler-report-profile
|
2012-08-22 06:38:59 +00:00
|
|
|
|
:reverse profiler-report-reversed
|
|
|
|
|
:order profiler-report-order))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-render-calltree ()
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Render calltree view."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(setq profiler-report-reversed nil)
|
|
|
|
|
(profiler-report-rerender-calltree))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-render-reversed-calltree ()
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Render reversed calltree view."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(setq profiler-report-reversed t)
|
|
|
|
|
(profiler-report-rerender-calltree))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-ascending-sort ()
|
|
|
|
|
"Sort calltree view in ascending order."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq profiler-report-order 'ascending)
|
|
|
|
|
(profiler-report-rerender-calltree))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-descending-sort ()
|
|
|
|
|
"Sort calltree view in descending order."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq profiler-report-order 'descending)
|
|
|
|
|
(profiler-report-rerender-calltree))
|
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-profile (profile)
|
|
|
|
|
(switch-to-buffer (profiler-report-setup-buffer profile)))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-profile-other-window (profile)
|
|
|
|
|
(switch-to-buffer-other-window (profiler-report-setup-buffer profile)))
|
|
|
|
|
|
|
|
|
|
(defun profiler-report-profile-other-frame (profile)
|
|
|
|
|
(switch-to-buffer-other-frame (profiler-report-setup-buffer profile)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-compare-profile (buffer)
|
|
|
|
|
"Compare the current profile with another."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive (list (read-buffer "Compare to: ")))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(let* ((profile1 (with-current-buffer buffer profiler-report-profile))
|
|
|
|
|
(profile2 profiler-report-profile)
|
|
|
|
|
(diff-profile (profiler-compare-profiles profile1 profile2)))
|
|
|
|
|
(profiler-report-profile diff-profile)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-write-profile (filename &optional confirm)
|
|
|
|
|
"Write the current profile into file FILENAME."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(list (read-file-name "Write profile: " default-directory)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(not current-prefix-arg)))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(profiler-write-profile profiler-report-profile
|
|
|
|
|
filename
|
|
|
|
|
confirm))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Profiler commands
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun profiler-start (mode)
|
Rewrite sampler to use Elisp hash-tables.
* src/profiler.c: Remove filtering functionality.
(is_in_trace, Qgc): Remove vars.
(make_log, record_backtrace, Fsample_profiler_log):
Rewrite, using Elisp hash-tables.
(approximate_median, evict_lower_half): New functions.
(cpu_log): Rename from sample_log.
(cpu_gc_count): New var.
(Fsample_profiler_reset, Fmemory_profiler_reset): Remove.
(sigprof_handler): Add count to cpu_gc_count during GC, detected via
backtrace_list.
(block_sigprof, unblock_sigprof): Remove.
(gc_probe, mark_profiler): Remove functions.
(syms_of_profiler): Staticpro cpu_log and memory_log.
* lisp/profiler.el (profiler-sample-interval): Move before first use.
Change default to 1ms.
(profiler-entry=, profiler-backtrace-reverse, profiler-log-fixup-slot)
(profiler-calltree-elapsed<, profiler-calltree-elapsed>): Remove functions.
(profiler-entry-format): Don't use type-of.
(profiler-slot, profiler-log): Remove structs.
(profiler-log-timestamp, profiler-log-type, profiler-log-diff-p):
Redefine for new log representation.
(profiler-log-diff, profiler-log-fixup, profiler-calltree-build-1):
Rewrite for new log representation.
(profiler-calltree): Remove `elapsed' fields.
(profiler-calltree-count<, profiler-report-make-entry-part):
Remove gc special case.
(profiler-calltree-find): Use equal.
(profiler-calltree-walk): Remove `args'; rely on closures instead.
(profiler-calltree-compute-percentages-1): Remove; inlined.
(profiler-calltree-compute-percentages): Simplify.
(profiler-report-log, profiler-report-reversed)
(profiler-report-order): Use defvar-local.
(profiler-report-line-format): Remove `elapsed', do a bit of CSE.
(profiler-report-mode-map): Remove up/down bindings.
(profiler-report-make-buffer-name): Simplify by CSE.
(profiler-report-mode): Remove redundant code.
(profiler-report-expand-entry, profiler-report-collapse-entry):
Use inhibit-read-only.
(profiler-report-render-calltree-1): Simplify by CSE.
(profiler-reset): Rewrite for new subroutines.
(profiler--report-cpu): Rename from sample-profiler-report.
(profiler--report-memory): Rename from memory-profiler-report.
* src/alloc.c (Fgarbage_collect): Record itself in backtrace_list.
Don't set is_in_trace any more. Don't call mark_profiler.
Only call gc_probe for the memory profiler.
(syms_of_alloc): Define Qautomatic_gc.
* src/lisp.h (SXHASH_COMBINE): Move back to...
* src/fns.c (SXHASH_COMBINE): ...here.
* src/xdisp.c (Qautomatic_redisplay): New constant.
(redisplay_internal): Record itself in backtrace_list.
(syms_of_xdisp): Define Qautomatic_redisplay.
* .dir-locals.el (indent-tabs-mode): Remove personal preference.
2012-09-24 14:38:10 +00:00
|
|
|
|
"Start/restart profilers.
|
|
|
|
|
MODE can be one of `cpu', `mem', or `cpu+mem'.
|
2021-06-19 13:08:50 +00:00
|
|
|
|
If MODE is `cpu' or `cpu+mem', start the time-based profiler,
|
|
|
|
|
whereby CPU is sampled periodically using the SIGPROF signal.
|
|
|
|
|
If MODE is `mem' or `cpu+mem', start profiler that samples CPU
|
|
|
|
|
whenever memory-allocation functions are called -- this is useful
|
|
|
|
|
if SIGPROF is not supported, or is unreliable, or is not sampling
|
|
|
|
|
at a high enough frequency."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive
|
2012-09-26 04:02:21 +00:00
|
|
|
|
(list (if (not (fboundp 'profiler-cpu-start)) 'mem
|
2020-09-06 18:35:11 +00:00
|
|
|
|
(intern (completing-read (format-prompt "Mode" "cpu")
|
2012-09-26 04:02:21 +00:00
|
|
|
|
'("cpu" "mem" "cpu+mem")
|
|
|
|
|
nil t nil nil "cpu")))))
|
2012-08-22 06:49:34 +00:00
|
|
|
|
(cl-ecase mode
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(cpu
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(profiler-cpu-start profiler-sampling-interval)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(message "CPU profiler started"))
|
2012-08-22 07:08:36 +00:00
|
|
|
|
(mem
|
2012-09-25 02:30:46 +00:00
|
|
|
|
(profiler-memory-start)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(message "Memory profiler started"))
|
2012-08-22 07:08:36 +00:00
|
|
|
|
(cpu+mem
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(profiler-cpu-start profiler-sampling-interval)
|
2012-09-25 02:30:46 +00:00
|
|
|
|
(profiler-memory-start)
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(message "CPU and memory profiler started"))))
|
|
|
|
|
|
|
|
|
|
(defun profiler-stop ()
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Stop started profilers. Profiler logs will be kept."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive)
|
2019-06-27 18:18:20 +00:00
|
|
|
|
(when (and (fboundp 'profiler-cpu-running-p)
|
|
|
|
|
(profiler-cpu-running-p))
|
|
|
|
|
(setq profiler-cpu-log (profiler-cpu-log)))
|
|
|
|
|
(when (profiler-memory-running-p)
|
|
|
|
|
(setq profiler-memory-log (profiler-memory-log)))
|
|
|
|
|
(let ((cpu (when (fboundp 'profiler-cpu-stop) (profiler-cpu-stop)))
|
2012-09-26 04:02:21 +00:00
|
|
|
|
(mem (profiler-memory-stop)))
|
|
|
|
|
(message "%s profiler stopped"
|
|
|
|
|
(cond ((and mem cpu) "CPU and memory")
|
|
|
|
|
(mem "Memory")
|
|
|
|
|
(cpu "CPU")
|
|
|
|
|
(t "No")))))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
|
|
|
|
(defun profiler-reset ()
|
2012-09-30 22:21:25 +00:00
|
|
|
|
"Reset profiler logs."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive)
|
2019-06-27 18:18:20 +00:00
|
|
|
|
(when (and (fboundp 'profiler-cpu-running-p) (profiler-cpu-running-p))
|
|
|
|
|
(profiler-cpu-stop))
|
|
|
|
|
(when (profiler-memory-running-p)
|
|
|
|
|
(profiler-memory-stop))
|
|
|
|
|
(setq profiler-cpu-log nil
|
|
|
|
|
profiler-memory-log nil))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-cpu ()
|
2019-06-27 18:18:20 +00:00
|
|
|
|
(when profiler-cpu-log
|
|
|
|
|
(profiler-report-profile-other-window (profiler-cpu-profile))))
|
2012-08-22 09:15:17 +00:00
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-report-memory ()
|
2019-06-27 18:18:20 +00:00
|
|
|
|
(when profiler-memory-log
|
|
|
|
|
(profiler-report-profile-other-window (profiler-memory-profile))))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-08-22 09:15:17 +00:00
|
|
|
|
(defun profiler-report ()
|
2012-08-23 12:11:12 +00:00
|
|
|
|
"Report profiling results."
|
2019-06-30 12:30:03 +00:00
|
|
|
|
(interactive)
|
2019-06-27 18:18:20 +00:00
|
|
|
|
(when (and (fboundp 'profiler-cpu-running-p) (profiler-cpu-running-p))
|
|
|
|
|
(setq profiler-cpu-log (profiler-cpu-log)))
|
|
|
|
|
(when (profiler-memory-running-p)
|
|
|
|
|
(setq profiler-memory-log (profiler-memory-log)))
|
|
|
|
|
(if (and (not profiler-cpu-log) (not profiler-memory-log))
|
|
|
|
|
(user-error "No profiler run recorded")
|
|
|
|
|
(profiler-report-cpu)
|
|
|
|
|
(profiler-report-memory)))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun profiler-find-profile (filename)
|
|
|
|
|
"Open profile FILENAME."
|
|
|
|
|
(interactive
|
|
|
|
|
(list (read-file-name "Find profile: " default-directory)))
|
|
|
|
|
(profiler-report-profile (profiler-read-profile filename)))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun profiler-find-profile-other-window (filename)
|
|
|
|
|
"Open profile FILENAME."
|
|
|
|
|
(interactive
|
|
|
|
|
(list (read-file-name "Find profile: " default-directory)))
|
|
|
|
|
(profiler-report-profile-other-window (profiler-read-profile filename)))
|
2012-08-22 09:15:17 +00:00
|
|
|
|
|
2012-08-22 06:38:59 +00:00
|
|
|
|
;;;###autoload
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(defun profiler-find-profile-other-frame (filename)
|
|
|
|
|
"Open profile FILENAME."
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(interactive
|
2012-09-30 22:21:25 +00:00
|
|
|
|
(list (read-file-name "Find profile: " default-directory)))
|
|
|
|
|
(profiler-report-profile-other-frame(profiler-read-profile filename)))
|
2012-08-22 06:38:59 +00:00
|
|
|
|
|
2012-08-22 09:15:17 +00:00
|
|
|
|
|
|
|
|
|
;;; Profiling helpers
|
|
|
|
|
|
2012-09-30 22:21:25 +00:00
|
|
|
|
;; (cl-defmacro with-cpu-profiling ((&key sampling-interval) &rest body)
|
2012-09-26 15:19:10 +00:00
|
|
|
|
;; `(unwind-protect
|
|
|
|
|
;; (progn
|
|
|
|
|
;; (ignore (profiler-cpu-log))
|
2012-09-30 22:21:25 +00:00
|
|
|
|
;; (profiler-cpu-start ,sampling-interval)
|
2012-09-26 15:19:10 +00:00
|
|
|
|
;; ,@body)
|
|
|
|
|
;; (profiler-cpu-stop)
|
|
|
|
|
;; (profiler--report-cpu)))
|
|
|
|
|
|
|
|
|
|
;; (defmacro with-memory-profiling (&rest body)
|
|
|
|
|
;; `(unwind-protect
|
|
|
|
|
;; (progn
|
|
|
|
|
;; (ignore (profiler-memory-log))
|
|
|
|
|
;; (profiler-memory-start)
|
|
|
|
|
;; ,@body)
|
|
|
|
|
;; (profiler-memory-stop)
|
|
|
|
|
;; (profiler--report-memory)))
|
2012-08-22 09:15:17 +00:00
|
|
|
|
|
2012-08-22 06:38:59 +00:00
|
|
|
|
(provide 'profiler)
|
|
|
|
|
;;; profiler.el ends here
|