diff --git a/src/box/lua/slab.cc b/src/box/lua/slab.cc index 4095ce312e2907288854a0ab631e5c57e7a53f9b..d0abaaf44a33a15a068deb6e3bf0b9f0c632fd9b 100644 --- a/src/box/lua/slab.cc +++ b/src/box/lua/slab.cc @@ -37,6 +37,7 @@ extern "C" { #include "box/tuple.h" #include "small/small.h" +#include "memory.h" /** A callback passed into salloc_stat() and invoked for every slab class. */ extern "C" { @@ -119,6 +120,22 @@ lbox_slab_info(struct lua_State *L) return 1; } +static int +lbox_runtime_info(struct lua_State *L) +{ + lua_newtable(L); + + lua_pushstring(L, "used"); + luaL_pushnumber64(L, runtime.used); + lua_settable(L, -3); + + lua_pushstring(L, "maxalloc"); + luaL_pushnumber64(L, runtime.maxalloc); + lua_settable(L, -3); + + return 1; +} + static int lbox_slab_check(struct lua_State *L __attribute__((unused))) { @@ -142,6 +159,16 @@ box_lua_slab_init(struct lua_State *L) lua_pushcfunction(L, lbox_slab_check); lua_settable(L, -3); + lua_settable(L, -3); /* box.slab */ + + lua_pushstring(L, "runtime"); + lua_newtable(L); + + lua_pushstring(L, "info"); + lua_pushcfunction(L, lbox_runtime_info); lua_settable(L, -3); - lua_pop(L, 1); + + lua_settable(L, -3); /* box.runtime */ + + lua_pop(L, 1); /* box. */ } diff --git a/test/box/misc.result b/test/box/misc.result index 651ae9f1b75a0d42dc9afe54cf5d2b4b269b7687..b2397d2a88830c8510156437ed4eaf6ebc307ca9 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -24,6 +24,7 @@ t - info - internal - rollback + - runtime - schema - session - slab @@ -154,6 +155,14 @@ t; - arena_size - slabs ... +box.runtime.info().used > 0; +--- +- true +... +box.runtime.info().maxalloc > 0; +--- +- true +... -- -- gh-502: box.slab.info() excessively sparse array -- diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua index dd7c2ddb984a11ca9c3b678882f026014d7aef23..10edd169c8516ee26cee0b29bcb0373a693787ef 100644 --- a/test/box/misc.test.lua +++ b/test/box/misc.test.lua @@ -61,6 +61,8 @@ for k, v in pairs(box.slab.info()) do table.insert(t, k) end; t; +box.runtime.info().used > 0; +box.runtime.info().maxalloc > 0; -- -- gh-502: box.slab.info() excessively sparse array