[Tarantool-patches] [PATCH v3 01/10] fiber: use uint64_t for fiber IDs
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Mon May 10 21:40:19 MSK 2021
Hi! Thanks for the patch!
See 5 comments below.
> diff --git a/changelogs/unreleased/gh-5846-cformat.md b/changelogs/unreleased/gh-5846-cformat.md
> new file mode 100644
> index 000000000..027de35d7
> --- /dev/null
> +++ b/changelogs/unreleased/gh-5846-cformat.md
> @@ -0,0 +1,12 @@
> +## bugfix/core
> + * Fixed wrong type specificator when printing fiber state
> + change which lead to negative fiber's ID logging.
> +
> + For exmaple
1. exmaple -> example.
> + ```
> + main/-244760339/cartridge.failover.task I> Instance state changed
> + ```
> + instead of proper
> + ```
> + main/4050206957/cartridge.failover.task I> Instance state changed
> + ```
2. You need to give a link to the issue here in a form 'gh-####'.
> diff --git a/changelogs/unreleased/gh-5846-fiber-id.md b/changelogs/unreleased/gh-5846-fiber-id.md
> new file mode 100644
> index 000000000..b645da849
> --- /dev/null
> +++ b/changelogs/unreleased/gh-5846-fiber-id.md
> @@ -0,0 +1,4 @@
> +## feature/core
> + * Fiber IDs are switched to monotonically increasing unsigned 8 byte
> + integers so that there won't be IDs wrapping anymore. This allows
> + to detect fiber's precedence by their IDs if needed.
3. This is a bugfix, not a feature. Please, keep it in the bugfix changelog
file.
> diff --git a/src/lib/core/say.c b/src/lib/core/say.c
> index cbd10e107..5307767b5 100644
> --- a/src/lib/core/say.c
> +++ b/src/lib/core/say.c
> @@ -792,8 +792,9 @@ say_format_plain_tail(char *buf, int len, int level, const char *filename,
> if (cord) {
> SNPRINT(total, snprintf, buf, len, " %s", cord->name);
> if (fiber() && fiber()->fid != FIBER_ID_SCHED) {
> - SNPRINT(total, snprintf, buf, len, "/%i/%s",
> - fiber()->fid, fiber_name(fiber()));
> + SNPRINT(total, snprintf, buf, len, "/%lld/%s",
4. This is llu, not lld, is it? Because FID is uint64_t. I see you
even use llu in the other places for FID.
Lets be consistent. Either you use int64_t fid and lld in the
formats, or you use uint64_t and llu in the formats.
> diff --git a/src/lua/fiber.c b/src/lua/fiber.c
> index 02ec3d158..c792bf385 100644
> --- a/src/lua/fiber.c
> +++ b/src/lua/fiber.c
> @@ -155,11 +155,11 @@ lbox_pushfiber(struct lua_State *L, int fid)
> static struct fiber *
> lbox_checkfiber(struct lua_State *L, int index)
> {
> - uint32_t fid;
> + uint64_t fid;
> if (lua_type(L, index) == LUA_TNUMBER) {
> - fid = lua_tonumber(L, index);
> + fid = luaL_touint64(L, index);
> } else {
> - fid = *(uint32_t *) luaL_checkudata(L, index, fiberlib_name);
> + fid = *(uint64_t *) luaL_checkudata(L, index, fiberlib_name);
5. Please, drop the whitespace after the type cast alongside. The same in
the block below.
> }
> struct fiber *f = fiber_find(fid);
> if (f == NULL)
> @@ -170,12 +170,12 @@ lbox_checkfiber(struct lua_State *L, int index)
> static int
> lbox_fiber_id(struct lua_State *L)
> {
> - uint32_t fid;
> + uint64_t fid;
> if (lua_gettop(L) == 0)
> fid = fiber()->fid;
> else
> - fid = *(uint32_t *) luaL_checkudata(L, 1, fiberlib_name);
> - lua_pushinteger(L, fid);
> + fid = *(uint64_t *) luaL_checkudata(L, 1, fiberlib_name);
> + luaL_pushuint64(L, fid);
> return 1;
> }
More information about the Tarantool-patches
mailing list