Split the threadpool in two: a small one for CPU-bound workloads and a large one for I/O-bound workloads. The CPU threadpool has approximately as many threads as there are CPUs in the machine. The I/O threadpool can have hundreds of threads, which is okay because they should mostly be blocked in system calls. I/O threads run on a reduced stack (32 kB) to avoid using up too much virtual address space on 32 bits architectures.
Make changes to the process title visible to tools like `ps`. The argv clobber technique is reasonably portable across Unices; the common code has been moved into src/unix/proctitle.c and is used on Linux and OS X. Other platforms will probably follow in the future.
Don't add the io watcher to the watcher queue if the requested change is effectively a no-op, that is, when the event mask doesn't change. The exception here is sunos because the event ports backend requires that watched file descriptors are re-added on every turn of the event loop. This commit is a micro-optimization, it does not change the event loop's observable behavior in any way.
Before this commit, it was assumed that connect() on UNIX sockets never returns EINPROGRESS. It turned out to be a bad assumption: Dave Pacheco reports sporadic hangups on SmartOS because of that. It's not clear to me _why_ the Illumos kernel returns that error but that's inconsequential: whatever the cause, libuv needs to handle it and now it does. Fixes joyent/node#4785.
Don't check the return value of epoll_ctl(EPOLL_CTL_DEL). When the file descriptor is closed, we're potentially racing with another thread and that means the errno is not a reliable indicator of the actual error. The other event mechanisms (kqueue, event ports) are not affected because: * kqueue returns either EBADF or ENOENT. Both are handled by libuv. * event ports rearms all file descriptors on each call to port_getn(). Fixes joyent/node#4558.
This reduces the line count.
In the src/*/timer.c code the first argument is called handle, not timer. We should be consistent in the interface definition file.
Compare start_id of timer handles when they have the same timeout. start_id is allocated with loop->timer_counter in uv_timer_start.
Using mach_absolute_time() for the pthread_cond_timedwait() timeout breaks a number of tests on OS X 10.8.2. This reverts commit 8311390.