<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Jonathan,<div><br></div><div>Just to let you know that I'll look into this soon. I have had reports that lots of downtime causes a CGI slowdown, and it looks like you've nailed where it is. Did you use any particular tools to identify this?</div><div><br></div><div>I'll probably get (3) added in first and defer (1) and (2) for later versions.</div><div><br></div><div>BTW, it will be useful to have multiple patches, so can apply them one at a time, rather than a single large patch.</div><div><br></div><div>Ton</div><div><br><div><div>On 23 Dec 2009, at 02:26, Jonathan Kamens wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"> <div bgcolor="#ffffff" text="#000000"> With nagios 3.2.0 at my site, it took over a minute from when I entered a host name in the Web UI's "Quick Search:" box and hit Enter, until when the status details for the host were actually displayed.<br> <br> The attached patch reduces the time to do exactly the same work to under five seconds.<br> <br> It adds the following optimizations to the code base:<br> <ol>  <li>When iterating through the lines in the status.dat file, use a persistent buffer to read lines rather than freeing and reallocating a new buffer for every line.  This reduces fragmentation of the malloc pool and reduces the amount of time spent in malloc() and free().  This is implemented by adding a new function, mmap_fgets_buf(), which is like mmap_fgets() except it takes an optional buffer to reuse if possible.  I added this to both cgiutils.c and utils.c so that it can be used elsewhere in the code.</li>  <li>When parsing the status.dat file, reduce the number of unnecessary calls to strcmp() by keeping track of when we know we're in a block and not checking for block-start sequences unnecessarily.</li>  <li>Defer the sorting of the comment and scheduled downtime linked lists until they've all been read from status.dat.  This makes a <b><i>huge</i></b> difference in performance -- it dwarfs by orders of magnitude the optimizations listed above.  The way this is implemented is invisible to programs aside from status.cgi that call add_comment() or add_downtime(), but those programs can easily be modified to take advantage of the new functionality if they need to be sped up.</li> </ol> I sincerely hope that the maintainers of Nagios will make an effort to include these changes in the next release.  They represent a dramatic improvement in the performance and usability of the Web UI.<br> <br> Thanks,<br> <br> Jonathan Kamens<br></div></blockquote></div><br></div></body></html>