From c8fd36bbdb991c20cd64faecf30cbb195bf031d0 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 10 Nov 2011 12:32:43 -0800 Subject: [PATCH] kill tools.profiler.counting and ui.tools.profiler Load tools.profiler.sampling from bootstrap/tools instead. --- basis/bootstrap/tools/tools.factor | 2 +- basis/help/handbook/handbook.factor | 2 +- basis/listener/listener.factor | 2 +- .../known-words/known-words.factor | 11 +- .../tools/annotations/annotations-docs.factor | 2 +- basis/tools/profiler/counting/authors.txt | 1 - .../profiler/counting/counting-docs.factor | 68 ------ .../profiler/counting/counting-tests.factor | 79 ------- basis/tools/profiler/counting/counting.factor | 83 ------- basis/tools/profiler/counting/summary.txt | 1 - basis/tools/profiler/counting/tags.txt | 1 - basis/tools/time/time-docs.factor | 2 +- .../tools/operations/operations-docs.factor | 2 +- basis/ui/tools/operations/operations.factor | 9 +- basis/ui/tools/profiler/authors.txt | 1 - basis/ui/tools/profiler/profiler-docs.factor | 15 -- basis/ui/tools/profiler/profiler-tests.factor | 3 - basis/ui/tools/profiler/profiler.factor | 215 ------------------ basis/ui/tools/profiler/summary.txt | 1 - basis/ui/tools/profiler/tags.txt | 1 - basis/ui/tools/tools-docs.factor | 5 +- 21 files changed, 14 insertions(+), 492 deletions(-) delete mode 100644 basis/tools/profiler/counting/authors.txt delete mode 100644 basis/tools/profiler/counting/counting-docs.factor delete mode 100644 basis/tools/profiler/counting/counting-tests.factor delete mode 100644 basis/tools/profiler/counting/counting.factor delete mode 100644 basis/tools/profiler/counting/summary.txt delete mode 100644 basis/tools/profiler/counting/tags.txt delete mode 100644 basis/ui/tools/profiler/authors.txt delete mode 100644 basis/ui/tools/profiler/profiler-docs.factor delete mode 100644 basis/ui/tools/profiler/profiler-tests.factor delete mode 100644 basis/ui/tools/profiler/profiler.factor delete mode 100644 basis/ui/tools/profiler/summary.txt delete mode 100644 basis/ui/tools/profiler/tags.txt diff --git a/basis/bootstrap/tools/tools.factor b/basis/bootstrap/tools/tools.factor index 731b36d1ce..b1ecbfe8dc 100644 --- a/basis/bootstrap/tools/tools.factor +++ b/basis/bootstrap/tools/tools.factor @@ -14,7 +14,7 @@ IN: bootstrap.tools "tools.disassembler" "tools.dispatch" "tools.memory" - "tools.profiler.counting" + "tools.profiler.sampling" "tools.test" "tools.time" "tools.threads" diff --git a/basis/help/handbook/handbook.factor b/basis/help/handbook/handbook.factor index 81f92deff9..3964e34d94 100644 --- a/basis/help/handbook/handbook.factor +++ b/basis/help/handbook/handbook.factor @@ -352,7 +352,7 @@ ARTICLE: "handbook-tools-reference" "Developer tools" { $heading "Performance" } { $subsections "timing" - "tools.profiler.counting" + "tools.profiler.sampling" "tools.memory" "tools.threads" "tools.destructors" diff --git a/basis/listener/listener.factor b/basis/listener/listener.factor index 0ad02e073b..740b739c42 100644 --- a/basis/listener/listener.factor +++ b/basis/listener/listener.factor @@ -175,7 +175,7 @@ SYMBOL: interactive-vocabs "tools.dispatch" "tools.errors" "tools.memory" - "tools.profiler.counting" + "tools.profiler.sampling" "tools.test" "tools.threads" "tools.time" diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index a8124f8438..4c94b9aec4 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -14,7 +14,7 @@ compiler.units system.private combinators tools.memory.private combinators.short-circuit locals locals.backend locals.types combinators.private stack-checker.values generic.single generic.single.private alien.libraries tools.dispatch.private -macros +macros tools.profiler.sampling.private stack-checker.alien stack-checker.state stack-checker.errors @@ -26,8 +26,6 @@ stack-checker.dependencies stack-checker.recursive-state stack-checker.row-polymorphism ; QUALIFIED-WITH: generic.single.private gsp -QUALIFIED-WITH: tools.profiler.counting.private counting -QUALIFIED-WITH: tools.profiler.sampling.private sampling IN: stack-checker.known-words : infer-special ( word -- ) @@ -427,10 +425,9 @@ M: object infer-call* \ call bad-macro-input ; \ modify-code-heap { array object object } { } define-primitive \ nano-count { } { integer } define-primitive \ nano-count make-flushable \ optimized? { word } { object } define-primitive -\ counting:profiling { object } { } define-primitive -\ sampling:profiling { object } { } define-primitive -\ sampling:(get-samples) { } { object } define-primitive -\ sampling:(clear-samples) { } { } define-primitive +\ profiling { object } { } define-primitive +\ (get-samples) { } { object } define-primitive +\ (clear-samples) { } { } define-primitive \ quot-compiled? { quotation } { object } define-primitive \ quotation-code { quotation } { integer integer } define-primitive \ quotation-code make-flushable \ reset-dispatch-stats { } { } define-primitive diff --git a/basis/tools/annotations/annotations-docs.factor b/basis/tools/annotations/annotations-docs.factor index 5a315f3530..43fc3af129 100644 --- a/basis/tools/annotations/annotations-docs.factor +++ b/basis/tools/annotations/annotations-docs.factor @@ -49,7 +49,7 @@ HELP: watch-vars HELP: add-timing { $values { "word" word } } { $description "Adds timing code to a word, which records its total running time, including that of words it calls, on every invocation." } -{ $see-also "timing" "tools.profiler.counting" } ; +{ $see-also "timing" "tools.profiler.sampling" } ; HELP: reset-word-timing { $description "Resets the word timing table." } ; diff --git a/basis/tools/profiler/counting/authors.txt b/basis/tools/profiler/counting/authors.txt deleted file mode 100644 index 1901f27a24..0000000000 --- a/basis/tools/profiler/counting/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/tools/profiler/counting/counting-docs.factor b/basis/tools/profiler/counting/counting-docs.factor deleted file mode 100644 index 8302492b67..0000000000 --- a/basis/tools/profiler/counting/counting-docs.factor +++ /dev/null @@ -1,68 +0,0 @@ -USING: tools.profiler.counting.private tools.time tools.crossref -help.markup help.syntax quotations io strings words definitions ; -IN: tools.profiler.counting - -ARTICLE: "profiler-limitations" "Profiler limitations" -"Certain optimizations performed by the compiler can inhibit accurate call counting:" -{ $list - "Calls to open-coded intrinsics are not counted. Certain words are open-coded as inline machine code, and in some cases optimized out altogether; this includes stack shuffling operations, conditionals, and many object allocation operations." - { "Calls to " { $link POSTPONE: inline } " words are not counted." } - { "Calls to methods which were inlined as a result of type inference are not counted." } - "Tail-recursive loops will only count the initial invocation of the word, not every tail call." -} ; - -ARTICLE: "tools.profiler.counting" "Call-counting profiler" -"The " { $vocab-link "tools.profiler.counting" } " vocabulary implements a simple call counting profiler." -$nl -"Quotations can be passed to a combinator which calls them with the profiler enabled:" -{ $subsections profile } -"After a quotation has been profiled, call counts can be presented in various ways:" -{ $subsections - profile. - vocab-profile. - usage-profile. - vocabs-profile. - method-profile. - "profiler-limitations" -} -{ $see-also "ui.tools.profiler" "tools.annotations" "timing" } ; - -ABOUT: "tools.profiler.counting" - -HELP: counters -{ $values { "words" "a sequence of words" } { "alist" "an association list mapping words to integers" } } -{ $description "Outputs an association list of word call counts." } ; - -HELP: counters. -{ $values { "assoc" "an association list mapping words to integers" } } -{ $description "Prints an association list of call counts to " { $link output-stream } "." } ; - -HELP: profile -{ $values { "quot" quotation } } -{ $description "Calls the quotation while collecting word call counts, which can then be displayed using " { $link profile. } " or related words." } ; - -HELP: profile. -{ $description "Prints a table of call counts from the most recent invocation of " { $link profile } "." } ; - -HELP: vocab-profile. -{ $values { "vocab" string } } -{ $description "Prints a table of call counts from the most recent invocation of " { $link profile } ", for words in the " { $snippet "vocab" } " vocabulary only." } -{ $examples { $code "\"math\" vocab-profile." } } ; - -HELP: usage-profile. -{ $values { "word" word } } -{ $description "Prints a table of call counts from the most recent invocation of " { $link profile } ", for words which directly call " { $snippet "word" } " only." } -{ $notes "This word obtains the list of static usages with the " { $link smart-usage } " word, and is not aware of dynamic call history. Consider the following scenario. A word " { $snippet "X" } " can execute word " { $snippet "Y" } " in a conditional branch, and " { $snippet "X" } " is executed many times during the profiling run, but this particular branch executing " { $snippet "Y" } " is never taken. However, some other word does execute " { $snippet "Y" } " multiple times. Then " { $snippet "\\ Y usage-profile." } " will list a number of calls to " { $snippet "X" } ", even though " { $snippet "Y" } " was never executed " { $emphasis "from" } " " { $snippet "X" } "." } -{ $examples { $code "\\ + usage-profile." } } ; - -HELP: vocabs-profile. -{ $description "Print a table of cumilative call counts for each vocabulary. Vocabularies whose words were not called are supressed from the output." } ; - -HELP: method-profile. -{ $description "Print a table of cumilative call counts for each method. Methods which were not called are supressed from the output." } ; - -HELP: profiling -{ $values { "?" "a boolean" } } -{ $description "Internal primitive to switch on call counting. This word should not be used; instead use " { $link profile } "." } ; - -{ time profile } related-words diff --git a/basis/tools/profiler/counting/counting-tests.factor b/basis/tools/profiler/counting/counting-tests.factor deleted file mode 100644 index 4d5497a807..0000000000 --- a/basis/tools/profiler/counting/counting-tests.factor +++ /dev/null @@ -1,79 +0,0 @@ -USING: accessors tools.profiler.counting tools.test kernel memory math -threads alien alien.c-types tools.profiler.counting.private sequences -compiler.test compiler.units words arrays ; -IN: tools.profiler.counting.tests - -[ t ] [ - \ length counter>> - 10 [ { } length drop ] times - \ length counter>> = -] unit-test - -[ ] [ [ 3 [ gc ] times ] profile ] unit-test - -[ ] [ [ 1000000 sleep ] profile ] unit-test - -[ ] [ profile. ] unit-test - -[ ] [ vocabs-profile. ] unit-test - -[ ] [ "kernel.private" vocab-profile. ] unit-test - -[ ] [ \ + usage-profile. ] unit-test - -: callback-test ( -- callback ) void { } cdecl [ ] alien-callback ; - -: indirect-test ( callback -- ) void { } cdecl alien-indirect ; - -: foobar ( -- ) ; - -[ - [ ] [ callback-test indirect-test ] unit-test - foobar -] profile - -[ 1 ] [ \ foobar counter>> ] unit-test - -: fooblah ( -- ) { } [ ] like call( -- ) ; - -: foobaz ( -- ) fooblah fooblah ; - -[ foobaz ] profile - -[ 1 ] [ \ foobaz counter>> ] unit-test - -[ 2 ] [ \ fooblah counter>> ] unit-test - -: recompile-while-profiling-test ( -- ) ; - -[ ] [ - [ - 333 [ recompile-while-profiling-test ] times - { recompile-while-profiling-test } compile - 333 [ recompile-while-profiling-test ] times - ] profile -] unit-test - -[ 666 ] [ \ recompile-while-profiling-test counter>> ] unit-test - -[ ] [ [ [ ] compile-call ] profile ] unit-test - -[ [ gensym execute ] profile ] [ undefined? ] must-fail-with - -: crash-bug-1 ( -- x ) "hi" ; -: crash-bug-2 ( -- ) 100000 [ crash-bug-1 drop ] times ; - -[ ] [ [ crash-bug-2 ] profile ] unit-test - -[ 1 ] [ - [ - [ [ ] ( -- ) define-temp ] with-compilation-unit - dup execute( -- ) - ] profile - counter>> -] unit-test - -! unwind_native_frames() would fail if profiling was enabled -! because the jit-profiling stub would clobber a parameter register -! on x86-64 -[ [ -10 f ] profile ] must-fail diff --git a/basis/tools/profiler/counting/counting.factor b/basis/tools/profiler/counting/counting.factor deleted file mode 100644 index 92fa931c81..0000000000 --- a/basis/tools/profiler/counting/counting.factor +++ /dev/null @@ -1,83 +0,0 @@ -! Copyright (C) 2007, 2010 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors words sequences math prettyprint kernel arrays -io io.styles namespaces assocs kernel.private strings -combinators sorting math.parser vocabs definitions -tools.profiler.counting.private tools.crossref continuations generic -compiler.units compiler.crossref sets classes fry ; -FROM: sets => members ; -IN: tools.profiler.counting - -: profile ( quot -- ) - [ t profiling call ] [ f profiling ] [ ] cleanup ; inline - -: filter-counts ( alist -- alist' ) - [ second 0 > ] filter ; - -: map-counters ( obj quot -- alist ) - { } map>assoc filter-counts ; inline - -: counters ( words -- alist ) - [ dup counter>> ] map-counters ; - -: cumulative-counters ( obj quot -- alist ) - '[ dup @ [ counter>> ] map-sum ] map-counters ; inline - -: vocab-counters ( -- alist ) - vocabs [ words [ predicate? not ] filter ] cumulative-counters ; - -: generic-counters ( -- alist ) - all-words [ subwords ] cumulative-counters ; - -: methods-on ( class -- methods ) - dup implementors [ lookup-method ] with map ; - -: class-counters ( -- alist ) - classes [ methods-on ] cumulative-counters ; - -: method-counters ( -- alist ) - all-words [ subwords ] map concat counters ; - -: profiler-usage ( word -- words ) - [ smart-usage [ word? ] filter ] - [ generic-call-sites-of keys ] - [ effect-dependencies-of keys ] - tri 3append members ; - -: usage-counters ( word -- alist ) - profiler-usage counters ; - -: counters. ( assoc -- ) - sort-values simple-table. ; - -: profile. ( -- ) - "Call counts for all words:" print - all-words counters counters. ; - -: vocab-profile. ( vocab -- ) - "Call counts for words in the " write - dup dup lookup-vocab write-object - " vocabulary:" print - words counters counters. ; - -: usage-profile. ( word -- ) - "Call counts for words which call " write - dup pprint - ":" print - usage-counters counters. ; - -: vocabs-profile. ( -- ) - "Call counts for all vocabularies:" print - vocab-counters counters. ; - -: generic-profile. ( -- ) - "Call counts for methods on generic words:" print - generic-counters counters. ; - -: class-profile. ( -- ) - "Call counts for methods on classes:" print - class-counters counters. ; - -: method-profile. ( -- ) - "Call counts for all methods:" print - method-counters counters. ; diff --git a/basis/tools/profiler/counting/summary.txt b/basis/tools/profiler/counting/summary.txt deleted file mode 100644 index d4f9e20e27..0000000000 --- a/basis/tools/profiler/counting/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Call counting profiler diff --git a/basis/tools/profiler/counting/tags.txt b/basis/tools/profiler/counting/tags.txt deleted file mode 100644 index ef1aab0d0e..0000000000 --- a/basis/tools/profiler/counting/tags.txt +++ /dev/null @@ -1 +0,0 @@ -tools diff --git a/basis/tools/time/time-docs.factor b/basis/tools/time/time-docs.factor index e865885116..a508e90ede 100644 --- a/basis/tools/time/time-docs.factor +++ b/basis/tools/time/time-docs.factor @@ -10,7 +10,7 @@ ARTICLE: "timing" "Timing code and collecting statistics" "A lower-level word puts timings on the stack, instead of printing:" { $subsections benchmark } "You can also read the system clock directly; see " { $link "system" } "." -{ $see-also "tools.profiler.counting" "tools.annotations" "calendar" } ; +{ $see-also "tools.profiler.sampling" "tools.annotations" "calendar" } ; ABOUT: "timing" diff --git a/basis/ui/tools/operations/operations-docs.factor b/basis/ui/tools/operations/operations-docs.factor index ceaf36429a..f2ce1c1a6f 100644 --- a/basis/ui/tools/operations/operations-docs.factor +++ b/basis/ui/tools/operations/operations-docs.factor @@ -1,5 +1,5 @@ USING: help.tips help.markup help.syntax ui.operations -tools.walker tools.time tools.profiler.counting ui.tools.operations ; +tools.walker tools.time ui.tools.operations ; TIP: "Press " { $operation com-stack-effect } " to print the stack effect of the code in the input field without executing it (" { $link "inference" } ")." ; diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index 4ed9f53807..f10e0ed6a6 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -3,11 +3,11 @@ USING: continuations definitions generic help.topics threads stack-checker summary io.pathnames io.styles kernel namespaces parser prettyprint quotations tools.crossref tools.annotations -editors tools.profiler.counting tools.test tools.time tools.walker vocabs +editors tools.test tools.time tools.walker vocabs vocabs.loader words sequences classes compiler.errors compiler.units accessors vocabs.parser macros.expander ui ui.tools.browser ui.tools.listener ui.tools.listener.completion -ui.tools.profiler ui.tools.inspector ui.tools.traceback +ui.tools.inspector ui.tools.traceback ui.commands ui.gadgets.editors ui.gestures ui.operations ui.tools.deploy models help.tips source-files.errors destructors libc libc.private ; @@ -165,11 +165,6 @@ M: word com-stack-effect 1quotation com-stack-effect ; { +listener+ t } } define-operation -[ quotation? ] \ com-profile H{ - { +keyboard+ T{ key-down f { C+ } "o" } } - { +listener+ t } -} define-operation - : com-expand-macros ( quot -- ) expand-macros . ; [ quotation? ] \ com-expand-macros H{ diff --git a/basis/ui/tools/profiler/authors.txt b/basis/ui/tools/profiler/authors.txt deleted file mode 100644 index 1901f27a24..0000000000 --- a/basis/ui/tools/profiler/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/ui/tools/profiler/profiler-docs.factor b/basis/ui/tools/profiler/profiler-docs.factor deleted file mode 100644 index 3ca4b1957c..0000000000 --- a/basis/ui/tools/profiler/profiler-docs.factor +++ /dev/null @@ -1,15 +0,0 @@ -IN: ui.tools.profiler -USING: help.markup help.syntax ui.operations ui.commands help.tips ; - -ARTICLE: "ui.tools.profiler" "UI profiler tool" -"The " { $vocab-link "ui.tools.profiler" } " vocabulary implements a graphical tool for viewing profiling results (see " { $link "tools.profiler.counting" } ")." -$nl -"To use the profiler, enter a piece of code in the listener input area and press " { $operation com-profile } "." -$nl -"Clicking on a vocabulary in the vocabulary list narrows down the word list to only include words from that vocabulary. The sorting options control the order of elements in the vocabulary and word lists. The search fields narrow down the list to only include words or vocabularies whose names contain a substring." -$nl -"Consult " { $link "tools.profiler.counting" } " for details about the profiler itself." ; - -TIP: "Press " { $operation com-profile } " to run the code in the input field with profiling enabled (" { $link "ui.tools.profiler" } ")." ; - -ABOUT: "ui.tools.profiler" diff --git a/basis/ui/tools/profiler/profiler-tests.factor b/basis/ui/tools/profiler/profiler-tests.factor deleted file mode 100644 index c1c8fdbff9..0000000000 --- a/basis/ui/tools/profiler/profiler-tests.factor +++ /dev/null @@ -1,3 +0,0 @@ -USING: ui.tools.profiler tools.test ; - - diff --git a/basis/ui/tools/profiler/profiler.factor b/basis/ui/tools/profiler/profiler.factor deleted file mode 100644 index 24060da958..0000000000 --- a/basis/ui/tools/profiler/profiler.factor +++ /dev/null @@ -1,215 +0,0 @@ -! Copyright (C) 2007, 2009 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays assocs combinators.short-circuit -combinators.smart definitions.icons fry kernel locals -math.order models models.search models.sort present see -sequences tools.profiler.counting ui.baseline-alignment ui.commands -ui.gadgets ui.gadgets.borders ui.gadgets.buttons -ui.gadgets.labeled ui.gadgets.labels ui.gadgets.packs -ui.gadgets.search-tables ui.gadgets.status-bar -ui.gadgets.tabbed ui.gadgets.tables ui.gadgets.tracks -ui.gestures ui.images ui.operations ui.tools.browser -ui.tools.common vocabs words ; -FROM: models.arrow => ; -FROM: models.arrow.smart => ; -FROM: models.product => ; -IN: ui.tools.profiler - -TUPLE: profiler-gadget < tool -sort -vocabs vocab -words -methods -generic class ; - -SINGLETONS: word-renderer vocab-renderer ; -UNION: profiler-renderer word-renderer vocab-renderer ; - -array ; inline - -PRIVATE> - -! Value is a { word count } pair -M: profiler-renderer row-columns - drop - [ - [ - [ [ definition-icon ] [ present ] bi ] - [ present ] - bi* - ] with-datastack* - ] [ { "" "All" "" } ] if* ; - -M: profiler-renderer prototype-row - drop \ = definition-icon "" "" 3array ; - -M: profiler-renderer row-value - drop dup [ first ] when ; - -M: profiler-renderer column-alignment drop { 0 0 1 } ; -M: profiler-renderer filled-column drop 1 ; - -M: word-renderer column-titles drop { "" "Word" "Count" } ; -M: vocab-renderer column-titles drop { "" "Vocabulary" "Count" } ; - -SINGLETON: method-renderer - -M: method-renderer column-alignment drop { 0 0 1 } ; -M: method-renderer filled-column drop 1 ; - -! Value is a { method count } pair -M: method-renderer row-columns - drop [ - [ [ definition-icon ] [ synopsis ] bi ] - [ present ] - bi* - ] with-datastack* ; - -M: method-renderer row-value drop first ; - -M: method-renderer column-titles drop { "" "Method" "Count" } ; - -: ( values profiler -- model ) - [ [ filter-counts ] ] [ sort>> ] bi* ; - -: ( profiler -- model ) - [ - [ words>> ] [ vocab>> ] bi - [ - [ - [ first vocabulary>> ] - [ vocab-name ] - bi* = - ] when* - ] - ] keep ; - -: ( model renderer -- table ) - [ dup [ first present ] when ] - [ invoke-primary-operation ] >>action ; - -: ( counts profiler -- model' ) - [ ] dip [ f prefix ] ; - -: ( profiler -- model ) - [ vocab-counters [ [ lookup-vocab ] dip ] assoc-map ] dip - ; - -: ( profiler -- model ) - [ generic-counters ] dip ; - -: ( profiler -- model ) - [ class-counters ] dip ; - -: method-matches? ( method generic class -- ? ) - [ first ] 2dip - { - [ drop dup [ subwords member-eq? ] [ 2drop t ] if ] - [ nip dup [ swap "method-class" word-prop = ] [ 2drop t ] if ] - } 3&& ; - -: ( profiler -- model ) - [ - [ method-counters ] dip - [ generic>> ] [ class>> ] bi - [ '[ _ _ method-matches? ] filter ] - ] keep ; - -: sort-by-name ( obj1 obj2 -- <=> ) - [ first name>> ] compare ; - -: sort-by-call-count ( obj1 obj2 -- <=> ) - [ second ] compare invert-comparison ; - -: sort-options ( -- alist ) - { - { [ sort-by-name ] "by name" } - { [ sort-by-call-count ] "by call count" } - } ; - -: ( model -- gadget ) - - +baseline+ >>align - { 5 5 } >>gap - "Sort by:"