Skip to content
Snippets Groups Projects
Commit 19f67667 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Analyze perf output and address two hotspots.

This patch gives up to 200 000 extra rps in wal_mode=none on
my laptop (1 450 000 vs. 1 250 000, nosqlbench 10x1000 batch workload)
parent d0961b56
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,6 @@
#include "schema.h"
#include "user_def.h"
#include "engine.h"
#include "space.h"
#include "memtx_index.h"
#include "func.h"
#include "tuple.h"
......
......@@ -69,6 +69,7 @@ enum {
#include "error.h"
#include <stdio.h> /* snprintf */
#include "space.h"
extern uint32_t sc_version;
......@@ -94,9 +95,16 @@ space_name_by_id(uint32_t id);
static inline struct space *
space_cache_find(uint32_t id)
{
struct space *space = space_by_id(id);
if (space)
static uint32_t scv = 0;
static struct space *space = NULL;
if (scv != sc_version)
space = NULL;
if (space && space->def.id == id)
return space;
if ((space = space_by_id(id))) {
scv = sc_version;
return space;
}
tnt_raise(ClientError, ER_NO_SUCH_SPACE, int2str(id));
}
......
......@@ -50,6 +50,8 @@ fiber_pool_f(va_list ap)
{
struct fiber_pool *pool = va_arg(ap, struct fiber_pool *);
struct stailq *output = va_arg(ap, struct stailq *);
struct ev_loop *loop = va_arg(ap, struct ev_loop *);
struct ev_async *watcher = va_arg(ap, struct ev_async *);
pool->size++;
bool was_empty;
restart:
......@@ -59,7 +61,13 @@ fiber_pool_f(va_list ap)
while (! stailq_empty(output))
cmsg_deliver(stailq_shift_entry(output, struct cmsg, fifo));
/* fiber_yield_timeout() is expensive, avoid under load. */
fiber_sleep(0);
if (ev_is_pending(watcher)) {
struct cpipe *pipe = (struct cpipe *) watcher->data;
(void) cpipe_peek(pipe);
ev_clear_pending(loop, watcher);
} else {
fiber_reschedule();
}
}
/** Put the current fiber into a fiber cache. */
......@@ -75,7 +83,6 @@ fiber_pool_f(va_list ap)
static void
fiber_pool_cb(ev_loop *loop, struct ev_async *watcher, int events)
{
(void) loop;
(void) events;
struct cpipe *pipe = (struct cpipe *) watcher->data;
struct fiber_pool *pool = &pipe->pool;
......@@ -92,7 +99,7 @@ fiber_pool_cb(ev_loop *loop, struct ev_async *watcher, int events)
error_log(diag_last_error(&fiber()->diag));
break;
}
fiber_start(f, pool, &pipe->output);
fiber_start(f, pool, &pipe->output, loop, watcher);
} else {
/**
* No worries that this watcher may not
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment