On Mon, Sep 08, 2003 at 05:34:51PM +0200, Elizabeth Mattijsen wrote: > At 14:47 +0100 9/8/03, Dave Mitchell wrote: > >On Mon, Sep 08, 2003 at 03:06:32PM +0200, Elizabeth Mattijsen wrote: > >> I'm only interested (probably my tunnel vision ;-) in saving memory, > >> as that means saving memory multiple times over when using threads, > > > plus making threads faster on startup. > >Note that Config.sh declares the vars holding the big strings as 'unique', > >so they don't get copied when new threads are created. > > Running a simple test with Benchmark::Thread::Size confirms this. > However, it is not nearly as much as you would hope it would save ;-( > > Performing each test 10 times > (ref) 10 100 > normal 10 100 > unique 10 100 > # (ref) normal unique > 0 2187 ± 2 +20 +20 > 1 2610 ±16 +37 ± 4 +30 ±14 > 2 2944 ±18 +62 ±18 +41 ±18 > 5 3912 ±18 +122 ±22 +71 ±20 > 10 5534 ±18 +221 ±26 +125 ±28 > 20 8774 ±30 +424 ±34 +236 ±30 > 50 18493 ±32 +1045 ±50 +540 ±66 > 100 34689 ±32 +2069 ±70 +1063 ±74 > > ==== normal ====================================================== > our $var = 'abcdefghij' x 1000; > > ==== unique ====================================================== > our $var : unique = 'abcdefghij' x 1000; > > ================================================================== That's because the SV target for the 'x' operator, which holds a (notionally) temporary copy of the 1000 byte string, is still cloned for each interpreter. -- Any [programming] language that doesn't occasionally surprise the novice will pay for it by continually surprising the expert. - Larry WallThread Previous | Thread Next