{"id":26728819,"url":"https://github.com/slashdotted/cpp-consistent-hashing-algorithms","last_synced_at":"2026-02-09T13:04:56.566Z","repository":{"id":210899886,"uuid":"727714990","full_name":"slashdotted/cpp-consistent-hashing-algorithms","owner":"slashdotted","description":"C++ implementations and benchmark tools for MementoHash, AnchorHash, JumpHash, and PowerConsistentHash","archived":false,"fork":false,"pushed_at":"2024-05-21T08:11:45.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T09:21:17.571Z","etag":null,"topics":["anchorhash","benchmarking","consistent-hash-algorithm","consistent-hashing","jumphash","mementohash","powerconsistenthashing"],"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/slashdotted.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,"zenodo":null}},"created_at":"2023-12-05T12:32:34.000Z","updated_at":"2024-03-05T14:34:19.000Z","dependencies_parsed_at":"2024-01-13T03:28:37.827Z","dependency_job_id":"8f5dae58-0972-4c98-bdab-f9e3876bd27e","html_url":"https://github.com/slashdotted/cpp-consistent-hashing-algorithms","commit_stats":{"total_commits":21,"total_committers":3,"mean_commits":7.0,"dds":0.6666666666666667,"last_synced_commit":"2e535897ab856d0fd763a340c3a5747a110aa4f7"},"previous_names":["slashdotted/cpp-consistent-hashing-algorithms"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/slashdotted/cpp-consistent-hashing-algorithms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fcpp-consistent-hashing-algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fcpp-consistent-hashing-algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fcpp-consistent-hashing-algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fcpp-consistent-hashing-algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slashdotted","download_url":"https://codeload.github.com/slashdotted/cpp-consistent-hashing-algorithms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashdotted%2Fcpp-consistent-hashing-algorithms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29266163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T12:53:16.161Z","status":"ssl_error","status_checked_at":"2026-02-09T12:52:30.244Z","response_time":56,"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":["anchorhash","benchmarking","consistent-hash-algorithm","consistent-hashing","jumphash","mementohash","powerconsistenthashing"],"created_at":"2025-03-27T22:36:44.252Z","updated_at":"2026-02-09T13:04:56.540Z","avatar_url":"https://github.com/slashdotted.png","language":"C++","readme":"# cpp-consistent-hashing-algorithms\nThis project collects C++ implementations and benchmarking tools of some of the most prominent consistent hashing algorithms for non-peer-to-peer contexts.\n\nThe implemented algorithms are:\n* [2014] __jump hash__ by [Lamping and Veach](https://arxiv.org/pdf/1406.2294.pdf)\n* [2020] __anchor hash__ by [Gal Mendelson et al.](https://arxiv.org/pdf/1812.09674.pdf), using the implementation found on [Github](https://github.com/anchorhash/cpp-anchorhash)\n* [2023] __power consistent hash__ by [Eric Leu](https://arxiv.org/pdf/2307.12448.pdf)\n* [2023] __memento hash__ by [M. Coluzzi et al.](https://arxiv.org/pdf/2306.09783.pdf)\n\n## Benchmarks\n\nThe project includes three benchmarking tools **speed_test**, **balance**, and **monotonicity** derived from the same tools provided by [Anchorhash](https://github.com/anchorhash/cpp-anchorhash)\n\n**speed_test** also records **heap allocations** and the maximum allocated heap space.\n\n## Building\n\nClone the repository:\n```bash\ngit clone https://github.com/slashdotted/cpp-consistent-hashing-algorithms.git\n```\nMove into the project's directory and update the [vcpkg](https://vcpkg.io/en/) submodule:\n```bash\ncd cpp-consistent-hashing-algorithms/\ngit submodule update --init\ncd vcpkg\n./bootstrap-vcpkg.sh -useSystemBinaries\n```\nGenerate the build file (for [Ninja](https://ninja-build.org/)):\n```bash\ncd ..\ncmake -B build/ -S . -GNinja -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release\n```\nMove into the **build** directory and start building:\n```bash\ncd build\nninja\n```\n## Running the benchmarks\nThe **speed_test** benchmark performs several random key lookups, the syntax is:\n```bash\n./speed_test Algorithm AnchorSet WorkingSet NumRemovals Numkeys ResFilename\n```\nwhere\n * **Algorithm** can be *memento* (for MementoHash using *boost::unordered_flat_map* for the removal set), *mementoboost* (for MementoHash using *boost::unordered_map* for the removal set), *mementostd* (for MementoHash using *std::unordered_map* for the removal set), *mementomash* (for MementoHash using a hash table similar to Java's HashMap), *anchor* (for AnchorHash), *mementogtl* (for Memento with gtl hash map), *jump* (for JumpHash), *power* (for Power Consistent Hashing)\n * **AnchorSet** is the size of the Anchor set (**a**): this parameter is used only by *anchor* but must be set to a value *at least equal to WorkingSet* even with *MementoHash*;\n * **WorkingSet** is the size of the initial Working set (**w**);\n * **NumRemovals** is the number of nodes that should be removed (randomly, except for *Jump*) before starting the benchmark;\n * **Numkeys** is the number of keys that will be queried during the benchmark;\n * **ResFilename** is the filename containing the results of the benchmark;\nBy default, details about the allocate memory will also be produced in the output. For example:\n```bash\n./speed_test memento 1000000 1000000 20000 1000000 memento.txt\nAlgorithm: memento, AnchorSet: 1000000, WorkingSet: 1000000, NumRemovals: 20000, NumKeys: 1000000, ResFileName: memento.txt, Random: rand()\n   @StartBenchmark: Allocations: 0, Allocated: 0, Deallocations: 0, Deallocated: 0, Maximum: 0\n   @AfterAlgorithmInit: Allocations: 0, Allocated: 0, Deallocations: 0, Deallocated: 0, Maximum: 0\n   @AfterRemovals: Allocations: 11, Allocated: 802488, Deallocations: 10, Deallocated: 401076, Maximum: 802488\n   @EndBenchmark: Allocations: 11, Allocated: 802488, Deallocations: 10, Deallocated: 401076, Maximum: 802488\nMemento\u003cboost::unordered_flat_map\u003e Elapsed time is 0.333966 seconds, maximum heap allocated memory is 802488 bytes, sizeof(Memento\u003cboost::unordered_flat_map\u003e) is 56\n```\n\nThe **balance** benchmark performs a balance test and accepts the same parameters as **speed_test**. Example:\n\n```bash\n./balance memento 1000000 1000000 20000 1000000 memento.txt\nAlgorithm: memento, AnchorSet: 1000000, WorkingSet: 1000000, NumRemovals: 20000, NumKeys: 1000000, ResFileName: memento.txt\nMemento\u003cboost::unordered_flat_map\u003e: LB is 8.82\n```\nThe **monotonicity** benchmark performs a monotonicity test and accepts the same parameters as **speed_test**. Example:\n\n```bash\n./monotonicity memento 1000000 1000000 1000 1000000 memento.txt\nAlgorithm: memento, AnchorSet: 1000000, WorkingSet: 1000000, NumRemovals: 1000, NumKeys: 1000000, ResFileName: memento.txt\nDone determining initial assignment of 1000000 unique keys\nRemoved node 424868\nMemento\u003cboost::unordered_flat_map\u003e: after removal misplaced keys are 0% (0 keys out of 1000000)\nAdded node 424868\nMemento\u003cboost::unordered_flat_map\u003e: after adding back misplaced keys are 0% (0 keys out of 1000000)\n```\n\n## Java implementation\nFor a Java implementation of these and additional algorithms please refer to [this repository](https://github.com/SUPSI-DTI-ISIN/java-consistent-hashing-algorithms)\n\n## Credits\nThe AnchorHash implementation is based on code Copyright (c) 2020 anchorhash released under the MIT License\nMementoHash is based on the Java implementation found on [this repository](https://github.com/SUPSI-DTI-ISIN/java-consistent-hashing-algorithms), released under the GNU GPL-3.0 license \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslashdotted%2Fcpp-consistent-hashing-algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslashdotted%2Fcpp-consistent-hashing-algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslashdotted%2Fcpp-consistent-hashing-algorithms/lists"}