This is because they copy every data structure except the ones you mark as shared
Only if the data structures exist before the threads are spawned. So don't do that. Spawn your threads before you load or create your large data structures. It ain't rocket science.
And, as has been mentioned before, most forked perl processes do not benefit from COW much either:
And that's just a few of the apparently read-only operations that will cause COW to trigger. Doing anything non-readonly, like adding or deleting an element to a hash or array and you induce wholesale copying. Increment or decrement a variable. Modify it 'in-place' with s/// or tr or substr.
In reply to Re^2: Perl Threads and multi-core CPUs
by BrowserUk
in thread Perl Threads and multi-core CPUs
by haidut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |