{"id":18026776,"url":"https://github.com/yegor256/micromap","last_synced_at":"2026-03-11T08:16:20.226Z","repository":{"id":153245915,"uuid":"628644726","full_name":"yegor256/micromap","owner":"yegor256","description":"📈 The fastest (for very small maps!) alternative of Rust HashMap, which doesn't use hashing and doesn't use heap (aka \"linear map\")","archived":false,"fork":false,"pushed_at":"2026-02-27T18:32:35.000Z","size":997,"stargazers_count":189,"open_issues_count":17,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-02-27T22:50:20.362Z","etag":null,"topics":["data-structures","fast-map-matching","hashmap","linear-maps","performance","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/micromap","language":"Rust","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/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-16T15:38:24.000Z","updated_at":"2026-02-10T18:29:48.000Z","dependencies_parsed_at":"2023-06-01T14:00:18.944Z","dependency_job_id":"34a06200-3f0e-4de8-b5d2-02f43437fd8b","html_url":"https://github.com/yegor256/micromap","commit_stats":{"total_commits":402,"total_committers":10,"mean_commits":40.2,"dds":0.5124378109452736,"last_synced_commit":"5ace3d9b78af9f62f5394eb30b857528e9e0a503"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/yegor256/micromap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicromap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicromap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicromap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicromap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/micromap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fmicromap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30375913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: 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":["data-structures","fast-map-matching","hashmap","linear-maps","performance","rust"],"created_at":"2024-10-30T08:07:59.891Z","updated_at":"2026-03-11T08:16:20.183Z","avatar_url":"https://github.com/yegor256.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Fastest Linear Map in Rust\n\n[![cargo](https://github.com/yegor256/micromap/actions/workflows/cargo.yml/badge.svg)](https://github.com/yegor256/micromap/actions/workflows/cargo.yml)\n[![crates.io](https://img.shields.io/crates/v/micromap.svg)](https://crates.io/crates/micromap)\n[![codecov](https://codecov.io/gh/yegor256/micromap/branch/master/graph/badge.svg)](https://codecov.io/gh/yegor256/micromap)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/micromap)](https://hitsofcode.com/view/github/yegor256/micromap)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/micromap/blob/master/LICENSE.txt)\n[![docs.rs](https://img.shields.io/docsrs/micromap)](https://docs.rs/micromap/latest/micromap/)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fyegor256%2Fmicromap.svg?type=shield\u0026issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fyegor256%2Fmicromap?ref=badge_shield\u0026issueType=license)\n\nA much faster alternative of\n[`HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html),\nfor very small maps.\nIt is also faster than\n[FxHashMap](https://github.com/rust-lang/rustc-hash),\n[hashbrown](https://github.com/rust-lang/hashbrown),\n[ArrayMap](https://github.com/robjtede/tinymap),\n[IndexMap](https://crates.io/crates/indexmap),\nand _all_ others.\nThe smaller the map, the higher the performance.\nIt was observed that when a map contains more than 20 keys,\nit may be better to use the standard\n[`HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html),\nsince the performance of `micromap::Map` _may_ start to degrade.\nSee the [benchmarking results](#benchmark) below.\n\n**WELCOME**:\nNot all functions that you might expect to have in a map are implemented.\nI will appreciate if you contribute by implementing these\n[missing functions](https://github.com/yegor256/micromap/issues).\n\nFirst, add this to `Cargo.toml`:\n\n```toml\n[dependencies]\nmicromap = \"0.0.17\"\n```\n\nThen, use it like a standard hash map... well, almost:\n\n```rust\nuse micromap::Map;\nlet mut m : Map\u003cu64, \u0026str, 10\u003e = Map::new(); // allocation on stack\nm.insert(1, \"foo\");\nm.insert(2, \"bar\");\nassert_eq!(2, m.len());\n```\n\nPay attention, here the map is created with an extra generic argument `10`.\nThis is the total size of the map, which is allocated on stack when `::new()`\nis called. Unlike `HashMap`, the `Map` doesn't use heap at all. If more than\nten keys will be added to the map, it will panic.\n\nRead [the API documentation](https://docs.rs/micromap/latest/micromap/).\nThe struct\n[`micromap::Map`](https://docs.rs/micromap/latest/micromap/struct.Map.html)\nis designed to be as closely similar to\n[`std::collections::HashMap`][std] as possible.\n\n## Benchmark\n\nThere is a summary of a simple benchmark, where we compared `micromap::Map` with\na few other Rust maps, changing the total capacity of the map (horizontal axis).\nWe applied the same interactions\n([`benchmark.rs`][rs])\nto them and measured how fast they performed. In the following table,\nthe numbers over 1.0 indicate performance gain,\nwhile the numbers below 1.0 demonstrate performance loss.\n\n\u003c!-- benchmark --\u003e\n| | 2 | 4 | 8 | 16 | 32 | 64 | 128 |\n| --- | --: | --: | --: | --: | --: | --: | --: |\n| `flurry::HashMap` | 283.44 | 84.25 | 40.99 | 22.93 | 11.46 | 5.17 | 2.50 |\n| `hashbrown::HashMap` | 20.36 | 10.78 | 6.68 | 3.24 | 1.48 | 0.65 | 0.30 |\n| `heapless::LinearMap` | 1.08 | 1.41 | 1.20 | 1.23 | 1.04 | 1.05 | 0.86 |\n| `indexmap::IndexMap` | 13.11 | 11.53 | 7.49 | 5.94 | 2.18 | 0.94 | 0.44 |\n| `linear_map::LinearMap` | 1.62 | 1.49 | 1.06 | 1.10 | 1.01 | 1.15 | 1.02 |\n| `linked_hash_map::LinkedHashMap` | 26.22 | 20.17 | 12.37 | 6.73 | 3.46 | 1.59 | 0.70 |\n| `litemap::LiteMap` | 1.62 | 2.19 | 4.35 | 3.18 | 2.23 | 0.96 | 0.52 |\n| `micromap::Map` 👍 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 |\n| `nohash_hasher::BuildNoHashHasher` | 20.38 | 11.10 | 7.37 | 2.97 | 1.50 | 0.65 | 0.32 |\n| `rustc_hash::FxHashMap` | 20.07 | 10.80 | 6.85 | 2.95 | 1.28 | 0.61 | 0.28 |\n| `std::collections::BTreeMap` | 24.77 | 10.41 | 5.48 | 4.30 | 2.44 | 1.13 | 0.63 |\n| `std::collections::HashMap` | 20.71 | 13.81 | 8.63 | 4.70 | 2.64 | 1.07 | 0.51 |\n| `tinymap::array_map::ArrayMap` | 1.98 | 4.39 | 4.54 | 4.83 | 4.34 | 4.34 | 3.91 |\n\nThe experiment [was performed][action] on 07-04-2025.\nThere were 1000000 repetition cycles.\nThe entire benchmark took 248s.\nUname: 'Linux'.\n\n\u003c!-- benchmark --\u003e\n\nAs you see, the highest performance gain was achieved for the maps that\nwere smaller than ten keys.\nFor the maps of just a few keys, the gain was enormous.\n\n## How to Contribute\n\nFirst, install [Rust](https://www.rust-lang.org/tools/install) and then:\n\n```bash\ncargo test -vv\n```\n\nIf everything goes well, fork repository, make changes, send us a\n[pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nWe will review your changes and apply them to the `master` branch shortly,\nprovided they don't violate our quality standards. To avoid frustration,\nbefore sending us your pull request please run `cargo test` again. Also,\nrun `cargo fmt` and `cargo clippy`.\n\nAlso, before you start making changes, run benchmarks:\n\n```bash\nrustup run nightly cargo bench\n```\n\nThen, after the changes you make, run it again. Compare the results.\nIf your changes\ndegrade performance, think twice before submitting a pull request.\n\n[std]: https://doc.rust-lang.org/std/collections/struct.HashMap.html\n[rs]: https://github.com/yegor256/micromap/blob/master/tests/benchmark.rs\n[action]: https://github.com/yegor256/micromap/actions/workflows/benchmark.yml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fmicromap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Fmicromap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fmicromap/lists"}