{"id":20564319,"url":"https://github.com/tarantool/small","last_synced_at":"2025-04-05T04:11:21.087Z","repository":{"id":1950802,"uuid":"44667904","full_name":"tarantool/small","owner":"tarantool","description":"Specialized memory allocators","archived":false,"fork":false,"pushed_at":"2025-01-06T15:43:46.000Z","size":671,"stargazers_count":106,"open_issues_count":17,"forks_count":23,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-03-29T03:07:21.623Z","etag":null,"topics":["memory-allocation","slab-arena"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tarantool.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":"2015-10-21T10:06:27.000Z","updated_at":"2025-02-25T09:45:09.000Z","dependencies_parsed_at":"2024-07-23T16:04:41.347Z","dependency_job_id":"d5a9a21e-f8ff-4539-b997-819517a9e070","html_url":"https://github.com/tarantool/small","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarantool%2Fsmall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarantool%2Fsmall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarantool%2Fsmall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarantool%2Fsmall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarantool","download_url":"https://codeload.github.com/tarantool/small/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284950,"owners_count":20913704,"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":["memory-allocation","slab-arena"],"created_at":"2024-11-16T04:25:38.735Z","updated_at":"2025-04-05T04:11:21.067Z","avatar_url":"https://github.com/tarantool.png","language":"C","readme":"# small - a collection of Specialized Memory ALLocators for small allocations\n\n[![Build Status](https://travis-ci.org/tarantool/small.png?branch=master)](https://travis-ci.org/tarantool/small)\n\n![Allocators hierarhy](doc/images/allocators_hierarchy_light.svg#gh-light-mode-only)\n![Allocators hierarhy](doc/images/allocators_hierarchy_dark.svg#gh-dark-mode-only)\n\nThe library provides the following facilities:\n\n# quota\n\nSet a limit on the amount of memory all allocators use.\nThread-safe.\n\n## slab_arena\n\nTo initialize an arena, you need a quota. Multiple arenas\ncan use a shared quota object. Thread safe.\n\nDefines an API with two methods: map() and unmap().\nMap returns a memory area. Unmap returns this area to the arena.\nAll objects returned by arena have the same size, defined in\ninitialization-time constant SLAB_MAX_SIZE.\nBy default, SLAB_MAX_SIZE is 4M. All objects returned by arena\nare aligned by SLAB_MAX_SIZE: (ptr \u0026 (SLAB_MAX_SIZE - 1)) is\nalways 0. SLAB_MAX_SIZE therefore must be a power of 2. Limiting\nSLAB_MAX_SIZE is important to avoid internal fragmentation.\nMultiple arenas can exist, an object must be returned to the same\narena in which it was allocated.\n\nThere is a number of different implementations of slab_arena\nAPI:\n\n- huge_arena: this implementation maps at initialization\n  time a huge region of memory, and then uses this region to\n  produce objects. Can be configured to use shared or private\n  mappings.\n- grow_arena - mmaps() each individual block. Thus can incur\n  fragmentation of the address space, but actually\n  returns objects to the OS on unmap.\n\nUse of instances of slab_arena is thread-safe: multiple\nthreads can use the same arena.\n  \n## slab_cache\n\nRequires an arena for initialization, which works\nas a memory source for slab_cache.\nReturns power-of-two sized slabs, with size-aligned address.\nUses a buddy system to deal with memory fragmentation.\nIs expected to be thread-local.\n\n## mempool\n\nA memory pool for objects of the same size. Thread local.\nRequires a slab cache, which works as a source of memory.\nAutomatically defines the optimal slab size, given \nthe object size. Supports alloc() and free().\n\n## region\n\nA typical region allocator. Very cheap allocation,\nbut all memory can be freed at once only. Supports savepoints,\ni.e. an allocation point to which it can roll back, i.e.\nfree all memory allocated after a savepoint.\nUses slab_cache as a memory source.\n\n## small\n\nA typical slab allocator. Built as a collection \nof mempool allocators, each mempool suited for a particular\nobject size. Has stepped pools, i.e. pools for small objects \nup to 500 bytes, and factored pools, for larger objects.\nThe difference between stepped and factored pools is that\nobject size in stepped pools grows step by step, each\nnext pool serving objects of prev_pool_object_size + 8.\nIn factored pools a growth factor is used, i.e. \ngiven a factor of 1.1 and previous pool for objects\nof size up to 1000, next pool will serve objects in range\n1001-1100.\nSince is based on mempool, uses slab_cache as a memory source.\n\n## ibuf\n\nA typical input buffer, which could be seen as a memory allocator\nas well, which reallocates itself when it gets full.\nUses slab_cache as a memory source.\n\n## obuf\n\nAnother implementation of an output buffer, which, for growth,\ninstead of reallocation, used a collection of buffers,\nsize of each next buffer in a collection twice the\nsize the prevoius one. \nUses slab_cache as a memory source.\n\n## matras\n\nThis is the best one. Memory Address Translating\nallocator. Only allows to allocate objects of size\nwhich is a power of two. Provides a 32-bit\nid for each allocated object. Supports multi-versioning\nfor all allocated objects, i.e. it's possible to create\na consistent read view of all allocated memory.\n\nUses slab_cache as a memory source.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarantool%2Fsmall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarantool%2Fsmall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarantool%2Fsmall/lists"}