Mark Martinec
unread,Aug 29, 2013, 7:50:34 PM8/29/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to redi...@googlegroups.com
Using redis 2.8 from git, having four Lua routines with 200 lines of Lua code
altogether, fairly straightforward code with some but not much dynamic
memory usage (no cyclic structures as far as I can tell), taking about
a millisecond for each EVALSHA call, single redis instance with no slaves,
used for processing mail, one call to each routine about every few seconds.
Noticed today that the INFO command reports almost 4 MB of memory
used for Lua (and about 180 MB for everything else) after running the
application for a few days - which seemed like excessive amount of Lua
memory, considering that near the application start the Lua memory
usage reported is about 50 kB.
The real surprise came when I collected and plotted Lua memory usage
with an independently running shell command, repeated about every
second:
while true; do
redis-cli eval 'return collectgarbage("count") * 1024' 0;
sleep 1
done
Will attach the graph, hope it makes it to the mailing list, otherwise
I'll post a link. The diagram shows Lua memory usage on the y axis,
with samples taken approx every second of elapsed time (the x axis).
The plot (blue dots) is just incredibly unbelievable: the Lua memory
(above some initial offset) keeps doubling in discrete steps, each step
takes about twice the elapsed time of the previous one - see the diagram
and it will become obvious what I'm saying.
The random excursions above each baseline segment show that
the Lua automatic garbage collector works just fine, trimming the
memory usage back to about its current baseline every now an then,
frequently enough. It is the large steps in a baseline that are most weird.
To rule out any potential artifacts of a Lua automatic garbage
collector, I repeated the experiment (red dots), restarting redis-server
and the application, but this time the application calls collectgarbage()
after every mail message being processed. As expected the random
memory excursions are now trimmed very frequently, so the weird
baseline steps are now even more obvious.
The funny thing is that steps take place near seconds ?, ?, 250, 500,
1000, 2000, 4000, 8000. (I attribute the small skew to the shell
while ... sleep loop, although I may be wrong). There is nothing
time-related in the application that could explain this, as far as I
can tell. Interestingly the red dots seem to have slightly longer
time period.
Any ideas for an explanation???
(btw, I haven't tried it with 2.6)
Mark