Re: [Nagios-devel] Optimize status.cgi

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Optimize status.cgi

Post by Guest »


--Apple-Mail-51-488884878
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit

Hi Jonathan,

On 23 Dec 2009, at 02:26, Jonathan Kamens wrote:

> It adds the following optimizations to the code base:
> 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.
> 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.
> Defer the sorting of the comment and scheduled downtime linked lists
> until they've all been read from status.dat. This makes a huge
> 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.
> 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.

Just to let you know that (3) is now committed.

There's a test script which creates different numbers of comments/
downtimes and it shows that the code changes are indeed an order of
magnitude faster. Thanks again for the patch!

I've blogged about it here: http://opsview-blog.opsera.com/dotorg/2 ... -cgis.html

Ton


--Apple-Mail-51-488884878
Content-Type: text/html;
charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

Hi =
Jonathan,On 23 Dec 2009, at 02:26, Jonathan Kamens =
wrote: It adds the following optimizations to the code =
base: 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. 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. Defer the =
sorting of the comment and scheduled downtime linked lists until they've =
all been read from status.dat.  This makes a huge =
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. =
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.Just to let you know =
that (3) is now committed.There's a test =
script which creates different

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked