Corecpp 2023 allocations tracking lighting talk
In the repository root there is slides from the talk: Allocation policy enforcement.pdf.
Every folder in the repository represents one snippet. Each snippet should be buildable in the container described by the Dockerfile in the root of the repository.
To build and attach to the container, invoke the following command in the root of the repository.
> make build
> make run
To run a snippet. In the container.
> /workdir# cd tcmallochook/
> /workdir/tcmallochook# make build
clang++ -std=c++20 -Wall -Wextra -O2 -DNDEBUG -ltcmalloc hook.cpp -o hook
> /workdir/tcmallochook# make run
./hook
malloc(32} called from 0x11940a0
sizeof(std::string) = 32
abacaba
These are snippets of a trivial malloc benchmark, created to provide an estimate of the order of magnitude of malloc+free call latency.
The actual latency in a real-world application will depend on the usage pattern. Please note that this benchmark should not be considered extensive or representative in any way. Its purpose is to provide a general understanding, rather than being a comprehensive benchmark.
This snippet demonstrates the usage of __mallok_hook from glibc. It's worth noting that this snippet is a bit outdated, as __malloc_hooks have been deprecated and removed from glibc. However, it serves as an interesting idea.
This snippet showcases hooks based on tcmalloc. It works well, but it requires gperftools to function properly.
Please be aware that using hooks can have significant implications for latency, so they should not be utilized in a production environment.
See CONTRIBUTING.md for details.
Apache 2.0; see LICENSE for details.
This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.