Help with storing data in memory
Max Lapshin
max.lapshin@REDACTED
Tue Mar 23 10:27:07 CET 2010
Erlyvideo has got a timeshift feature. It means, that last 10 minutes
of videostream are stored in stream_media gen_server.
When client want to seek back in live stream, it starts to read from
timeshift buffer just like from plain file.
43000 frames take about 1,5MB in ets table. They are stored as tuples
with float timestamp as a key.
Once in 5 seconds message clean_timeshift is received by stream_media
and it deletes all expired frames from this ets table.
When deletion doesn't work, erlyvideo takes about 10% CPU per several
clients. When I turn it on, it raises to 17%CPU.
I don't know what to do. When I works the same feature on ObjectiveC,
there was a ring buffer in memory, but Erlang isn't suitable for
such structures.
Currently I have an idea to keep two ets tables: when first entry from
first table comes to timeshift limit, I add second table and begin
to track from which table to take frames. When first entry from second
table comes to timeshift limit, I drop first table.
So I eliminate ets:select_delete call
More information about the erlang-questions
mailing list