lua: add malloc info
This commit adds two new Lua functions: - `box.malloc.info()` is a public function that returns the total memory usage of internal data structures allocated with `malloc()`. This information is extracted from the `malloc_info()` output. See the doc bot request for details. - `box.malloc.internal.info()` is an internal function that returns a parsed XML document returned by `malloc_info()` as is. It isn't documented. We may need it to get the detailed information about the system memory allocator. Both functions are useful only on Linux and only if ASAN is disabled because otherwise `malloc_info()` is unavailable. On other platforms `box.malloc.info()` reports zero memory usage while `internal.info()` returns an empty table. Closes #7311 @TarantoolBot document Title: Document `box.malloc.info()` `box.malloc.info()` is a function that returns a table with two fields: ``` tarantool> box.malloc.info() --- - size: 2498560 used: 1835726 ... ``` The `used` value is the total amount of memory in bytes allocated by Tarantool for internal data structures with [`malloc()`][1]. The `size` value is the total amount of memory in bytes allocated from the system by the `malloc()` allocator. It may not be less than `used`. The function may be used before `box.cfg()` is called. Currently, the function is available only on Linux. On other systems it reports zero memory usage (`{size = 0, used = 0}`). [1]: https://man7.org/linux/man-pages/man3/malloc.3.html (cherry picked from commit d34a0cbc)
Showing
- CMakeLists.txt 2 additions, 0 deletionsCMakeLists.txt
- changelogs/unreleased/gh-7311-malloc-info.md 5 additions, 0 deletionschangelogs/unreleased/gh-7311-malloc-info.md
- src/box/lua/load_cfg.lua 1 addition, 0 deletionssrc/box/lua/load_cfg.lua
- src/box/lua/slab.cc 165 additions, 0 deletionssrc/box/lua/slab.cc
- src/trivia/config.h.cmake 2 additions, 0 deletionssrc/trivia/config.h.cmake
- test/app-luatest/gh_7311_malloc_info_test.lua 115 additions, 0 deletionstest/app-luatest/gh_7311_malloc_info_test.lua
- test/box/misc.result 1 addition, 0 deletionstest/box/misc.result
Loading
Please register or sign in to comment