{"id":13645085,"url":"https://github.com/microsoft/snmalloc","last_synced_at":"2025-04-11T03:32:51.313Z","repository":{"id":37802943,"uuid":"164874285","full_name":"microsoft/snmalloc","owner":"microsoft","description":"Message passing based allocator","archived":false,"fork":false,"pushed_at":"2025-04-03T12:56:41.000Z","size":5456,"stargazers_count":1646,"open_issues_count":42,"forks_count":114,"subscribers_count":39,"default_branch":"main","last_synced_at":"2025-04-03T20:05:33.887Z","etag":null,"topics":["allocator","malloc","memory-allocator"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.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":"docs/security/FreelistProtection.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-09T14:05:53.000Z","updated_at":"2025-04-03T12:56:45.000Z","dependencies_parsed_at":"2022-07-14T04:20:30.307Z","dependency_job_id":"64d27b35-7d17-4de0-ad88-404509e0b452","html_url":"https://github.com/microsoft/snmalloc","commit_stats":{"total_commits":1119,"total_committers":35,"mean_commits":31.97142857142857,"dds":0.581769436997319,"last_synced_commit":"feff2e8151f4c8465139de9e768520fdf3b9ee94"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsnmalloc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsnmalloc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsnmalloc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsnmalloc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/snmalloc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248335440,"owners_count":21086591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["allocator","malloc","memory-allocator"],"created_at":"2024-08-02T01:02:26.306Z","updated_at":"2025-04-11T03:32:51.287Z","avatar_url":"https://github.com/microsoft.png","language":"C++","readme":"# snmalloc\n\nsnmalloc is a high-performance allocator. \nsnmalloc can be used directly in a project as a header-only C++ library, \nit can be `LD_PRELOAD`ed on Elf platforms (e.g. Linux, BSD),\nand there is a [crate](https://crates.io/crates/snmalloc-rs) to use it from Rust.\n\nIts key design features are:\n\n* Memory that is freed by the same thread that allocated it does not require any\n  synchronising operations.\n* Freeing memory in a different thread to initially allocated it, does not take\n  any locks and instead uses a novel message passing scheme to return the\n  memory to the original allocator, where it is recycled.  This enables 1000s of remote \n  deallocations to be performed with only a single atomic operation enabling great\n  scaling with core count. \n* The allocator uses large ranges of pages to reduce the amount of meta-data\n  required.\n* The fast paths are highly optimised with just two branches on the fast path \n  for malloc (On Linux compiled with Clang).\n* The platform dependencies are abstracted away to enable porting to other platforms. \n\nsnmalloc's design is particular well suited to the following two difficult \nscenarios that can be problematic for other allocators:\n\n  * Allocations on one thread are freed by a different thread\n  * Deallocations occur in large batches\n\nBoth of these can cause massive reductions in performance of other allocators, but \ndo not for snmalloc.\n\nThe implementation of snmalloc has evolved significantly since the [initial paper](snmalloc.pdf).\nThe mechanism for returning memory to remote threads has remained, but most of the meta-data layout has changed.\nWe recommend you read [docs/security](./docs/security/README.md) to find out about the current design, and \nif you want to dive into the code [docs/AddressSpace.md](./docs/AddressSpace.md) provides a good overview of the allocation and deallocation paths.\n\n[![snmalloc CI](https://github.com/microsoft/snmalloc/actions/workflows/main.yml/badge.svg)](https://github.com/microsoft/snmalloc/actions/workflows/main.yml)\n\n# Hardening\n\nThere is a hardened version of snmalloc, it contains\n\n*  Randomisation of the allocations' relative locations,\n*  Most meta-data is stored separately from allocations, and is protected with guard pages,\n*  All in-band meta-data is protected with a novel encoding that can detect corruption, and\n*  Provides a `memcpy` that automatically checks the bounds relative to the underlying malloc.\n\nA more comprehensive write up is in [docs/security](./docs/security/README.md).\n\n# Further documentation\n\n - [Instructions for building snmalloc](docs/BUILDING.md)\n - [Instructions for porting snmalloc](docs/PORTING.md)\n\n# Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.microsoft.com.\n\nWhen you submit a pull request, a CLA-bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n","funding_links":[],"categories":["Memory Allocation","C++","Memory"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fsnmalloc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fsnmalloc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fsnmalloc/lists"}