From: Jorge <jo...@jorgechamorro.com>
Date: Tue, 3 Jul 2012 18:50:18 +0200
Local: Tues, Jul 3 2012 12:50 pm
Subject: Re: [v8-users] V8 and pthreads
I've been playing with threads and V8 too: <https://github.com/xk/node-threads-a-gogo> :-P
Cheers,
On 02/07/2012, at 13:46, mschwartz wrote:
> I was toying with pthreads and V8 and it all pretty much works as I expected.
> The repo is here:
> It's a pretty small amount of code, so all the v8 API calls used are not so obfuscated.
> The test program, test.js is:
> var NUM_THREADS = 1000;
> var pthread = builtin.pthread;
> log(pthread);
> function Thread(fn) {
> function thread(n) {
> function tester(i, n) {
> function main() {
> while (true) {
> A couple of things to note:
> First, there is no actual "wait for any thread to exit" kind of functionality in pthreads. I implemented my own using doubly linked lists and pthread_cond_signal(). pthread_t may be radically different on various operating systems, so I implemented my own threadId scheme, similar to PIDs.
> When I spawn 1000 threads, they don't seem to get equal treatment by the scheduler. Sample output of the test.js program:
> As you can see, the first 600 or so threads seem to get equal processor time, while the remaining ones seem really starved for processor time. I'm not sure if this is due to the OSX pthread scheduler algorithm (I tried all 3 variants, not much difference) or something about how v8::Locker works.
> Anyhow, I hope the code is of interest to someone.
> -- You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||