On Fri, Aug 13, 2010 at 6:16 AM, Domas Mituzas <[email protected]> wrote: >> Without having looked at any code, can't the threads just add data to >> a semaphore linked list (fast), and a single separate thread writes >> the stuff to disk occasionally? > > Isn't that the usual error that threaded software developers do: > > 1. get all threads depend on single mutex > 2. watch them fight! (you'd get a million wakeups here a second :-)
But adding to a linked list (essentially, changing a pointer) is about the cheapest operation there is... > as a bonus point you get a need to copy data to a separate buffer or frenzy > memory allocating with another mutex for malloc/free ;-) Disk dump thread: * Get mutex for list start pointer * Copy list start pointer * Reset list start pointer = NULL * Release mutex * Write list to disk * Release memory If you allocate memory per list item, the freed ones should nicely fit the next ones, so malloc would not be too slow, I imagine (just use char[] of fixed size). Just curious: is the "million wakeups" an actual number, or a figure of speech? How many views/sec are there? Cheers, Magnus _______________________________________________ Wikitech-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l
