[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

faster pthread_getspecific



Hi, Drepper,

I wonder if it is possible to speed up the pthread_getspecific().
Some application requires extreme fast pthread_getspecific().
Just an example, Sun JVM makes 1 million calls to it during
startup code. I know it sounds insane, but it is reality.

Here is my quick proposal. Please take a look and see if it fits.

/*
 * the first level 2 table is inlined into thread block.
 */
void *
__pthread_getspecific (key)
     pthread_key_t key;
{
  if (key < PTHREAD_KEY_2NDLEVEL_SIZE) {
    struct pthread_key_data * entry
      = THREAD_GETMEM_NC (THREAD_SELF, fast_specific[key]);
    if (entry->seq == __pthread_keys[key].seq) {
      return entry->data;
    } else {
      /* cleanup work here */
      return NULL;
    }
  }
  key -= PTHREAD_KEY_2NDLEVEL_SIZE;
  /* the existing code */
  ...
}

Hong





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]