So I finally got some time to play with this and I still can't wrap my head around it.
If I understand it correctly, the trick is in the fact that you:
- load the whole DB as a memdb with shared cache
- then use the
to get this memory where the DB is loaded shared with all the threads
shared_clone( $dbh )
- and then inside the thread create a new DB handler, but thanks to the fact you're using the same memdb with shared cache, it reuses the same memory as the DB handler in the main thread
Is that even remotely correct? :-) And if so:
- Why do the shared_clone( $dbh )? Isn't the shared memdb enough for the threads to have access to the same memory? I've been trying to somehow see the difference between the two scenarios (with and without passing the shared_clone( $dbh )) and I'm probably not measuring this right, but the memory usage (vm_stat) seems to be similar in both cases.
- What's the purpose of the
? Why pass the string to the thread and then just dequeue it? And what's the relation to waiting for DB?
$Q->nq( ('Wakey wakey') x $T );
$Q->dq; ## Wait for DB