Overview
SHA1 Hash: | 8287044ecd9ff29efd42fd698da4c60be67f9e71 |
---|---|
Date: | 2008-02-16 06:43:54 |
User: | aku |
Comment: | 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. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Added tools/cvs2fossil/getmemoryseries.tcl version [d3a2537d7a]
@@ -1,1 +1,60 @@ +#!/bin/bash +# -*- tcl -*- \ +exec tclsh "$0" ${1+"$@"} + +package require csv +foreach {in outbasic outmarker plot} $argv break + +set in [open $in r] +set ba [open $outbasic w] +set mr [open $outmarker w] + +puts $ba "\# Time Memory MaxMemory" +puts $mr "\# Time Memory" + +set k 0 +while {![eof $in]} { + gets $in line + puts -nonewline \r[incr k] + + if {[string match *|=|* $line]} { + # Basic series + regexp {^(.*)|=|} $line -> line + foreach {x _ cba _ _ _ mba} $line break + puts $ba [join [list $x $cba $mba] \t] + continue + } + + if {[string match *|@|* $line]} { + # Marker series + regexp {^(.*)|@|} $line -> line + foreach {x _ cba} $line break + puts $mr [join [list $x $cba] \t] + continue + } +} + +puts "" +close $in +close $ba +close $mr + +# Generate gnuplot control file for the series +set f [open $plot w] +puts $f "" +puts $f "plot \"$outbasic\" using 1:2 title 'Memory' with steps, \\" +puts $f " \"$outbasic\" using 1:3 title 'Max Memory' with steps" +puts $f "pause -1" +puts $f "" +close $f +exit + +# Comparison to baseline +plot "basic.dat" using 1:2 title 'Memory Base' with steps lt rgb "blue", \ + "newbasic.dat" using 1:2 title 'Memory Current' with steps lt rgb "red", \ + +# Comparison to baseline via normalization - need math op (div) +plot "basic.dat" using 1:2 title 'Memory Base' with steps lt rgb "blue", \ + "newbasic.dat" using 1:2 title 'Memory Current' with steps lt rgb "red", \ +
Added tools/cvs2fossil/lib/mem.tcl version [124db2afe9]
@@ -1,1 +1,139 @@ +## -*- tcl -*- +# # ## ### ##### ######## ############# ##################### +## Copyright (c) 2008 Andreas Kupries. +# +# This software is licensed as described in the file LICENSE, which +# you should have received as part of this distribution. +# +# This software consists of voluntary contributions made by many +# individuals. For exact contribution history, see the revision +# history and logs, available at http://fossil-scm.hwaci.com/fossil +# # ## ### ##### ######## ############# ##################### + +## Utilities for memory tracking + +# # ## ### ##### ######## ############# ##################### +## Requirements + +package require Tcl 8.4 ; # Required runtime +package require struct::list ; # List assignment + +# # ## ### ##### ######## ############# ##################### +## + +namespace eval ::vc::tools::mem { + # # ## ### ##### ######## ############# + ## Public API, Methods + + if {[llength [info commands memory]]} { + proc minfo {} { + # memory info reduced to the set of relevant numbers in the output + struct::list assign [split [memory info] \n] tm tf cpa cba mpa mba + struct::list assign $tm _ _ tm + struct::list assign $tf _ _ tf + struct::list assign $cpa _ _ _ cpa + struct::list assign $cba _ _ _ cba + struct::list assign $mpa _ _ _ mpa + struct::list assign $mba _ _ _ mba + return [list $tm $tf $cpa $cba $mpa $mba] + } + } else { + proc minfo {} {return {0 0 0 0 0 0}} + } + + proc mlog {} { + variable track ; if {!$track} { return {} } + + variable lcba + variable lmba + variable mid + + struct::list assign [minfo] _ _ _ cba _ mba + + set dc [expr $cba - $lcba] ; set lcba $cba + set dm [expr $mba - $lmba] ; set lmba $mba + + # projection: 1 2 3 4 5 6 7 6 8 10 + return "[F [incr mid]] | [F $cba] | [F $dc] | [F $mba] | [F $dm] |=| " + } + + proc mark {} { + variable track ; if {!$track} return + variable mid + variable lcba + variable lmark + set dm [expr {$lcba - $lmark}] + puts "[F $mid] | [F $lcba] | [F $dm] | [X %] | [X %] |@| [X %]" + set lmark $lcba + return + } + + proc F {n} { format %10d $n } + proc X {c} { string repeat $c 10 } + + proc mlimit {} { + variable track ; if {!$track} return ; # No checks if there is no memory tracking + variable limit ; if {!$limit} return ; # No checks if there is no memory limit set + + struct::list assign [minfo] _ _ _ cba _ _ + + # Nothing to do if we are still under the limit + if {$cba <= $limit} return + + # Notify user and kill the importer + puts "" + puts "\tMemory limit breached: $cba > $limit" + puts "" + exit 1 + } + + proc setlimit {thelimit} { + # Activate memory tracking, and set the limit. The specified + # limit is taken relative to the amount of memory allocated at + # the time of the call. + + variable limit + struct::list assign [minfo] _ _ _ cba _ _ + set limit [expr $cba + $thelimit] + + track + return + } + + proc notrack {} { + variable track 0 + return + } + + proc track {} { + variable track 1 + return + } + + # # ## ### ##### ######## ############# + + variable track 0 ; # Boolean flag. If set this module will track + # memory, inserting the relevant information + # whenever the application logs something. + variable limit 0 ; # The maximum amount of memory allowed to the + # application. This module will abort when + # 'current bytes allocated' goes over this + # value. + + variable lcba 0 ; # Last 'current bytes allocated' (cba) + variable lmba 0 ; # Last 'maximum bytes allocated' (mba) + variable mid 0 ; # Memory id, abstract time + variable lmark 0 ; # + + # # ## ### ##### ######## ############# +} + +namespace eval ::vc::tools::mem { + namespace export minfo mlog track notrack mlimit setlimit mark +} + +# ----------------------------------------------------------------------------- +# Ready +package provide vc::tools::mem 1.0 +return
Modified tools/cvs2fossil/lib/pkgIndex.tcl from [8e64440f57] to [73c4287bf5].
@@ -39,6 +39,7 @@ package ifneeded vc::rcs::parser 1.0 [list source [file join $dir rcsparser.tcl]] package ifneeded vc::tools::dot 1.0 [list source [file join $dir dot.tcl]] package ifneeded vc::tools::id 1.0 [list source [file join $dir id.tcl]] package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]] package ifneeded vc::tools::misc 1.0 [list source [file join $dir misc.tcl]] +package ifneeded vc::tools::mem 1.0 [list source [file join $dir mem.tcl]] package ifneeded vc::tools::trouble 1.0 [list source [file join $dir trouble.tcl]]