From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp14.mail.ru (smtp14.mail.ru [94.100.181.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6C54E469719 for ; Mon, 5 Oct 2020 09:39:57 +0300 (MSK) Date: Mon, 5 Oct 2020 09:39:33 +0300 From: Sergey Kaplun Message-ID: <20201005063933.GB32264@root> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH v3 2/2] misc: add C and Lua API for platform metrics List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Munkin , Sergey Ostanevich Cc: tarantool-patches@dev.tarantool.org On 20.09.20, Sergey Kaplun wrote: > This patch introduces both C and Lua API for LuaJIT platform > This patch isn't relevant. You can see actual version here [1]. You can apply -R corresponding diff to return to this version. ================================================================== diff --git a/src/lib_misc.c b/src/lib_misc.c index 287b059..ef11237 100644 --- a/src/lib_misc.c +++ b/src/lib_misc.c @@ -42,10 +42,6 @@ LJLIB_CF(misc_getmetrics) setnumfield(L, m, "gc_udatanum", metrics.gc_udatanum); setnumfield(L, m, "gc_cdatanum", metrics.gc_cdatanum); - setnumfield(L, m, "gc_whitenum", metrics.gc_whitenum); - setnumfield(L, m, "gc_graynum", metrics.gc_graynum); - setnumfield(L, m, "gc_blacknum", metrics.gc_blacknum); - setnumfield(L, m, "gc_total", metrics.gc_total); setnumfield(L, m, "gc_freed", metrics.gc_freed); setnumfield(L, m, "gc_allocated", metrics.gc_allocated); diff --git a/src/lj_mapi.c b/src/lj_mapi.c index a3fb645..7645a44 100644 --- a/src/lj_mapi.c +++ b/src/lj_mapi.c @@ -36,10 +36,6 @@ LUAMISC_API void luaM_metrics(lua_State *L, struct luam_Metrics *metrics) metrics->gc_cdatanum = 0; #endif - metrics->gc_whitenum = gc->whitenum; - metrics->gc_graynum = gc->graynum; - metrics->gc_blacknum = gc->blacknum; - metrics->gc_total = gc->total; metrics->gc_freed = gc->freed; metrics->gc_allocated = gc->allocated; diff --git a/src/lmisclib.h b/src/lmisclib.h index e4970b5..e2d1909 100644 --- a/src/lmisclib.h +++ b/src/lmisclib.h @@ -27,13 +27,6 @@ struct luam_Metrics { /* Amount of allocated cdata objects. */ size_t gc_cdatanum; - /* Amount of white objects. */ - size_t gc_whitenum; - /* Amount of gray objects. */ - size_t gc_graynum; - /* Amount of black objects. */ - size_t gc_blacknum; - /* Memory currently allocated. */ size_t gc_total; /* Total amount of freed memory. */ diff --git a/test/clib-misclib-getmetrics.test.lua b/test/clib-misclib-getmetrics.test.lua index 840840c..34adaba 100755 --- a/test/clib-misclib-getmetrics.test.lua +++ b/test/clib-misclib-getmetrics.test.lua @@ -14,26 +14,12 @@ local jit_opt_default_minstitch = 0 local tap = require('tap') local test = tap.test("clib-misc-getmetrics") -test:plan(13) +test:plan(10) local testgetmetrics = require("testgetmetrics") test:ok(testgetmetrics.base()) test:ok(testgetmetrics.gc_allocated_freed()) -test:ok(testgetmetrics.gc_colors_base()) -test:ok(testgetmetrics.gc_colors_strempty()) - --- Upvalues are never gray. -tbar_t = {} -test:ok(testgetmetrics.gc_colors_tbar(function() - local tabnew = require"table.new" - for i =1, 100 do - tbar_t.x = tabnew(i,0) - end - collectgarbage("collect") - tbar_t = nil -end)) - test:ok(testgetmetrics.gc_steps()) test:ok(testgetmetrics.objcount(function() diff --git a/test/clib-misclib-getmetrics/testgetmetrics.c b/test/clib-misclib-getmetrics/testgetmetrics.c index 85f0505..32802d2 100644 --- a/test/clib-misclib-getmetrics/testgetmetrics.c +++ b/test/clib-misclib-getmetrics/testgetmetrics.c @@ -20,10 +20,6 @@ static int base(lua_State *L) assert((ssize_t)metrics.gc_udatanum >= 0); assert((ssize_t)metrics.gc_cdatanum >= 0); - assert((ssize_t)metrics.gc_whitenum >= 0); - assert((ssize_t)metrics.gc_graynum >= 0); - assert((ssize_t)metrics.gc_blacknum >= 0); - assert((ssize_t)metrics.gc_total >= 0); assert((ssize_t)metrics.gc_freed >= 0); assert((ssize_t)metrics.gc_allocated >= 0); @@ -63,44 +59,6 @@ static int gc_allocated_freed(lua_State *L) return 1; } -static int gc_colors_base(lua_State *L) -{ - struct luam_Metrics metrics; - lua_gc(L, LUA_GCCOLLECT, 0); - luaM_metrics(L, &metrics); - /* There are no non-white objects after full gc cycle. */ - assert(metrics.gc_blacknum == 0); - assert(metrics.gc_graynum == 0); - lua_pushboolean(L, 1); - return 1; -} - -static int gc_colors_strempty(lua_State *L) -{ - /* - * Empty string is specially recolored at the end - * of atomic phase. - */ - lua_pushstring(L, ""); - /* Check that none of the internal asserts will fail. */ - for (int i = 0; i < 100; i++) - lua_gc(L, LUA_GCCOLLECT, 0); - lua_pop(L, 1); - lua_pushboolean(L, 1); - return 1; -} - -static int gc_colors_tbar(lua_State *L) -{ - int n = lua_gettop(L); - if (n != 1 || !lua_isfunction(L, 1)) - luaL_error(L, "incorrect arguments: 1 function is required"); - /* Check that none of the internal asserts will fail. */ - lua_call(L, 0, 0); - lua_pushboolean(L, 1); - return 1; -} - static int gc_steps(lua_State *L) { struct luam_Metrics oldm, newm; @@ -269,9 +227,6 @@ static int tracenum_base(lua_State *L) static const struct luaL_Reg testgetmetrics[] = { {"base", base}, {"gc_allocated_freed", gc_allocated_freed}, - {"gc_colors_base", gc_colors_base}, - {"gc_colors_strempty", gc_colors_strempty}, - {"gc_colors_tbar", gc_colors_tbar}, {"gc_steps", gc_steps}, {"objcount", objcount}, {"snap_restores", snap_restores}, diff --git a/test/lib-misc-getmetrics.test.lua b/test/lib-misc-getmetrics.test.lua index 66423ab..2859e26 100755 --- a/test/lib-misc-getmetrics.test.lua +++ b/test/lib-misc-getmetrics.test.lua @@ -7,7 +7,7 @@ local tap = require('tap') local test = tap.test("lib-misc-getmetrics") -test:plan(13) +test:plan(10) local jit_opt_default_hotloop = 56 local jit_opt_default_hotexit = 10 @@ -16,7 +16,7 @@ local jit_opt_default_minstitch = 0 -- Test Lua API. test:test("base", function(subtest) - subtest:plan(22) + subtest:plan(19) local metrics = misc.getmetrics() subtest:ok(metrics.strhash_hit >= 0) subtest:ok(metrics.strhash_miss >= 0) @@ -26,10 +26,6 @@ test:test("base", function(subtest) subtest:ok(metrics.gc_udatanum >= 0) subtest:ok(metrics.gc_cdatanum >= 0) - subtest:ok(metrics.gc_whitenum >= 2) - subtest:ok(metrics.gc_graynum >= 0) - subtest:ok(metrics.gc_blacknum >= 0) - subtest:ok(metrics.gc_total >= 0) subtest:ok(metrics.gc_freed >= 0) subtest:ok(metrics.gc_allocated >= 0) @@ -47,43 +43,6 @@ test:test("base", function(subtest) subtest:ok(metrics.jit_trace_num >= 0) end) -test:test("gc-colors-base", function(subtest) - subtest:plan(2) - - -- Force up garbage collect all dead objects. - collectgarbage("collect") - - -- There are no non-white objects after full gc cycle. - local metrics = misc.getmetrics() - subtest:is(metrics.gc_graynum, 0) - subtest:is(metrics.gc_blacknum, 0) -end) - -test:test("gc-colors-stremty", function(subtest) - subtest:plan(1) - -- Empty string is specially recolored at the end - -- of atomic phase. - local strempty = "" - -- Check that none of the internal asserts will fail. - for i=1, 100 do - collectgarbage("collect") - end - subtest:ok(true, "no assertion failed") -end) - --- Upvalues are never gray. -tbar_t = {} -test:test("gc-colors-tbar", function(subtest) - subtest:plan(1) - local tabnew = require"table.new" - for i =1, 100 do - tbar_t.x = tabnew(i,0) - end - collectgarbage("collect") - tbar_t = nil - subtest:ok(true, "no assertion failed") -end) - test:test("gc-allocated-freed", function(subtest) subtest:plan(1) @@ -404,26 +363,26 @@ test:test("strhash", function(subtest) local new_metrics = misc.getmetrics() -- Do not use test:ok to avoid extra strhash hits/misses. - assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 22) + assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 19) assert(new_metrics.strhash_miss - old_metrics.strhash_miss == 0) old_metrics = new_metrics local str1 = "strhash".."_hit" new_metrics = misc.getmetrics() - assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 23) + assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 20) assert(new_metrics.strhash_miss - old_metrics.strhash_miss == 0) old_metrics = new_metrics new_metrics = misc.getmetrics() - assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 22) + assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 19) assert(new_metrics.strhash_miss - old_metrics.strhash_miss == 0) old_metrics = new_metrics local str2 = "new".."string" new_metrics = misc.getmetrics() - assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 22) + assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 19) assert(new_metrics.strhash_miss - old_metrics.strhash_miss == 1) subtest:ok(true, "no assertion failed") end) ================================================================== [1]: https://lists.tarantool.org/pipermail/tarantool-patches/2020-October/019882.html -- Best regards, Sergey Kaplun