diff options
| author | Stefan Monnier | 2012-09-24 10:38:10 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-09-24 10:38:10 -0400 |
| commit | 3d80c99f3817bf5eccd6acc6a79498a4fde979a4 (patch) | |
| tree | 5377692a9d9b96157a42b8ae693a8f7d18a8bc85 /src/alloc.c | |
| parent | 0970d85fef9830e3b8e5cbfbdc04dbf00cc4c027 (diff) | |
| download | emacs-3d80c99f3817bf5eccd6acc6a79498a4fde979a4.tar.gz emacs-3d80c99f3817bf5eccd6acc6a79498a4fde979a4.zip | |
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.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/alloc.c b/src/alloc.c index 36adb49f835..2fc93f825d1 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -264,6 +264,7 @@ static Lisp_Object Qintervals; | |||
| 264 | static Lisp_Object Qbuffers; | 264 | static Lisp_Object Qbuffers; |
| 265 | static Lisp_Object Qstring_bytes, Qvector_slots, Qheap; | 265 | static Lisp_Object Qstring_bytes, Qvector_slots, Qheap; |
| 266 | static Lisp_Object Qgc_cons_threshold; | 266 | static Lisp_Object Qgc_cons_threshold; |
| 267 | Lisp_Object Qautomatic_gc; | ||
| 267 | Lisp_Object Qchar_table_extra_slots; | 268 | Lisp_Object Qchar_table_extra_slots; |
| 268 | 269 | ||
| 269 | /* Hook run after GC has finished. */ | 270 | /* Hook run after GC has finished. */ |
| @@ -5421,6 +5422,7 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5421 | EMACS_TIME start; | 5422 | EMACS_TIME start; |
| 5422 | Lisp_Object retval = Qnil; | 5423 | Lisp_Object retval = Qnil; |
| 5423 | size_t tot_before = 0; | 5424 | size_t tot_before = 0; |
| 5425 | struct backtrace backtrace; | ||
| 5424 | 5426 | ||
| 5425 | if (abort_on_gc) | 5427 | if (abort_on_gc) |
| 5426 | abort (); | 5428 | abort (); |
| @@ -5430,6 +5432,14 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5430 | if (pure_bytes_used_before_overflow) | 5432 | if (pure_bytes_used_before_overflow) |
| 5431 | return Qnil; | 5433 | return Qnil; |
| 5432 | 5434 | ||
| 5435 | /* Record this function, so it appears on the profiler's backtraces. */ | ||
| 5436 | backtrace.next = backtrace_list; | ||
| 5437 | backtrace.function = &Qautomatic_gc; | ||
| 5438 | backtrace.args = &Qautomatic_gc; | ||
| 5439 | backtrace.nargs = 0; | ||
| 5440 | backtrace.debug_on_exit = 0; | ||
| 5441 | backtrace_list = &backtrace; | ||
| 5442 | |||
| 5433 | check_cons_list (); | 5443 | check_cons_list (); |
| 5434 | 5444 | ||
| 5435 | /* Don't keep undo information around forever. | 5445 | /* Don't keep undo information around forever. |
| @@ -5486,7 +5496,6 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5486 | shrink_regexp_cache (); | 5496 | shrink_regexp_cache (); |
| 5487 | 5497 | ||
| 5488 | gc_in_progress = 1; | 5498 | gc_in_progress = 1; |
| 5489 | is_in_trace = 1; | ||
| 5490 | 5499 | ||
| 5491 | /* Mark all the special slots that serve as the roots of accessibility. */ | 5500 | /* Mark all the special slots that serve as the roots of accessibility. */ |
| 5492 | 5501 | ||
| @@ -5538,8 +5547,6 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5538 | mark_backtrace (); | 5547 | mark_backtrace (); |
| 5539 | #endif | 5548 | #endif |
| 5540 | 5549 | ||
| 5541 | mark_profiler (); | ||
| 5542 | |||
| 5543 | #ifdef HAVE_WINDOW_SYSTEM | 5550 | #ifdef HAVE_WINDOW_SYSTEM |
| 5544 | mark_fringe_data (); | 5551 | mark_fringe_data (); |
| 5545 | #endif | 5552 | #endif |
| @@ -5607,7 +5614,6 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5607 | check_cons_list (); | 5614 | check_cons_list (); |
| 5608 | 5615 | ||
| 5609 | gc_in_progress = 0; | 5616 | gc_in_progress = 0; |
| 5610 | is_in_trace = 0; | ||
| 5611 | 5617 | ||
| 5612 | consing_since_gc = 0; | 5618 | consing_since_gc = 0; |
| 5613 | if (gc_cons_threshold < GC_DEFAULT_THRESHOLD / 10) | 5619 | if (gc_cons_threshold < GC_DEFAULT_THRESHOLD / 10) |
| @@ -5720,24 +5726,19 @@ See Info node `(elisp)Garbage Collection'. */) | |||
| 5720 | gcs_done++; | 5726 | gcs_done++; |
| 5721 | 5727 | ||
| 5722 | /* Collect profiling data. */ | 5728 | /* Collect profiling data. */ |
| 5723 | if (sample_profiler_running || memory_profiler_running) | 5729 | if (memory_profiler_running) |
| 5724 | { | 5730 | { |
| 5725 | size_t swept = 0; | 5731 | size_t swept = 0; |
| 5726 | size_t elapsed = 0; | ||
| 5727 | if (memory_profiler_running) | 5732 | if (memory_profiler_running) |
| 5728 | { | 5733 | { |
| 5729 | size_t tot_after = total_bytes_of_live_objects (); | 5734 | size_t tot_after = total_bytes_of_live_objects (); |
| 5730 | if (tot_before > tot_after) | 5735 | if (tot_before > tot_after) |
| 5731 | swept = tot_before - tot_after; | 5736 | swept = tot_before - tot_after; |
| 5732 | } | 5737 | } |
| 5733 | if (sample_profiler_running) | 5738 | malloc_probe (swept); |
| 5734 | { | ||
| 5735 | EMACS_TIME since_start = sub_emacs_time (current_emacs_time (), start); | ||
| 5736 | elapsed = EMACS_TIME_TO_DOUBLE (since_start) * 1000; | ||
| 5737 | } | ||
| 5738 | gc_probe (swept, elapsed); | ||
| 5739 | } | 5739 | } |
| 5740 | 5740 | ||
| 5741 | backtrace_list = backtrace.next; | ||
| 5741 | return retval; | 5742 | return retval; |
| 5742 | } | 5743 | } |
| 5743 | 5744 | ||
| @@ -6867,6 +6868,7 @@ do hash-consing of the objects allocated to pure space. */); | |||
| 6867 | DEFSYM (Qstring_bytes, "string-bytes"); | 6868 | DEFSYM (Qstring_bytes, "string-bytes"); |
| 6868 | DEFSYM (Qvector_slots, "vector-slots"); | 6869 | DEFSYM (Qvector_slots, "vector-slots"); |
| 6869 | DEFSYM (Qheap, "heap"); | 6870 | DEFSYM (Qheap, "heap"); |
| 6871 | DEFSYM (Qautomatic_gc, "Automatic GC"); | ||
| 6870 | 6872 | ||
| 6871 | DEFSYM (Qgc_cons_threshold, "gc-cons-threshold"); | 6873 | DEFSYM (Qgc_cons_threshold, "gc-cons-threshold"); |
| 6872 | DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots"); | 6874 | DEFSYM (Qchar_table_extra_slots, "char-table-extra-slots"); |