[erlang-questions] Help with storing data in memory

Bob Ippolito bob@REDACTED
Tue Mar 23 11:27:25 CET 2010


Why ets and not a gen_server with a queue (or queue-like) data
structure? Sending big enough binaries around should be cheap since
it's by reference.

On Tue, Mar 23, 2010 at 5:27 AM, Max Lapshin <max.lapshin@REDACTED> wrote:
> 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
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list