[collectd] [PATCH] Random write timeout for rrdtool plugin

Florian Forster octo at verplant.org
Tue Aug 18 08:52:09 CEST 2009

Hi Mariusz,

On Mon, Aug 17, 2009 at 02:20:29AM +0200, Mariusz Gronczewski wrote:
> i was thinking how to "spread out" writes to rrd files a bit, because
> now its big spike every CacheTimeout or little smaller "square" on
> graph if u use WritesPerSecond.

in general I like your patch, thank you very much for posting it :)
I have some doubts about calling rand() in such a busy place though,
since getting random numbers is potentially costly. Also, rand(3) is not
thread-safe, though I don't think that's really an issue for us.

Maybe a solution would be to add a ‘random_timeout’ member to the
‘rrd_cache_t’ struct, too. This member is then set when creating the
entry and set again right after the values have been removed. That way
rand(3) is only called once for each write instead of calling for every

As an interesting sidenote: With the above approach, the random write
times are distributed “uniform”, i. e. every delay from 0 to max-1
seconds has the same probability. With your code, I think the actual
time a value is written follows a “normal” distribution (you know, that
famous bell curve). So I'd expect the above approach to spread the value

Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20090818/dd39b585/attachment.pgp 

More information about the collectd mailing list