summaryrefslogtreecommitdiff
path: root/module/statprof.scm
Commit message (Expand)AuthorAgeFilesLines
* Adapt gcprof to preemptive interrupts...* module/statprof.scm (gcprof): Remove handle-interrupts trampoline from captured stacks. Andy Wingo2017-03-091-4/+4
* Adapt statprof to new preemptive interrupts...* module/statprof.scm (profile-signal-handler): Cut an additional stack frame, corresponding to the handle-interrupts trampoline added recently. Andy Wingo2017-03-091-2/+4
* statprof: 'with-statprof' honors #:display-style....* module/statprof.scm (with-statprof): Pass #:display-style to 'statprof'. Ludovic Courtès2017-03-091-1/+5
* Update statprof documentation; deprecate `with-statprof'...* module/statprof.scm: Remove most of the commentary, as it was duplicated in the manual and was getting out of date. (stats): Remove self-secs-per-call and cum-secs-per-call fields as they can be computed from the other fields. (statprof-call-data->stats): Adapt. (statprof-stats-self-secs-per-call): (statprof-stats-cum-secs-per-call): New functions. (statprof-display/flat): Don't print the seconds-per-call fields, as we are no longer stopping the clock around call counters. Anyway these times were quite misleading. (with-statprof): Deprecate. It took its keyword arguments at the beginning; very complicated! Better to use the `statprof' function. (`statprof' was introduced after `with-statprof' and then `with-statprof' was adapted to use it.) * doc/ref/statprof.texi (Statprof): Port this documentation away from the automatically generated text and update it for the new interfaces like #:display-style. * module/system/base/syntax.scm (record-case): Remove comment that referenced with-statprof. Add comment indicating that record-case should be replaced. * doc/ref/scheme-using.texi (Profile Commands): Update to mention keyword arguments and to link to the statprof documentation. Andy Wingo2016-02-011-114/+47
* Better call-counting profiles in statprof...* module/statprof.scm: Update commentary. (count-call): Don't bother stopping and starting the timer. The overhead of call counting perturbs timing too much already, and somewhat paradoxically stopping and starting the timer takes too much time. (skip-count-call): New function. (stack-samples->procedure-data, stack-samples->callee-lists): If we are counting calls, skip any part of the stack that is inside count-call. Andy Wingo2016-02-011-32/+39
* Remove frame-local-ref, frame-local-set!...* libguile/frames.h (scm_frame_num_locals, scm_frame_local_ref) (scm_frame_local_set_x): Remove. As long as we are changing the interface in a backward-incompatible way, we might as well remove these. * libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref) (scm_frame_local_set_x, scm_init_frames_builtins, scm_init_frames): Arrange to make frame-local-ref et al private to frames.scm. * module/system/vm/frame.scm: Load scm_init_frames_builtins extensions. (frame-instruction-pointer-or-primitive-procedure-name): New public function. (frame-binding-ref, frame-binding-set!): Allow binding objects as vars. * module/system/repl/debug.scm (print-locals): Pass binding directly to frame-binding-ref. * module/statprof.scm (sample-stack-procs, count-call): Use new frame-instruction-pointer-or-primitive-procedure-name function. Andy Wingo2016-01-311-11/+3
* statprof: Better tree-format profiles...* module/statprof.scm (statprof-fetch-call-tree): Add #:precise? keyword argument, defaulting to false. Search for cycles after computing printable source locations instead of doing so over addresses -- it could be that two addresses map to the same source location, and from the user's perspective they are then indistinguishable in the printout. Andy Wingo2016-01-111-19/+29
* statprof: Add tree #:display-style....* module/statprof.scm (statprof-display/flat): Rename from statprof-display. Use real format; we have it. (statprof-display-anomalies): Likewise use real format. (procedure=?): Remove unused function. (collect-cycles): New helper. (statprof-fetch-call-tree): Fix to root the trees correctly -- it was interpreting them in the wrong order. Detect cycles so that it's not so terrible. Use precise locations for source locations. Probably need to add an option to go back to the per-function behavior. (statprof-display/tree): New helper, uses statprof-fetch-call-tree to display a profile in a nested tree. (statprof-display): Add #:style argument, which can be `flat', `anomalies', or `tree'. (statprof): Add #:display-style argument, proxying to #:style, defaulting to 'flat. Andy Wingo2016-01-111-32/+119
* Remove primitive?, add primitive-code?...We need to be able to identify frames that are primitive applications without assuming that slot 0 in a frame is an SCM value and without assuming that value is the procedure being applied. * libguile/gsubr.c (scm_i_primitive_code_p): New helper. (scm_i_primitive_arity): Use the new helper. * libguile/gsubr.h: Declare the new helper. * libguile/programs.h: * libguile/programs.c (scm_program_code_p): New function, replacing scm_primitive_p. (scm_primitive_call_ip): Fix FUNC_NAME definition. * module/statprof.scm (sample-stack-procs, count-call): Identify primitive frames from the IP, not the frame-procedure. Avoids the assumption that slot 0 in a frame is a SCM value. (statprof-proc-call-data): Adapt to primitive-code? change. * module/system/vm/frame.scm (frame-call-representation): Identify primitive frames from the IP, not the closure. Still more work to do here to avoid assuming slot 0 is a procedure. * module/system/vm/program.scm: Export primitive-code? instead of primitive?. (program-arguments-alist, program-arguments-alists): Identify primitives from the code instead of the flags on the program. Not sure this is a great change, but it does avoid having to define a primitive? predicate in Scheme. Andy Wingo2015-12-011-14/+19
* Merge commit 'cdcba5b2f6270de808e51b3b933374170611b91d'...Conflicts: module/statprof.scm Andy Wingo2015-01-221-9/+11
|\
| * statprof: 'statprof' and 'with-statprof' return the code's return values....* module/statprof.scm (statprof): Return the return values of THUNK. (with-statprof): Adjust docstring accordingly. * test-suite/tests/statprof.test ("return values"): New test. * doc/ref/statprof.texi (Statprof): Adjust accordingly. Ludovic Courtès2015-01-111-11/+12
* | Fix inner and outer stack cuts to match on procedure code...* doc/ref/api-debug.texi (Stack Capture): Update make-stack docs. * libguile/programs.h: * libguile/programs.c (scm_program_address_range): New internal procedure. * libguile/stacks.c (narrow_stack): Interpret a pair of integers as an address range. If a cut is a procedure, attempt to resolve it to an address range. (scm_make_stack): Update docstring. * module/system/vm/program.scm (program-address-range): New exported procedure. * module/statprof.scm (statprof, gcprof): Use program-address-range to get the outer-cut, for efficiency. Andy Wingo2014-05-011-2/+4
* | Fix statprof for optimizations...* module/statprof.scm (profile-signal-handler): Bind in a letrec. Otherwise the compiler may see the closure slot as dead, and the inner stack cut won't work. Andy Wingo2014-04-161-21/+28
* | statprof avoids mucking with VM trace levels when not counting calls...* module/statprof.scm (statprof-start, statprof-stop): Don't futz the vm trace level when we aren't counting calls. With this change, statprof now imposes no overhead on the measured program. Andy Wingo2014-04-141-5/+5
* | Better state handling in statprof...* module/statprof.scm (statprof-fold-call-data) (statprof-proc-call-data): Add optional state arg. (gcprof): Add optional port arg, and pass state arg explicitly. (statprof-display-anomalies, statprof-display) (statprof-call-data->stats): Pass state explicitly. Andy Wingo2014-04-141-16/+20
* | ,profile, statprof, gcprof have an outer stack cut...* module/statprof.scm (<state>): Add outer-cut member. (fresh-profiler-state): Add outer-cut kwarg. (sample-stack-procs): Stop when the stack-length is zero, which will be before the frames run out if there is an outer cut. (profile-signal-handler): Use the outer cut when capturing the stack. (call-thunk): New helper, for use as an outer cut. (statprof, gcprof): Call the thunk within call-thunk, and use call-thunk as an outer cut. Andy Wingo2014-03-011-22/+28
* | Statprof commentings...* module/statprof.scm: Add a big ol' comment. (sample-stack-procs): If slot 0 isn't a primitive, use the IP to mark. In the future we will see more non-procedures in slot 0 as we start to use call-label and tail-call-label. Andy Wingo2014-03-011-17/+87
* | statprof-display prints source locations...* module/statprof.scm (call-data): Source is after printable. (addr->printable): Just produce a name, without source. Anonymous printables get "anon " prefixed. (stack-samples->procedure-data): Adapt to call-data change. (stats): Add "proc-source" element. (statprof-call-data->stats): Give a source to the call-data. (statprof-display): Print source also. Andy Wingo2014-03-011-17/+31
* | Refactorings: call-data has source, stats is a record...* module/statprof.scm (call-data): Add source member. (stack-samples->procedure-data): Populate source member (stats): Convert to record from vector. (statprof-call-data->stats): Adapt to produce a record. Andy Wingo2014-02-281-31/+31
* | Statprof uses stack trace buffer to always provide full stacks...* module/statprof.scm (<state>): Remove record-full-stacks? and stacks members. The stack trace buffer is sufficient. (fresh-profiler-state): Adapt. (sample-stack-procs): Don't save stacks. (statprof-reset): Deprecate the full-stacks? argument. (stack-samples->procedure-data): Remove a needless vector-ref. (stack-samples->callee-lists): New helper. (statprof-fetch-stacks): Use stack-samples->callee-lists. (statprof-fetch-call-tree): Use stack-samples->callee-lists, and implement our own callee->string helper. (statprof, with-statprof, gcprof): Deprecate full-stacks? argument. Andy Wingo2014-02-281-61/+62
* | Statprof always stores full stack traces...* module/statprof.scm (<state>): Instead of a boolean count-calls?, treat the presence of a call-counts hash table as indicating a need to count calls. That hash table maps callees to call counts. A "callee" is either the IP of the entry of a program, the symbolic name of a primitive, or the identity of a non-program. New members "buffer" and "buffer-pos" replace "procedure-data". We try to avoid analyzing things at runtime, instead just recording the stack traces into a buffer. This will let us do smarter things when post-processing. (fresh-buffer, expand-buffer): New helpers. (fresh-profiler-state): Adapt to <state> changes. (sample-stack-procs): Instead of updating the procedure-data table (which no longer exists), instead trace the stack into the buffer. (count-call): Update to update the call-counts table instead of the procedure-data table. (statprof-start, statprof-start): Adapt to call-counts change. (call-data): Move lower in the file. Add "name" and "printable" members, and no longer store a proc. (source->string, program-debug-info-printable, addr->pdi) (addr->printable): New helpers. (stack-samples->procedure-data): New procedure to process stack trace buffer into a hash table of the same format as the old procedure-data table. (statprof-fold-call-data, statprof-proc-call-data): Use stack-samples->procedure-data instead of procedure-data. (statprof-call-data->stats): Adapt to count-calls change. (statprof-display, statprof-display-anomalies): Adapt. Andy Wingo2014-02-281-113/+192
* | Update statprof commentary...* module/statprof.scm: Update commentary. Andy Wingo2014-02-281-9/+6
* | More state-related refactors in statprof...* module/statprof.scm (statprof-start, statprof-stop): Take optional state arg. (statprof-reset): Return no values. (statprof): Take port keyword arg. Since statprof-reset is now the same as parameterizing profiler-state, there's no need to call statprof-reset. Pass the state argument explicitly to statprof-start, statprof-stop, and statprof-display. Andy Wingo2014-02-281-14/+12
* | Statprof restores previous sigprof handler when stopping...* module/statprof.scm (<state>): Add field for the previous SIGPROF handler. (statprof-start, statprof-stop, statprof-reset): Instead of setting the SIGPROF handler in statprof-reset, set it when the profiler becomes active, and actually restore it when the profiler becomes inactive. Andy Wingo2014-02-281-11/+15
* | More statprof refactors...* module/statprof.scm (statprof-display, statprof-display-anomalies) (statprof-accumulated-time, statprof-sample-count) (statprof-fetch-stacks, statprof-fetch-call-tree): Take optional state argument. (statprof-display-anomolies): Deprecate this mis-spelling. (statprof): Just compute usecs for the period. Andy Wingo2014-02-281-23/+21
* | Slight gcprof refactor...* module/statprof.scm (gcprof): Refactor a bit. Andy Wingo2014-02-281-25/+12
* | statprof uses new setitimer magical usecs ability...* module/statprof.scm (sample-stack-procs): Take advantage of setitimer allowing usecs >= 1e6. Andy Wingo2014-02-281-5/+3
* | gcprof tweaks...* module/statprof.scm (gcprof): No need to reset in gcprof; the fresh profiler state and the parameterize handle that. Fix mistaken set-vm-trace-level! as well. Andy Wingo2014-02-251-15/+1
* | Refactor representation of sampling periods in statprof...* module/statprof.scm (<state>): The sampling frequency is actually a period; label it as such, and express in microseconds instead of as a pair. Likewise for remaining-prof-time. (fresh-profiler-state): Adapt. (reset-sigprof-timer): New helper. (profile-signal-handler): Use the new helper. (statprof-start): Use the new helper. (statprof-stop): Here too. (statprof-reset): Adapt to <state> change. (gcprof): Set remaining prof time to 0. Andy Wingo2014-02-251-24/+21
* | statprof and gcprof procedures use a fresh statprof state...* module/statprof.scm (statprof, gcprof): Create a fresh statprof state. Andy Wingo2014-02-251-83/+82
* | simplify profile-signal-handler...* module/statprof.scm (profile-signal-handler): Don't bother detecting if we were in a count-call call or not; it doesn't matter, and we should accumulate time in any case. Andy Wingo2014-02-221-20/+7
* | statprof: accumulated-time is in jiffies...* module/statprof.scm (fresh-profiler-state): accumulated-time and gc-time-taken are in jiffies, not seconds, so they are exact. (statprof-accumulated-time): Divide by 1.0 so that we get a flonum. Also refactor use of assq to get the gc-time-taken. Andy Wingo2014-02-221-8/+8
* | Pass state around statprof in more places...* module/statprof.scm (get-call-data, sample-stack-procs): Take the state as an argument. (profile-signal-handler, count-call, statprof-proc-call-data) (gcprof): Adapt. Andy Wingo2014-02-221-11/+11
* | statprof: call-data is a record type...* module/statprof.scm (call-data): Reimplement as a record type. Andy Wingo2014-02-221-11/+11
* | statprof: when/unless instead of if....* module/statprof.scm: Use when or unless instead of if, where appropriate. Andy Wingo2014-02-221-108/+101
* | add a statprof fixme...* module/statprof.scm: Add a fixme. Andy Wingo2014-02-211-0/+5
* | statprof-active? instead of checking profile level...* module/statprof.scm (statprof-reset, statprof-fold-call-data): (statprof-proc-call-data, statprof-accumulated-time): (statprof-sample-count): Refactor some things to use statprof-active? instead of checking the profile level manually. Andy Wingo2014-02-211-19/+12
* | statprof-reset creates a new state...* module/statprof.scm (fresh-profiler-state): New helper. (ensure-profiler-state): Use it. (accumulate-time): No need to add 0.0 here. (statprof-reset): Create a new state instead of mutating the existing one. Andy Wingo2014-02-211-16/+16
* | More statprof state refactorings...* module/statprof.scm (existing-profiler-state): New helper, gets the profiler state or fails if there is no state. (sample-stack-procs, profile-signal-handler, count-call) (statprof-fold-call-data, statprof-proc-call-data) (statprof-call-data->stats, statprof-display) (statprof-display-anomolies, statprof-accumulated-time) (statprof-sample-count, statprof-fetch-stacks) (statprof-fetch-call-tree): Use the new helper. (statprof-active?): Don't create a state if there isn't one already. Andy Wingo2014-02-211-14/+18
* | inside-profiler? to parameter instead of global variable...* module/statprof.scm (<state>): Add inside-profiler? member. Move mutations of inside-profiler? here. Andy Wingo2014-02-211-11/+11
* | Beginnings of statprof threadsafety...* module/statprof.scm (<state>, profiler-state, ensure-profiler-state): A mostly-mechanical refactor to encapsulate profiler state in a parameter and a record instead of global variables. Andy Wingo2014-02-211-108/+155
* | reform statprof commentary...* module/statprof.scm: Reformat the commentary. Andy Wingo2014-02-211-100/+89
* | VM accessors take VM as implicit argument, not explicit argument...* libguile/vm.h: * libguile/vm.c: (scm_vm_apply_hook, scm_vm_push_continuation_hook, scm_vm_pop_continuation_hook, scm_vm_abort_continuation_hook, scm_vm_restore_continuation_hook, scm_vm_next_hook, scm_vm_trace_level, scm_set_vm_trace_level_x, scm_vm_engine, scm_set_vm_engine_x, scm_c_set_vm_engine_x): The VM argument is now implicit: the VM for the current thread. * doc/ref/api-debug.texi (VM Hooks): Try to adapt. * module/ice-9/command-line.scm: * module/statprof.scm: * module/system/vm/coverage.scm: * module/system/vm/trace.scm: * module/system/vm/trap-state.scm: * module/system/vm/traps.scm: * test-suite/tests/control.test: * test-suite/tests/eval.test: Adapt users that set hooks or ensure that we have a debug engine. Andy Wingo2013-11-211-9/+7
* | rtl-program-code -> program-code...* libguile/programs.h: * libguile/programs.c (scm_program_code): Rename from scm_rtl_program_code. Also renames rtl-program-code to program-code. * module/statprof.scm: * module/system/repl/command.scm: * module/system/repl/debug.scm: * module/system/vm/coverage.scm: * module/system/vm/disassembler.scm: * module/system/vm/program.scm: * module/system/vm/traps.scm: * test-suite/tests/dwarf.test: * test-suite/tests/rtl.test: Adapt callers. Andy Wingo2013-11-191-2/+2
* | rtl-program? -> program?...* libguile/programs.c (scm_program_p): Rename from scm_rtl_program_p. Changes name also from rtl-program? to program?. * libguile/programs.h: * module/ice-9/session.scm: * module/language/tree-il/analyze.scm: * module/statprof.scm: * module/system/repl/command.scm: * module/system/repl/debug.scm: * module/system/vm/coverage.scm: * module/system/vm/disassembler.scm: * module/system/vm/frame.scm: * module/system/vm/program.scm: * module/system/vm/traps.scm: * module/system/xref.scm: Adapt. Andy Wingo2013-11-191-2/+2
* | Remove stack programs, objcode, and the old VM....* libguile/Makefile.am: * libguile/vm-i-loader.c: * libguile/vm-i-scheme.c: * libguile/vm-i-system.c: Remove the old VM files, and the rules to build the .i files. * libguile/vm-engine.c: * libguile/vm.c: Remove the old VM. Woot! * libguile/_scm.h (SCM_OBJCODE_COOKIE, SCM_OBJCODE_ENDIANNESS_OFFSET) (SCM_OBJCODE_WORD_SIZE_OFFSET): Remove. * libguile/evalext.c (scm_self_evaluating_p): Remove objcode and program cases. * libguile/frames.c (scm_frame_num_locals, scm_frame_previous): Remove program cases. * libguile/gc.c (scm_i_tag_name): Remove objcode case. * libguile/goops.c (scm_class_of, create_standard_classes): Remove objcode and program cases. * libguile/instructions.h: * libguile/instructions.c (scm_instruction_list, scm_instruction_p) (scm_instruction_length, scm_instruction_pops, scm_instruction_pushes) (scm_instruction_to_opcode, scm_opcode_to_instruction): Remove old VM code. * libguile/objcodes.h: * libguile/objcodes.c: Remove the objcode data type, and handling for objcode files. * libguile/print.c: Remove objcode and program printers. * libguile/procprop.c: Remove program cases. * libguile/procs.c: * libguile/programs.h: * libguile/programs.c: Remove old program code. * libguile/smob.c: Remove objcodes include. * libguile/snarf.h: Remove static program defines. * libguile/stacks.c: Remove program case. * libguile/tags.h: Remove program and objcode tc7s. * module/ice-9/session.scm (procedure-arguments) * module/language/tree-il/analyze.scm (validate-arity) * module/statprof.scm (get-call-data, procedure=?) * module/system/vm/frame.scm (frame-bindings) (frame-call-representation): Remove old program cases. * module/system/repl/debug.scm (frame->module): Add a FIXME. * module/system/vm/instruction.scm: Remove old exports. * module/system/vm/program.scm: Remove old program code. Andy Wingo2013-11-081-3/+0
* | Fix statprof-proc-call-data for recent changes...* module/statprof.scm (statprof-proc-call-data): Fix statprof for recent fixes. Andy Wingo2013-10-181-1/+1
* | Statprof works better with RTL programs...* module/statprof.scm (get-call-data, procedure=?): Work with RTL programs. Andy Wingo2013-10-171-7/+9
|/
* add gcprof...* module/statprof.scm (gcprof): New variant of statprof; instead of being driven by setitimer, this one is driven by the after-gc-hook. Andy Wingo2011-05-051-2/+83
* minor statprof tweaks...* module/statprof.scm (statprof-reset): Make full-stacks? into an optional arg instead of doing the rest arg dance. (statprof-display): Format gc-time-taken appropriately. Andy Wingo2011-05-051-4/+4