Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: vdavydov.dev@gmail.com
Subject: [PATCH v2 4/4] Allow to configure TX fiber pool size
Date: Mon, 23 Apr 2018 20:05:04 +0300	[thread overview]
Message-ID: <cf69dbb936b8d238c5c57950f2783b03a9c013bc.1524502856.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1524502856.git.v.shpilevoy@tarantool.org>
In-Reply-To: <cover.1524502856.git.v.shpilevoy@tarantool.org>

TX fiber pool size provides fibers to execute transactions and
remote requests, so it is linked with maximal remote request
count, that is allowed to be altered in the previous patch. Lets
do the same for fiber pool size.

Follow up #3320
---
 src/box/box.cc                  |  9 ++++++++-
 src/box/lua/load_cfg.lua        |  2 ++
 src/fiber_pool.h                |  6 +++++-
 test/box/fat_tx.lua             | 30 ++++++++++++++++++++++++++++
 test/box/request_limit.result   | 43 +++++++++++++++++++++++++++++++++++++++++
 test/box/request_limit.test.lua | 15 ++++++++++++++
 6 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 test/box/fat_tx.lua

diff --git a/src/box/box.cc b/src/box/box.cc
index 80684ad48..d2552709a 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1716,8 +1716,15 @@ box_is_configured(void)
 static inline void
 box_cfg_xc(void)
 {
+	int fiber_pool_size =
+		cfg_geti_default("fiber_pool_size", FIBER_POOL_SIZE_DEFAULT);
+	if (fiber_pool_size < FIBER_POOL_SIZE_MIN) {
+		tnt_raise(ClientError, ER_CFG, "fiber_pool_size",
+			  tt_sprintf("minimal value is %d",
+				     FIBER_POOL_SIZE_MIN));
+	}
 	/* Join the cord interconnect as "tx" endpoint. */
-	fiber_pool_create(&tx_fiber_pool, "tx", FIBER_POOL_SIZE,
+	fiber_pool_create(&tx_fiber_pool, "tx", fiber_pool_size,
 			  FIBER_POOL_IDLE_TIMEOUT);
 	/* Add an extra endpoint for WAL wake up/rollback messages. */
 	cbus_endpoint_create(&tx_prio_endpoint, "tx_prio", tx_prio_cb, &tx_prio_endpoint);
diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua
index 6ed30e016..b8af58450 100644
--- a/src/box/lua/load_cfg.lua
+++ b/src/box/lua/load_cfg.lua
@@ -64,6 +64,7 @@ local default_cfg = {
     feedback_host         = "https://feedback.tarantool.io",
     feedback_interval     = 3600,
     iproto_msg_max        = 768,
+    fiber_pool_size       = 4096,
 }
 
 -- types of available options
@@ -125,6 +126,7 @@ local template_cfg = {
     feedback_host         = 'string',
     feedback_interval     = 'number',
     iproto_msg_max        = 'number',
+    fiber_pool_size       = 'number',
 }
 
 local function normalize_uri(port)
diff --git a/src/fiber_pool.h b/src/fiber_pool.h
index d6a95105b..9f99da5ea 100644
--- a/src/fiber_pool.h
+++ b/src/fiber_pool.h
@@ -41,7 +41,11 @@
 extern "C" {
 #endif /* defined(__cplusplus) */
 
-enum { FIBER_POOL_SIZE = 4096, FIBER_POOL_IDLE_TIMEOUT = 1 };
+enum {
+	FIBER_POOL_SIZE_DEFAULT = 4096,
+	FIBER_POOL_SIZE_MIN = 100,
+	FIBER_POOL_IDLE_TIMEOUT = 1
+};
 
 /**
  * A pool of worker fibers to handle messages,
diff --git a/test/box/fat_tx.lua b/test/box/fat_tx.lua
new file mode 100644
index 000000000..6ef5c8f96
--- /dev/null
+++ b/test/box/fat_tx.lua
@@ -0,0 +1,30 @@
+#!/usr/bin/env tarantool
+os = require('os')
+
+box.cfg{
+    listen = os.getenv("LISTEN"),
+    pid_file = "tarantool.pid",
+    fiber_pool_size = 5000,
+    iproto_msg_max = 5000
+}
+
+require('console').listen(os.getenv('ADMIN'))
+net_box = require('net.box')
+fiber = require('fiber')
+
+box.schema.user.grant('guest', 'read,write,execute', 'universe')
+conn = net_box.connect(box.cfg.listen)
+net_box = require('net.box')
+active = 0
+continue = false
+function do_long_f()
+	active = active + 1
+	while not continue do
+		fiber.sleep(0.1)
+	end
+	active = active - 1
+end
+
+function do_long(c)
+	c:call('do_long_f')
+end
diff --git a/test/box/request_limit.result b/test/box/request_limit.result
index 8f722b1b9..068ba3766 100644
--- a/test/box/request_limit.result
+++ b/test/box/request_limit.result
@@ -270,6 +270,49 @@ conn2:close()
 conn:close()
 ---
 ...
+--
+-- Test that new fiber pool limit can be reached.
+--
+test_run:cmd('create server fat_tx with script = "box/fat_tx.lua"')
+---
+- true
+...
+test_run:cmd("start server fat_tx")
+---
+- true
+...
+test_run:cmd('switch fat_tx')
+---
+- true
+...
+box.cfg.fiber_pool_size
+---
+- 5000
+...
+for i = 1, 5000 do fiber.create(do_long, conn) end
+---
+...
+while active ~= 5000 do fiber.sleep(0.01) end
+---
+...
+continue = true
+---
+...
+while active ~= 0 do fiber.sleep(0.01) end
+---
+...
+test_run:cmd("switch default")
+---
+- true
+...
+test_run:cmd("stop server fat_tx")
+---
+- true
+...
+test_run:cmd("cleanup server fat_tx")
+---
+- true
+...
 box.schema.user.revoke('guest', 'read,write,execute', 'universe')
 ---
 ...
diff --git a/test/box/request_limit.test.lua b/test/box/request_limit.test.lua
index 286df0455..f02d0dcdd 100644
--- a/test/box/request_limit.test.lua
+++ b/test/box/request_limit.test.lua
@@ -136,5 +136,20 @@ wait_finished(run_max * 2)
 conn2:close()
 conn:close()
 
+--
+-- Test that new fiber pool limit can be reached.
+--
+test_run:cmd('create server fat_tx with script = "box/fat_tx.lua"')
+test_run:cmd("start server fat_tx")
+test_run:cmd('switch fat_tx')
+box.cfg.fiber_pool_size
+for i = 1, 5000 do fiber.create(do_long, conn) end
+while active ~= 5000 do fiber.sleep(0.01) end
+continue = true
+while active ~= 0 do fiber.sleep(0.01) end
+test_run:cmd("switch default")
+test_run:cmd("stop server fat_tx")
+test_run:cmd("cleanup server fat_tx")
+
 box.schema.user.revoke('guest', 'read,write,execute', 'universe')
 box.cfg{readahead = old_readahead, iproto_msg_max = limit}
-- 
2.15.1 (Apple Git-101)

  parent reply	other threads:[~2018-04-23 17:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 17:05 [PATCH v2 0/4] IProto fixes and iproto_msg_max option Vladislav Shpilevoy
2018-04-23 17:05 ` [PATCH v2 1/4] iproto: fix error with input discarding Vladislav Shpilevoy
2018-04-24 15:35   ` Vladimir Davydov
2018-04-23 17:05 ` [PATCH v2 2/4] iproto: fix error with unstoppable batching Vladislav Shpilevoy
2018-04-24 15:36   ` Vladimir Davydov
2018-04-23 17:05 ` [PATCH v2 3/4] iproto: allow to configure IPROTO_MSG_MAX Vladislav Shpilevoy
2018-04-23 17:05 ` Vladislav Shpilevoy [this message]
2018-04-24 15:43   ` [PATCH v2 4/4] Allow to configure TX fiber pool size Vladimir Davydov
2018-04-24 17:33     ` [tarantool-patches] " Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cf69dbb936b8d238c5c57950f2783b03a9c013bc.1524502856.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH v2 4/4] Allow to configure TX fiber pool size' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox