Thanks for the detailed answer!

I rewrote my test program to become tests the compressing process, but I 
got same result.
But I got the reason.
Each compressing process slice data to small chunks, and compress it in 
turn.

the order:

data0: [ 1| 5| 9|13]
data1: [ 2| 6|10|14]
data2: [ 3| 7|11|15]
data3: [ 4| 8|12|16]


So, seemed to return after all process done.
Oh in fact, them have completed at the same time really.

Thanks a lot!


2012年12月6日木曜日 12時01分09秒 UTC+9 Bert Belder:
>
> On Thursday, December 6, 2012 3:18:42 AM UTC+1, 長島徹 wrote:
>>
>> Thanks for the response.
>>
>> Can I avoid or lessen that worker threads delay the JavaScript main 
>> thread?
>> 4 CPU cores exists and HT supported.
>> (I think ... the priority of main thread set to higher, ...?)
>>
>
> The main thread can get pre-empted if you saturate all the cores in your 
> machine. (And yes, it would be possible in theory to ramp up the priority 
> of the main thread with pthread_setschedparam; you'll have to hack node or 
> create a compiled addon to do that though.)
>
> That however is not the "problem" that you are seeing here. Your seem to 
> assume that "reading and compressing a file" is executed as a single 
> operation in a thread pool thread. That's not how it works; node will first 
> read a small chunk of data in the thread pool, then compress it, then write 
> out the compressed data while reading in a new chunk of data in parallel, 
> etc. Effectively, each of your "compress-a-file" operations are broken up 
> in small chunks that are interleaved and partly run in parallel on the 
> thread pool; that's why you see them complete all at the same time.
>
> - Bert
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to