Hello all,
Attached is a patch to the CollectD::Graph::Common library used by graph.cgi,
part of the Collection3 perl scripts shipped with CollectD under contrib/.
At present graph.cgi extremely slowly on servers with large numbers of RRD
files. This is because it issues an unnecessary stat() call to _every_ RRD
file on the local system before loading and rendering graph data.
I've chased this behaviour down to the function get_files_by_ident() in
CollectD::Graph::Common -- which even has some faster, more specific code
commented out that doesn't work -- presumably because the internal
data-structures it used evolved in an incompatible way.
I've uncommented it out, and applied a trivial fixup so that it matches the
internal data-structures used internally.
On my system, which has on the order of 100,000 individual RRD files, this
patch speeds graph rendering (in the hot-cache case) from 6s to just ~0.25s, a
24x speedup.
Cheers,
David
--
David McBride <[email protected]>
Department of Computing, Imperial College, London
--- Common.pm.old 2011-05-16 11:55:55.060395340 +0100
+++ Common.pm 2011-05-16 11:55:24.469559055 +0100
@@ -391,14 +391,14 @@
my @ret = ();
my $data_dir = gc_get_scalar ('DataDir', $DefaultDataDir);
- #if ($ident->{'hostname'})
- #{
- #$all_files = get_files_for_host ($ident->{'hostname'});
- #}
- #else
- #{
+ if ($ident->{'hostname'})
+ {
+ $all_files = get_files_for_host ($ident->{'hostname'}[0]);
+ }
+ else
+ {
$all_files = get_files_from_directory ($data_dir, 3);
- #}
+ }
@ret = grep { _filter_ident ($ident, $_) == 0 } (@$all_files);
_______________________________________________
collectd mailing list
[email protected]
http://mailman.verplant.org/listinfo/collectd