Forum OpenACS Q&A: Re: carnage blender is live on aolserver 4 beta5

Collapse
Posted by Jonathan Ellis on
No, they didn't. I ran an experiment and it turns out having up to a million mutex handles around didn't cause problems. This program runs about instantaneously:
#include <pthread.h>
#include <stdio.h>

pthread_mutex_t a[1000000];

void main(int argc, char **argv)
{
    int i;
    for (i = 0; i < 1000000; i++) {
        pthread_mutex_init(a + i, NULL);
    }

    printf("Done creating\n");


    for (i = 0; i < 1000000; i++) {
        pthread_mutex_destroy(a + i);
    }
}
ns_mutex is just a thin wrapper around pthread_mutex calls. So I figured having around the measly 10k mutexes I use on my site won't cause me any problems and just stopped destroying unused ones. So perhaps a politically acceptable fix for the nsd guys might be to just not provide mutex destroy anymore.