Skip to content

Commit

Permalink
spinlocks never seem to help in benchmarks
Browse files Browse the repository at this point in the history
If a thread is allowed to go to sleep, it can be woken up early as soon as the
lock is freed. If we spinlock, the scheduler can't help us and threads will
randomly run out their timeslice until the thread actually holding the lock
finishes its work.

In my benchmarks killing the spinlock only makes things better.
  • Loading branch information
dormando committed Jan 10, 2015
1 parent 87ff9dc commit 0aa1a82
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions memcached.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,12 +540,7 @@ enum store_item_type do_store_item(item *item, int comm, conn* c, const uint32_t
conn *conn_new(const int sfd, const enum conn_states init_state, const int event_flags, const int read_buffer_size, enum network_transport transport, struct event_base *base);
extern int daemonize(int nochdir, int noclose);

static inline int mutex_lock(pthread_mutex_t *mutex)
{
while (pthread_mutex_trylock(mutex));
return 0;
}

#define mutex_lock(x) pthread_mutex_lock(x)
#define mutex_unlock(x) pthread_mutex_unlock(x)

#include "stats.h"
Expand Down

0 comments on commit 0aa1a82

Please sign in to comment.