From c3b502b43242b86f591b13702af962ed0bb907b6 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Wed, 24 Sep 2014 19:59:07 +0400 Subject: [PATCH] Sneak in a feature urgently needed for sberlabs. Add a replacement for show palloc in 1.5, which I simply removed with small allocator. --- src/box/lua/slab.cc | 29 ++++++++++++++++++++++++++++- test/box/misc.result | 9 +++++++++ test/box/misc.test.lua | 2 ++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/box/lua/slab.cc b/src/box/lua/slab.cc index 4095ce312e..d0abaaf44a 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 651ae9f1b7..b2397d2a88 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 dd7c2ddb98..10edd169c8 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 -- GitLab