1999Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD&#45;Dev] code profiling -->
<!--X-From-R13: Quevf Uenl <ptNnzv&#45;pt.UenlEntr.Sqzbagba.OP.QO> -->
<!--X-Date: Mon, 8 Feb 1999 22:00:33 &#45;0800 -->
<!--X-Message-Id: 199902090559.WAA01232@ami&#45;cg.GraySage.Edmonton.AB.CA -->
<!--X-Content-Type: text/plain -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] code profiling</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00370.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00372.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00375.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00373.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00371">Author</A>
&nbsp;|&nbsp;<A HREF="#00371">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00371">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] code profiling</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: [MUD-Dev] code profiling</LI>
<LI><em>From</em>: Chris Gray &lt;<A HREF="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</A>&gt;</LI>
<LI><em>Date</em>: Mon, 8 Feb 1999 22:59:19 -0700</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
Since there has been recent discussion here of finding performance
problems and code profiling, I thought I'd briefly relate my experience
with this from the last half hour.

When I left my server over the weekend, I had been messing around with
some changes to my database. As part of that I had implemented some
data structure consistency checking, which I had forgotten I'd left
enabled. Well, of course the performance was quite poor. So, in testing
the performance effects of some changes, I was quite disappointed in
the result. Tonight I turned those changes off, and performance was still
terrible - much moreso that what I remembered. What was wrong? Profiling
to the rescue. I deleted my object files and re-compiled (using gcc)
with '-pg' enabled. Run my server for a couple of seconds, then shut it
down (there are 150 or so "machines" in my testbed database right now).

Run "gprof MUDServ | more", and the culprit (the consistency checker
routine" was blindingly obvious - it was using 95% of the time. So,
turn it off. Try again - much better! The top few lines now are:

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 26.75      0.65     0.65   736529     0.00     0.00  ioRead
 22.63      1.20     0.55   636842     0.00     0.00  runExec
  7.41      1.38     0.18     8890     0.02     0.02  ioCacheFree
  4.94      1.50     0.12    11579     0.01     0.01  sendToMachines
  4.94      1.62     0.12    10029     0.01     0.01  ForEachAgent
  2.88      1.69     0.07  3498226     0.00     0.00  trace
....

'ioRead' fetches things from the database. Unexpectedly high - I'll
have to have a good look at it. 'runExec' is the main body of my
MUD-language interpreter; I expect that to be quite high. 'ioCacheFree'
is also in the DB cache - when a block is freed, that routine trys to
merge it with other free ones - could be expensive when I'm pounding
on the DB (3/4 million reads in 2.5 seconds). 'sendToMachines' and
'ForEachAgent' are used to tell characters (PC and NPC) about things
happening in the same location as them. Not unexpected when 150 NPC's
are moving at about 2-second intervals. I need better searching.

So, as you can see, a simple run using compiler profiling can tell
you an awful lot about where to look for performance improvements. The
amount of work is minimal. Fixing the problems is a lot harder!

--
Don't design inefficiency in - it'll happen in the implementation. - me

Chris Gray     cg#ami-cg,GraySage.Edmonton.AB.CA
               <A  HREF="http://www.GraySage.Edmonton.AB.CA/cg/">http://www.GraySage.Edmonton.AB.CA/cg/</A>


</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<ul compact><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><A NAME="00373" HREF="msg00373.html">[MUD-Dev] optimizing code</A></strong>
<ul compact><li><em>From:</em> &lt;diablo#best,com&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00370.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00372.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00375.html">[MUD-Dev] Re: optimizing code</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00373.html">[MUD-Dev] optimizing code</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00371"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00371"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><STRONG>[MUD-Dev] Re: pet peeves</STRONG>, <EM>(continued)</EM>
<ul compact>
<ul compact>
<LI><strong><A NAME="00381" HREF="msg00381.html">[MUD-Dev] Re: pet peeves</A></strong>, 
Richard Woolcock <a href="mailto:KaVir#dial,pipex.com">KaVir#dial,pipex.com</a>, Thu 11 Feb 1999, 23:02 GMT
</LI>
</ul>
</ul>
</LI>
<LI><strong><A NAME="00376" HREF="msg00376.html">[MUD-Dev] World-file parsing and RTTI?</A></strong>, 
The Arrow <a href="mailto:arrow#trelleborg,mail.telia.com">arrow#trelleborg,mail.telia.com</a>, Wed 10 Feb 1999, 18:45 GMT
<UL>
<LI><strong><A NAME="00377" HREF="msg00377.html">[MUD-Dev] Re: World-file parsing and RTTI?</A></strong>, 
Mark Gritter <a href="mailto:mark#erdos,Stanford.EDU">mark#erdos,Stanford.EDU</a>, Wed 10 Feb 1999, 22:55 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00375" HREF="msg00375.html">[MUD-Dev] Re: optimizing code</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Wed 10 Feb 1999, 02:41 GMT
<LI><strong><A NAME="00371" HREF="msg00371.html">[MUD-Dev] code profiling</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Tue 09 Feb 1999, 06:00 GMT
<UL>
<LI><strong><A NAME="00373" HREF="msg00373.html">[MUD-Dev] optimizing code</A></strong>, 
diablo <a href="mailto:diablo#best,com">diablo#best,com</a>, Tue 09 Feb 1999, 06:31 GMT
<UL>
<LI><strong><A NAME="00374" HREF="msg00374.html">[MUD-Dev] Re: optimizing code</A></strong>, 
Hans-Henrik Staerfeldt <a href="mailto:hhs#cbs,dtu.dk">hhs#cbs,dtu.dk</a>, Tue 09 Feb 1999, 14:58 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
<LI><strong><A NAME="00366" HREF="msg00366.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Tue 09 Feb 1999, 03:31 GMT
<UL>
<LI><strong><A NAME="00369" HREF="msg00369.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>, 
Adam J. Thornton <a href="mailto:adam#phoenix,Princeton.EDU">adam#phoenix,Princeton.EDU</a>, Tue 09 Feb 1999, 04:34 GMT
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>