Fossil SCM

Created a memory tracking subsystem to investigate memory consumption of the system in general, and pass InitCsets in particular. getmemory series is a postprocessor pulling the data out of the log and into a tables gnuplot is able to handle.

aku 2008-02-16 06:43 trunk
Commit 8287044ecd9ff29efd42fd698da4c60be67f9e71
--- a/tools/cvs2fossil/getmemoryseries.tcl
+++ b/tools/cvs2fossil/getmemoryseries.tcl
@@ -0,0 +1,58 @@
1
+#!/bin/bash
2
+# -*- tcl -*- \
3
+exec tclsh "$0" ${1+"$@"}
4
+
5
+package require csv
6
+foreach outmarker plot outbasicold} $argv break
7
+
8
+set in [open $in r]
9
+set ba [open $outbasic w]
10
+set mr [open $outmarker w]
11
+
12
+puts $ba "\# Time Memory MaxMemory"
13
+puts $mr "\# Time Memory"
14
+
15
+set k 0
16
+while {![eof $in]} {
17
+ gets $in line
18
+ puts -nonewline \r[incr k]
19
+
20
+ if {[string match *|=|* $line]} {
21
+ # Basic series
22
+ regexp {^(.*)|=r series
23
+ regexp {^(.*)\|@\|} $lin _ _ _ mba} $line break
24
+ puts $ _ mba} $line break
25
+ puts $ba [join [list $x $cba $mba] \t]
26
+ continue
27
+ }
28
+
29
+ if {[string|@r series
30
+ regexp {^(.*)\|@\|} $line -> line
31
+ foreach {x _ cba} $line break
32
+ puts $mr [join [list $x $cba] \t]
33
+ continue
34
+ }
35
+}
36
+
37
+puts ""
38
+close $in
39
+close $ba
40
+close $mr
41
+
42
+# Generate gnuplot control file for the series
43
+set f [open $plot w]
44
+puts $f ""
45
+puts $f "plot \"$outbasic\" using 1:2 title 'Memory' with steps, \\"
46
+puts $f " \"$outbasic\" using 1:3 title 'Max Memory' with steps"
47
+puts $f "pause -1"
48
+puts $f ""
49
+close $f
50
+exit
51
+
52
+# Comparison to baseline
53
+plot "basic.dat" using 1:2 title 'Memory Base' with steps lt rgb "blue", \
54
+ "newbasic.dat" using 1:2 title 'Memory Current' with steps lt rgb "red", \
55
+
56
+# Comparison to baseline via normalization - need math op (div)
57
+plot "basic.dat" using 1:2 title 'Memory Base' with steps lt rgb "blue", \
58
+ "newbasic.dat" using 1:
--- a/tools/cvs2fossil/getmemoryseries.tcl
+++ b/tools/cvs2fossil/getmemoryseries.tcl
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/tools/cvs2fossil/getmemoryseries.tcl
+++ b/tools/cvs2fossil/getmemoryseries.tcl
@@ -0,0 +1,58 @@
1 #!/bin/bash
2 # -*- tcl -*- \
3 exec tclsh "$0" ${1+"$@"}
4
5 package require csv
6 foreach outmarker plot outbasicold} $argv break
7
8 set in [open $in r]
9 set ba [open $outbasic w]
10 set mr [open $outmarker w]
11
12 puts $ba "\# Time Memory MaxMemory"
13 puts $mr "\# Time Memory"
14
15 set k 0
16 while {![eof $in]} {
17 gets $in line
18 puts -nonewline \r[incr k]
19
20 if {[string match *|=|* $line]} {
21 # Basic series
22 regexp {^(.*)|=r series
23 regexp {^(.*)\|@\|} $lin _ _ _ mba} $line break
24 puts $ _ mba} $line break
25 puts $ba [join [list $x $cba $mba] \t]
26 continue
27 }
28
29 if {[string|@r series
30 regexp {^(.*)\|@\|} $line -> line
31 foreach {x _ cba} $line break
32 puts $mr [join [list $x $cba] \t]
33 continue
34 }
35 }
36
37 puts ""
38 close $in
39 close $ba
40 close $mr
41
42 # Generate gnuplot control file for the series
43 set f [open $plot w]
44 puts $f ""
45 puts $f "plot \"$outbasic\" using 1:2 title 'Memory' with steps, \\"
46 puts $f " \"$outbasic\" using 1:3 title 'Max Memory' with steps"
47 puts $f "pause -1"
48 puts $f ""
49 close $f
50 exit
51
52 # Comparison to baseline
53 plot "basic.dat" using 1:2 title 'Memory Base' with steps lt rgb "blue", \
54 "newbasic.dat" using 1:2 title 'Memory Current' with steps lt rgb "red", \
55
56 # Comparison to baseline via normalization - need math op (div)
57 plot "basic.dat" using 1:2 title 'Memory Base' with steps lt rgb "blue", \
58 "newbasic.dat" using 1:
--- a/tools/cvs2fossil/lib/mem.tcl
+++ b/tools/cvs2fossil/lib/mem.tcl
@@ -0,0 +1,74 @@
1
+## -*- tcl -*-
2
+# # ## ### ##### ######## ############# #####################
3
+## Copyright (c) 2008 Andreas Kupries.
4
+#
5
+# This software is licensed as described in the file LICENSE, which
6
+# you should have received as part of this distribution.
7
+#
8
+# This software consists of voluntary contributions made by many
9
+# individuals. For exact contribution history, see the revision
10
+# history and logs, available at http://fossil-scm.hwaci.com/fossil
11
+# # ## ### ##### ######## ############# #####################
12
+
13
+## Utilities for memory tracking
14
+
15
+# # ## ### ##### ######## ############# #####################
16
+## Requirements
17
+
18
+package require Tcl 8.4 ; # Required runtime
19
+package require struct::list ; # List assignment
20
+
21
+# # ## ### ##### ######## ############# #####################
22
+##
23
+
24
+namespace eval ::vc::tools::mem {
25
+ # # ## ### ##### ######## #############
26
+ ## Public API, Methods
27
+
28
+ if {[llength [info commands memory]]} {
29
+ proc minfo {} {
30
+ # memory info reduced to the set of relevant numbers in the output
31
+ struct::list assign [split [memory info] \n] tm tf cpa cba mpa mba
32
+ struct::list assign $tm _ _ tm
33
+ struct::list assign $tf _ _ tf
34
+ struct::list assign $cpa _ _ _ cpa
35
+ struct::list assign $cba _ _ _ cba
36
+ struct::list assign $mpa _ _ _ mpa
37
+ struct::list assign $mba _ _ _ mba
38
+ return [list $tm $tf $cpa $cba $mpa $mba]
39
+ }
40
+ } else {
41
+ proc minfo {} {return {0 0 0 0 0 0}}
42
+ }
43
+
44
+ proc mlog {} {
45
+ variable track ; if {!$track} { return {} }
46
+
47
+ variable lcba
48
+ variable lmba
49
+ variable mid
50
+
51
+ struct::list assign [minfo] _ _ _ cba _ mba
52
+
53
+ set dc [expr $c ba - $lcba] ; set
54
+
55
+ # projection: 1 2 3 4 5 6 7 6 8 10
56
+ return "[F [incr mid]] | [F $cba] | [F $dc] | [F $mba] | [F $dm] |=| "
57
+ }
58
+
59
+ proc mark {} {
60
+ variable track ; if {!$track} return
61
+ variable mid
62
+ variable lcba
63
+ variable lmark
64
+ set dm [expr {$lcba - $lmark}]
65
+ puts "[F $mid] | [F $lcba] | [F $dm] | [X %] | [X %] |@| [X %]"
66
+ set lmark $lcba
67
+ return
68
+ }
69
+
70
+ proc F {n} { format %10d $n }
71
+ proc X {c} { string repeat $c 10 }
72
+
73
+ proc mlimit {} {
74
+ vari
--- a/tools/cvs2fossil/lib/mem.tcl
+++ b/tools/cvs2fossil/lib/mem.tcl
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/tools/cvs2fossil/lib/mem.tcl
+++ b/tools/cvs2fossil/lib/mem.tcl
@@ -0,0 +1,74 @@
1 ## -*- tcl -*-
2 # # ## ### ##### ######## ############# #####################
3 ## Copyright (c) 2008 Andreas Kupries.
4 #
5 # This software is licensed as described in the file LICENSE, which
6 # you should have received as part of this distribution.
7 #
8 # This software consists of voluntary contributions made by many
9 # individuals. For exact contribution history, see the revision
10 # history and logs, available at http://fossil-scm.hwaci.com/fossil
11 # # ## ### ##### ######## ############# #####################
12
13 ## Utilities for memory tracking
14
15 # # ## ### ##### ######## ############# #####################
16 ## Requirements
17
18 package require Tcl 8.4 ; # Required runtime
19 package require struct::list ; # List assignment
20
21 # # ## ### ##### ######## ############# #####################
22 ##
23
24 namespace eval ::vc::tools::mem {
25 # # ## ### ##### ######## #############
26 ## Public API, Methods
27
28 if {[llength [info commands memory]]} {
29 proc minfo {} {
30 # memory info reduced to the set of relevant numbers in the output
31 struct::list assign [split [memory info] \n] tm tf cpa cba mpa mba
32 struct::list assign $tm _ _ tm
33 struct::list assign $tf _ _ tf
34 struct::list assign $cpa _ _ _ cpa
35 struct::list assign $cba _ _ _ cba
36 struct::list assign $mpa _ _ _ mpa
37 struct::list assign $mba _ _ _ mba
38 return [list $tm $tf $cpa $cba $mpa $mba]
39 }
40 } else {
41 proc minfo {} {return {0 0 0 0 0 0}}
42 }
43
44 proc mlog {} {
45 variable track ; if {!$track} { return {} }
46
47 variable lcba
48 variable lmba
49 variable mid
50
51 struct::list assign [minfo] _ _ _ cba _ mba
52
53 set dc [expr $c ba - $lcba] ; set
54
55 # projection: 1 2 3 4 5 6 7 6 8 10
56 return "[F [incr mid]] | [F $cba] | [F $dc] | [F $mba] | [F $dm] |=| "
57 }
58
59 proc mark {} {
60 variable track ; if {!$track} return
61 variable mid
62 variable lcba
63 variable lmark
64 set dm [expr {$lcba - $lmark}]
65 puts "[F $mid] | [F $lcba] | [F $dm] | [X %] | [X %] |@| [X %]"
66 set lmark $lcba
67 return
68 }
69
70 proc F {n} { format %10d $n }
71 proc X {c} { string repeat $c 10 }
72
73 proc mlimit {} {
74 vari
--- tools/cvs2fossil/lib/pkgIndex.tcl
+++ tools/cvs2fossil/lib/pkgIndex.tcl
@@ -39,6 +39,7 @@
3939
package ifneeded vc::rcs::parser 1.0 [list source [file join $dir rcsparser.tcl]]
4040
package ifneeded vc::tools::dot 1.0 [list source [file join $dir dot.tcl]]
4141
package ifneeded vc::tools::id 1.0 [list source [file join $dir id.tcl]]
4242
package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]]
4343
package ifneeded vc::tools::misc 1.0 [list source [file join $dir misc.tcl]]
44
+package ifneeded vc::tools::mem 1.0 [list source [file join $dir mem.tcl]]
4445
package ifneeded vc::tools::trouble 1.0 [list source [file join $dir trouble.tcl]]
4546
--- tools/cvs2fossil/lib/pkgIndex.tcl
+++ tools/cvs2fossil/lib/pkgIndex.tcl
@@ -39,6 +39,7 @@
39 package ifneeded vc::rcs::parser 1.0 [list source [file join $dir rcsparser.tcl]]
40 package ifneeded vc::tools::dot 1.0 [list source [file join $dir dot.tcl]]
41 package ifneeded vc::tools::id 1.0 [list source [file join $dir id.tcl]]
42 package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]]
43 package ifneeded vc::tools::misc 1.0 [list source [file join $dir misc.tcl]]
 
44 package ifneeded vc::tools::trouble 1.0 [list source [file join $dir trouble.tcl]]
45
--- tools/cvs2fossil/lib/pkgIndex.tcl
+++ tools/cvs2fossil/lib/pkgIndex.tcl
@@ -39,6 +39,7 @@
39 package ifneeded vc::rcs::parser 1.0 [list source [file join $dir rcsparser.tcl]]
40 package ifneeded vc::tools::dot 1.0 [list source [file join $dir dot.tcl]]
41 package ifneeded vc::tools::id 1.0 [list source [file join $dir id.tcl]]
42 package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]]
43 package ifneeded vc::tools::misc 1.0 [list source [file join $dir misc.tcl]]
44 package ifneeded vc::tools::mem 1.0 [list source [file join $dir mem.tcl]]
45 package ifneeded vc::tools::trouble 1.0 [list source [file join $dir trouble.tcl]]
46

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button