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

Merge remote-tracking branch 'origin/master' into 1.6

Conflicts:
	src/box/iproto.cc
parents dc6f56fb 9f92caf4
No related branches found
No related tags found
No related merge requests found
...@@ -116,7 +116,7 @@ struct IprotoMsgGuard { ...@@ -116,7 +116,7 @@ struct IprotoMsgGuard {
{ struct iproto_msg *tmp = msg; msg = NULL; return tmp; } { struct iproto_msg *tmp = msg; msg = NULL; return tmp; }
}; };
enum { IPROTO_FIBER_POOL_SIZE = 1024 }; enum { IPROTO_FIBER_POOL_SIZE = 1024, IPROTO_FIBER_POOL_IDLE_TIMEOUT = 3 };
/* }}} */ /* }}} */
...@@ -838,7 +838,8 @@ iproto_init() ...@@ -838,7 +838,8 @@ iproto_init()
static struct cpipe_fiber_pool fiber_pool; static struct cpipe_fiber_pool fiber_pool;
cpipe_fiber_pool_create(&fiber_pool, "iproto", &tx_pipe, cpipe_fiber_pool_create(&fiber_pool, "iproto", &tx_pipe,
IPROTO_FIBER_POOL_SIZE); IPROTO_FIBER_POOL_SIZE,
IPROTO_FIBER_POOL_IDLE_TIMEOUT);
static struct cord net_cord; static struct cord net_cord;
if (cord_costart(&net_cord, "iproto", net_cord_f, NULL)) if (cord_costart(&net_cord, "iproto", net_cord_f, NULL))
......
...@@ -257,9 +257,13 @@ cpipe_fiber_pool_f(va_list ap) ...@@ -257,9 +257,13 @@ cpipe_fiber_pool_f(va_list ap)
rlist_add_entry(&pool->fiber_cache, fiber(), state); rlist_add_entry(&pool->fiber_cache, fiber(), state);
pool->size--; pool->size--;
pool->cache_size++; pool->cache_size++;
fiber_yield(); bool timed_out = fiber_yield_timeout(pool->idle_timeout);
pool->cache_size--; pool->cache_size--;
pool->size++; pool->size++;
if (timed_out) {
/** Nothing to do for quite a while */
return;
}
goto restart; goto restart;
} }
} }
...@@ -296,7 +300,7 @@ cpipe_fiber_pool_cb(ev_loop * /* loop */, struct ev_async *watcher, ...@@ -296,7 +300,7 @@ cpipe_fiber_pool_cb(ev_loop * /* loop */, struct ev_async *watcher,
void void
cpipe_fiber_pool_create(struct cpipe_fiber_pool *pool, cpipe_fiber_pool_create(struct cpipe_fiber_pool *pool,
const char *name, struct cpipe *pipe, const char *name, struct cpipe *pipe,
int max_pool_size) int max_pool_size, float idle_timeout)
{ {
rlist_create(&pool->fiber_cache); rlist_create(&pool->fiber_cache);
pool->name = name; pool->name = name;
...@@ -304,5 +308,6 @@ cpipe_fiber_pool_create(struct cpipe_fiber_pool *pool, ...@@ -304,5 +308,6 @@ cpipe_fiber_pool_create(struct cpipe_fiber_pool *pool,
pool->size = 0; pool->size = 0;
pool->cache_size = 0; pool->cache_size = 0;
pool->max_size = max_pool_size; pool->max_size = max_pool_size;
pool->idle_timeout = idle_timeout;
cpipe_set_fetch_cb(pipe, cpipe_fiber_pool_cb, pool); cpipe_set_fetch_cb(pipe, cpipe_fiber_pool_cb, pool);
} }
...@@ -457,6 +457,11 @@ struct cpipe_fiber_pool { ...@@ -457,6 +457,11 @@ struct cpipe_fiber_pool {
int cache_size; int cache_size;
/** The limit on the number of fibers working on tasks. */ /** The limit on the number of fibers working on tasks. */
int max_size; int max_size;
/**
* Fibers in leave the pool if they have nothing to do
* for longer than this.
*/
float idle_timeout;
struct cpipe *pipe; struct cpipe *pipe;
}; };
...@@ -467,6 +472,6 @@ struct cpipe_fiber_pool { ...@@ -467,6 +472,6 @@ struct cpipe_fiber_pool {
void void
cpipe_fiber_pool_create(struct cpipe_fiber_pool *pool, cpipe_fiber_pool_create(struct cpipe_fiber_pool *pool,
const char *name, struct cpipe *pipe, const char *name, struct cpipe *pipe,
int max_pool_size); int max_pool_size, float idle_timeout);
#endif /* TARANTOOL_CBUS_H_INCLUDED */ #endif /* TARANTOOL_CBUS_H_INCLUDED */
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