in reply to Re: Thread very slow
in thread Thread very slow

Thanks. Your advice with Data::Dumper helped me a lot. Your code version was not the final solution because the thread was still slow. But it helped me to find the solution. Now the thread is running fast.

Here the code of the main task:

$Data::Dumper::Varname = "gen_data_str"; $gen_data_str1 = Dumper($ref_gen_data); $q->enqueue( $gen_data_str1 ); $q->enqueue( undef );

Here the code within the worker thread:

my %gen_data; while( my $gen_data_str1 = $q->dequeue ) { %gen_data = %{ eval $gen_data_str1 }; };

Replies are listed 'Best First'.
Re^3: Thread very slow
by Corion (Patriarch) on Jul 12, 2010 at 13:26 UTC

    I think there must be still something going wrong with your serialization, as Thread::Queue basically does what you do, except it's using the (slightly faster in most cases) Storable::nstore to serialize the data for the queue.

    As you haven't shown the code where you construct %gen_data and the values you construct them from, it's hard to guess. If you can construct an example without Tk that exhibits the behaviour, that would be convenient. If you can post (a small excerpt of) how you populate %gen_data, that might also lead to more clue as to what really goes wrong.