As promised, below is slightly cleaner version (still needs more work) that ties in some of the information from "ns_info threads". Hopefully this will help a little.

PS - Doesn't work on IE... ;-)

- n

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>AOLserver Memory Pools</title>
<style type="text/css" media="screen,print">
html,body {
margin:0;
padding:10px;
color:#000;
background:#fff;
}
body {

font:140% Verdana , Arial, Helvetica, sans-serif;
}
.equal {
display:table;
border-collapse:separate;
margin:1px auto;
border-spacing:1px;
background:#cccccc;
width:100%;
}
.row {
display:table-row;
}
.row div {
background:#fff;
display:table-cell;
}
.row div.title {
margin:0 0 0 0;
padding:2px;
color:#fff;
background:#999999;
text-align:right;
}
.row div.data {
margin:0 0 0 0;
padding:2px;
text-align:right;
}
.row div.total {
margin:0 0 0 0;
padding:2px;
background:#ffffcc;
text-align:right;
}
</style>
</head>
<body>

<%
set ns_thread(0) "NS_OK"
set ns_thread(-1) "NS_ERROR"
set ns_thread(-2) "NS_TIMEOUT"
set ns_thread(200) "NS_THREAD_MAXTLS"
set ns_thread(1) "NS_THREAD_DETACHED"
set ns_thread(2) "NS_THREAD_JOINED"
set ns_thread(4) "NS_THREAD_EXITED"
set ns_thread(32) "NS_THREAD_NAMESIZE"

foreach thread [ns_info threads] {
set threads(thread[lindex $thread 2]) $thread
}

set talloc 0
set trequest 0
set tused 0
set tlocks 0
set twaits 0
set tfree 0
set tops 0

foreach pool [lsort [ns_info pools]] {
set thread [lindex $pool 0]

ns_adp_puts "<b>
$thread</b><br>"

if {[info exists threads($thread)]} {
ns_adp_puts "\
Thread: [lindex $threads($thread) <br>
Parent: [lindex $threads($thread) <br>
Id: [lindex $threads($thread) <br>
Flags: $ns_thread([lindex $threads($thread) <br>
Proc: [lindex $threads($thread) <br>
Args: [lindex $threads($thread) <br><br>"
}

ns_adp_puts "\
<div class=\"equal\">
<div class=\"row\">
<div class=\"title\">Block Size</div>
<div class=\"title\">Frees</div>
<div class=\"title\">Gets</div>
<div class=\"title\">Puts</div>
<div class=\"title\">Bytes Req</div>
<div class=\"title\">Bytes Used</div>
<div class=\"title\">Overhead</div>
<div class=\"title\">Locks</div>
<div class=\"title\">Lock Waits</div>
</div>"

set ptf 0
set ptg 0
set ptp 0
set ptbr 0
set ptbu 0
set ptl 0
set ptlw 0

foreach b [lrange $pool 1 end] {
set bs [lindex $b 0]
set nf [lindex $b 1]
set ng [lindex $b 2]
set np [lindex $b 3]
set nr [lindex $b 4]
set nu [expr $ng - $np]
set na [expr $nu * $bs]


incr tops [expr $ng + $np]
incr tlocks [lindex $b 5]
incr twaits [lindex $b 6]
incr tfree [expr $bs * $nf]
incr talloc $na
incr trequest $nr
incr tused $nu

incr ptf $nf
incr ptg $ng
incr ptp $np
incr ptbr $nr
incr ptbu $na
incr ptl [lindex $b 5]
incr ptlw [lindex $b 6]

if {$nr != 0} {
set ov [expr $na - $nr]
set op [format %4.2f%% [expr $ov.0 * 100 / $nr.0]]
} else {
set ov "N/A"
set op "N/A"
}

ns_adp_puts "<div class=\"row\">"

foreach e [linsert [lreplace $b 4 4] 4 $nr $na $op] {
ns_adp_puts "<div class=\"data\">$e</div>"
}

ns_adp_puts "</div>"
}

if {$ptbu != 0} {
set ptov [format %4.2f%% [expr ($ptbu - $ptbr) * 100 / $ptbr.0]]
} else {
set ptov "N/A"
}

ns_adp_puts "\
<div class=\"row\">
<div class=\"total\"></div>
<div class=\"total\">$ptf</div>
<div class=\"total\">$ptg</div>
<div class=\"total\">$ptp</div>
<div class=\"total\">$ptbr</div>
<div class=\"total\">$ptbu</div>
<div class=\"total\">$ptov</div>
<div class=\"total\">$ptl</div>
<div class=\"total\">$ptlw</div>
</div>
</div>
<br>
<hr size=1 color=#cccccc>"
}

set ov [expr $talloc - $trequest]
set op [format %4.2f [expr $ov.0 * 100 / $trequest.0]]
set av [format %4.2f [expr 100.0 - ($tlocks.0 * 100) / $tops.0]]

if {$tlocks > 0} {
set wr [format %4.2f [expr $twaits.0 / $tlocks.0]]
} else {
set wr "N/A"
}

%>

<div class="equal">
<div class="row">
<div class="data">Total Bytes Requested</div>
<div class="total"><%=$trequest%></div>
</div>
<div class="row">
<div class="data">Total Bytes Free</div>
<div class="total"><%=$tfree%></div>
</div>
<div class="row">
<div class="data">Total Bytes Allocated</div>
<div class="total"><%=$talloc%></div>
</div>
<div class="row">
<div class="data">Total Bytes Wasted</div>
<div class="total"><%=$ov%></div>
</div>
<div class="row">
<div class="data">Total Byte Overhead</div>
<div class="total"><%=$op%>%</div>
</div>
<div class="row">
<div class="data">Total Mutex Locks</div>
<div class="total"><%=$tlocks%></div>
</div>
<div class="row">
<div class="data">Total Mutex Lock Waits</div>
<div class="total"><%=$twaits%></div>
</div>
<div class="row">
<div class="data">Total Gets/Puts</div>
<div class="total"><%=$tops%></div>
</div>
<div class="row">
<div class="data">Total Lock Avoidance</div>
<div class="total"><%=$av%>%</div>
</div>
</div>
</body>
</html>


On Jan 26, 2005, at 1:44 PM, Janine Sisk wrote:

On Jan 24, 2005, at 8:55 PM, Nathan Folkman wrote:

Below is a quick and dirty page you can use to print out some info
from the "Zippy" memory allocator. Not pretty, but might help you gain
some insight into what is going on. Pay close attention to the total
stats at the end of the page. By design the memory allocator is
somewhat of a memory hog (note the high overhead), however, you'll
notice the lock contention is nearly non-existent. In practice memory
is "cheap" and lock contention is to be avoided at all costs! Hope
this helps!

Thanks, Nathan!

I've run this, but I'm not sure how to interpret the output. The full
page is at

http://www.furfly.net/janine/memory-pools.html

The total stats you mentioned are:

Bytes Requested: 17754181
Bytes Free: 1980544
Bytes Allocated: 28301396
Bytes Wasted: 10547215
Byte Overhead: 59.41%
Mutex Locks: 10660
Mutex Lock Waits: 0
Lock Wait Ratio: 0.00%
Gets/Puts: 1722429
Lock Avoidance: 99.38%

The Bytes Wasted seems pretty high, but without knowing why or how they
are considered wasted it's hard to know what to think about that. Does
this suggest anything to you?

It seems like it would be useful to be able to look at Tcl's data
structures and see how much memory is allocated to NSVs, etc, but I
don't know how to do that, if it's even possible.

thanks,

janine


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.

Reply via email to