Branch: Tag:

2010-11-13

2010-11-13 23:19:15 by Jonas Walldén <jonasw@roxen.com>

Disallow threads during hashing of small strings (current threshold is 1 MB).
This change improves ApacheBench numbers ~20% for a Roxen benchmark on a
quad-core Core i5.

127:    if(!ctx)    SIMPLE_OUT_OF_MEMORY_ERROR("hash", meta->context_size);    +  /* Only thread this block for significant data size */ +  if (in->len > THREADS_ALLOW_THRESHOLD) {    THREADS_ALLOW();    meta->init(ctx);    meta->update(ctx, in->len, (const uint8_t *)in->str);    THREADS_DISALLOW(); -  +  } else { +  meta->init(ctx); +  meta->update(ctx, in->len, (const uint8_t *)in->str); +  }       digest_length = meta->digest_size;    out = begin_shared_string(digest_length);
284:    Pike_error("HashState not properly initialized.\n");       NO_WIDE_STRING(data); +  +  /* Only thread this block for significant data size */ +  if (data->len > THREADS_ALLOW_THRESHOLD) {    THREADS_ALLOW();    meta->update(ctx, data->len, (const uint8_t *)data->str);    THREADS_DISALLOW(); -  +  } else { +  meta->update(ctx, data->len, (const uint8_t *)data->str); +  }       push_object(this_object());    }