Changes between Version 10 and Version 11 of ArrayTasklist

Show
Ignore:
Timestamp:
10/13/09 17:06:37 (5 years ago)
Author:
kurahaupo
Comment:

notes on thread safety, exponential resizing

Legend:

Unmodified
Added
Removed
Modified
  • ArrayTasklist

    v10 v11  
    5959(I think the current explosion of Array types was an attempt to optimize that has failed; do we have benchmarks showing that any particular array is faster/more compact/??? than another for a particular usage? Personally, I'd like to see a unification of array types, not a further segmentation --coke) 
    6060 
     61= Thread Safety = 
     62 
     63Any object that can change its representation is a potential pit-fall for thread-safe programming. 
     64 
     65This includes reallocating memory to expand the size of an array. To do this safely means ''every'' operation on the array has to be gated through a mutex, which clearly will be ''very'' expensive. 
     66 
     67Fixed sized arrays, on the other hand, need no such gating, because the location and manner of storing each element is fixed. 
     68 
     69With some care it is even possible to support resizable arrays with a fixed allocation bound, ''provided'' that one only uses push, pop, unshift, shift and truncate (assign length zero) to change the logical size of the array. It's also a bit simpler (and fast) if only one thread performs shift & unshift, and one other (or possibly the same) thread performs push, pop and truncate. 
     70 
    6171= Tasks = 
    6272 
     
    6575 * Update all ResizableArrays to perform initialization of unset elements, in particular those that re-appear when an array is shrunk and then re-extended. Assuming of course no HLL's would suffer significantly from this "pessimization". 
    6676 * Array types should grow by powers of two (or multiples of system page size for large arrays) for improved allocation performance 
     77   * (they already do -- kurahaupo) 
    6778 * Deprecate and remove Array PMC type. 
    6879