Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The suggestion of setting <code>debug-on-quit</code> to <code>t</code> so that you can find out what Emacs is up to is a good one. You can think of this as being a form of sampling profiling with a single sample: often a single sample is all you need.</p> <hr> <p><strong>Update:</strong> Starting with version 24.3, Emacs contains <em>two</em> profilers. There's a (new) sampling profiler in <code>profiler.el</code>, and an (old) instrumenting profiler in <code>elp.el</code>.</p> <p>The sampling profiler is <a href="http://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html" rel="noreferrer">documented here</a>. It's pretty straightforward to use:</p> <blockquote> <p>To begin profiling, type <code>M-x profiler-start</code>. You can choose to profile by processor usage, memory usage, or both. After doing some work, type <code>M-x profiler-report</code> to display a summary buffer for each resource that you chose to profile. When you have finished profiling, type <code>M-x profiler-stop</code>.</p> </blockquote> <p>Here's some example output from a <code>cpu+mem</code> profiler session with the <a href="https://github.com/gareth-rees/p4.el" rel="noreferrer">Perforce/Emacs integration</a> that I maintain. I've expanded the topmost function (<code>progn</code>) in order to find out <a href="https://github.com/gareth-rees/p4.el/issues/112" rel="noreferrer">where the CPU time and memory use is coming from</a>.</p> <pre class="lang-none prettyprint-override"><code>Function Bytes % - progn 26,715,850 29% - let 26,715,850 29% - while 26,715,850 29% - let 26,715,850 29% - cond 26,715,850 29% - insert 26,715,850 29% + c-after-change 26,713,770 29% + p4-file-revision-annotate-links 2,080 0% + let 20,431,797 22% + call-interactively 12,767,261 14% + save-current-buffer 10,005,836 11% + while 8,337,166 9% + p4-annotate-internal 5,964,974 6% + p4-annotate 2,821,034 3% + let* 2,089,810 2% </code></pre> <p>You can see that the culprit is <code>c-after-change</code>, so it looks as though I could save a lot of CPU time and memory by <a href="https://github.com/gareth-rees/p4.el/commit/4e015793877a56c4ccb1bfbb6e2d278be7c078d8" rel="noreferrer">locally binding <code>inhibit-modification-hooks</code> to <code>t</code> around this code</a>.</p> <hr> <p>You can also use the Emacs Lisp Profiler. This is rather under-documented: you'll have to read the comments in <code>elp.el</code> for the details, but basically you run <code>elp-instrument-package</code> to turn on profiling for all the functions with a given prefix, and then <code>elp-results</code> to see the results.</p> <p>Here's some typical output after typing <code>M-x elp-instrument-package RET c- RET</code>, fontifying 4,000 lines of C, and then running <code>elp-results</code> (and using <code>elp-sort-by-function</code> to sort by call count):</p> <pre class="lang-none prettyprint-override"><code>Function Name Call Count Elapsed Time Average Time ============================= ========== ============ ============ c-skip-comments-and-strings 107 0.0 0.0 c-valid-offset 78 0.0 0.0 c-set-offset 68 0.031 0.0004558823 c-end-of-macro 52 0.0 0.0 c-neutralize-CPP-line 52 0.0 0.0 c-font-lock-invalid-string 20 0.0 0.0 c-set-style-1 19 0.031 0.0016315789 ... </code></pre> <p>In your particular case the profiler doesn't help immediately, because you don't know which package is at fault. But if you can make a guess (or use <code>debug-on-quit</code> to find it for sure) then the profiler can help you diagnose the problem in detail.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload