{"id":23444079,"url":"https://github.com/sevagh/konfiscator","last_synced_at":"2026-04-21T09:32:10.782Z","repository":{"id":82225485,"uuid":"224964856","full_name":"sevagh/konfiscator","owner":"sevagh","description":"First-fit Free List malloc with Prometheus metrics and docker testbench","archived":false,"fork":false,"pushed_at":"2020-06-14T01:50:55.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-13T17:55:52.157Z","etag":null,"topics":["docker","malloc","malloc-tracing","memory-allocation","mmap","prometheus-exporter"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sevagh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-30T05:33:55.000Z","updated_at":"2020-06-14T22:16:41.000Z","dependencies_parsed_at":"2023-04-05T10:46:20.358Z","dependency_job_id":null,"html_url":"https://github.com/sevagh/konfiscator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sevagh/konfiscator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fkonfiscator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fkonfiscator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fkonfiscator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fkonfiscator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sevagh","download_url":"https://codeload.github.com/sevagh/konfiscator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sevagh%2Fkonfiscator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32085451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T06:27:27.065Z","status":"ssl_error","status_checked_at":"2026-04-21T06:27:21.250Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","malloc","malloc-tracing","memory-allocation","mmap","prometheus-exporter"],"created_at":"2024-12-23T18:26:31.320Z","updated_at":"2026-04-21T09:32:10.772Z","avatar_url":"https://github.com/sevagh.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# konfiscator\n\nkonfiscator is simple implementation of malloc using mmap and a First-Fit Free List (based on [embeddedartistry's article](https://embeddedartistry.com/blog/2017/02/15/implementing-malloc-first-fit-free-list/)) with the Linux kernel's [doubly linked list](./src/list.h). The only APIs implemented are malloc and free.\n\nThe script `docker_ci.sh` launches a Docker container and uses the [LD_PRELOAD](https://www.gnu.org/software/libc/manual/html_node/Replacing-malloc.html) trick to launch a simple driver program, which mallocs an array of ints to print, and launches a blocking Prometheus metrics script (exit with ctrl-c), binding to the host's port 8000:\n\n```\nindex 44: value 44\nindex 45: value 45\nindex 46: value 46\nindex 47: value 47\nindex 48: value 48\nindex 49: value 49\n+ echo 'konfiscator test done, exporting metrics'\nkonfiscator test done, exporting metrics\n+ /prometheus-metrics/konfiscator_metrics.py\nstarting up prometheus metrics endpoint\nupdating konfiscator stats\nupdating konfiscator stats\nupdating konfiscator stats\n```\n\nThere's a fun trick of using a mmapped file, `/tmp/konfiscator-stats`, to write simple integer counters to, which is then read by a Python [Prometheus metrics exporter](./prometheus-metrics/konfiscator_metrics.py) that reads from the same mmapped file. The 4 metrics collected are counters for some of konfiscator's internals, browsable at http://localhost:8000:\n\n```\n# HELP konfiscator_malloc_total konfiscator malloc calls\n# TYPE konfiscator_malloc_total gauge\nkonfiscator_malloc_total 2.0\n# HELP konfiscator_mmap_total konfiscator mmap calls\n# TYPE konfiscator_mmap_total gauge\nkonfiscator_mmap_total 0.0\n# HELP konfiscator_free_total konfiscator free calls\n# TYPE konfiscator_free_total gauge\nkonfiscator_free_total 1.0\n# HELP konfiscator_defrag_total konfiscator defragged blocks\n# TYPE konfiscator_defrag_total gauge\nkonfiscator_defrag_total 0.0\n```\n\nAfter joining the running container with `docker exec`, run `LD_PRELOAD=/libkonfiscator.so ./a.out` and reload the metrics endpoint to watch the stats get updated.\n\ndocker exec:\n\n```\nsevagh:konfiscator $ docker exec -it adoring_curran /bin/bash\n[root@e5668ad09f0f /]# LD_PRELOAD=/libkonfiscator.so ./a.out\nindex 0: value 0\nindex 1: value 1\nindex 2: value 2\n```\n\nUpdated metrics:\n\n```\n# HELP konfiscator_malloc_total konfiscator malloc calls\n# TYPE konfiscator_malloc_total gauge\nkonfiscator_malloc_total 4.0\n# HELP konfiscator_mmap_total konfiscator mmap calls\n# TYPE konfiscator_mmap_total gauge\nkonfiscator_mmap_total 0.0\n# HELP konfiscator_free_total konfiscator free calls\n# TYPE konfiscator_free_total gauge\nkonfiscator_free_total 2.0\n# HELP konfiscator_defrag_total konfiscator defragged blocks\n# TYPE konfiscator_defrag_total gauge\nkonfiscator_defrag_total 0.0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevagh%2Fkonfiscator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsevagh%2Fkonfiscator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsevagh%2Fkonfiscator/lists"}