Re: Problems while switching C stacks (fibers)

  • From: Mike Pall <mike-1309@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 8 Sep 2013 14:45:37 +0200

Konstantin Olkhovskiy wrote:
> But we have no clear understanding of how to organize shared state between
> lua fibers. In previous concept it was just a set of global tables.

Well, before going that route, please remember this: shared memory
is just an optimization.

It all depends on your usage patterns and what kind of shared
state you actually need: maybe a global pool of aggregates that
can be accessed in arbitrary ways will do? Or maybe it's better to
formalize it with message queues? Or maybe an in-memory database
is the best option?

I guess you need to make your mind up about the inter-thread
communication patterns first. Then decide on the most suitable
communication mechanism and only then decide on an implementation.

Please consider that all of the options I mentioned actually use
shared memory for their highest-performing implementations. The
choice of the communication mechanism has as much of an influence
on performance as the communication patterns.

This is even more important for preemptive threading or IPC, where
you need to deal with contention and communication latencies. That
might not be what you currently need -- but maybe you'll want it
in the future? So choose wisely.

--Mike

Other related posts: