{"id":18430650,"url":"https://github.com/trivago/fastutil-concurrent-wrapper","last_synced_at":"2025-04-07T17:33:44.881Z","repository":{"id":43256827,"uuid":"444013140","full_name":"trivago/fastutil-concurrent-wrapper","owner":"trivago","description":"Set of concurrent wrappers around fastutil primitive maps ","archived":false,"fork":false,"pushed_at":"2023-12-05T09:41:49.000Z","size":111,"stargazers_count":41,"open_issues_count":5,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T22:23:33.580Z","etag":null,"topics":["concurrency","concurrenthashmap","fastutil","hashmap-java","hashmaps","java","java-concurrency","locks","maps","primitive-types","threadsafety"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trivago.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":"2022-01-03T09:58:55.000Z","updated_at":"2025-03-15T17:33:27.000Z","dependencies_parsed_at":"2023-10-15T03:33:10.546Z","dependency_job_id":"192bca79-e622-4b22-b2fe-29544f15a5a5","html_url":"https://github.com/trivago/fastutil-concurrent-wrapper","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trivago%2Ffastutil-concurrent-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trivago%2Ffastutil-concurrent-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trivago%2Ffastutil-concurrent-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trivago%2Ffastutil-concurrent-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trivago","download_url":"https://codeload.github.com/trivago/fastutil-concurrent-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247698166,"owners_count":20981312,"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":["concurrency","concurrenthashmap","fastutil","hashmap-java","hashmaps","java","java-concurrency","locks","maps","primitive-types","threadsafety"],"created_at":"2024-11-06T05:21:49.892Z","updated_at":"2025-04-07T17:33:44.523Z","avatar_url":"https://github.com/trivago.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastUtil Concurrent Wrapper\n\n![Java CI](https://github.com/trivago/fastutil-concurrent-wrapper/actions/workflows/gradle.yml/badge.svg)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.trivago/fastutil-concurrent-wrapper/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/com.trivago/fastutil-concurrent-wrapper/)\n\n## Description\n\nSet of concurrent wrappers around [fastutil primitive maps](https://github.com/vigna/fastutil).\n\n[How we use it at trivago.](https://tech.trivago.com/post/2022-03-09-why-and-how-we-use-primitive-maps)\n\nMain purpose is to provide useful concurrent builders around \nfastutil primitive maps with flexible locking policy.\n\nAdvantages over [java.util wrappers](https://docs.oracle.com/javase/tutorial/collections/implementations/wrapper.html):\n\n- builders provide maps with buckets,\n- every map uses `striped ReadWriteLocks` instead of `synchronized(mutex)`; one RW-lock per map's bucket, \n- two lock modes: `standard` and `busy-waiting` (could be good for low-latency systems),\n- no extra memory on stack -- API based on `primitive types`.\n\nCheck [usage](#usage) section for more details.\n\n_Note_: currently the lib contains wrappers not for every primitive map. Feel free to contribute.\n\n## Install\n\n#### Maven\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.trivago\u003c/groupId\u003e\n    \u003cartifactId\u003efastutil-concurrent-wrapper\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### Gradle\n\n```groovy\nimplementation group: 'com.trivago', name: 'fastutil-concurrent-wrapper', version: '0.2.2'\n```\n\n## Usage\n\n### Builder options\n- `number of buckets` -- number of buckets in the map (default `8`),\n- `default value` -- default value, for _getOrDefault()_ method\n- `initial capacity` -- initial map capacity (default `100_000`),\n- `concurrent mode` -- lock mode: _default_ and _busy-waiting_,\n- `load factor` -- map load factor (default `0.8f`).\n\n### Basic usage\n\n```java\nConcurrentLongLongMapBuilder b = ConcurrentLongLongMapBuilder.newBuilder()\n        .withBuckets(2)\n        .withDefaultValue(0)\n        .withInitialCapacity(100)\n        .withMode(ConcurrentLongLongMapBuilder.MapMode.BUSY_WAITING)\n        .withLoadFactor(0.9f);\n\nLongLongMap map = b.build();\n\nmap.put(1L, 10L);\nlong v = map.get(1L);\n\n```\n\nExamples of creation and usage could be found inside \n[test directory](https://github.com/trivago/fastutil-concurrent-wrapper/tree/master/src/test/java/com/trivago/fastutilconcurrentwrapper);\n\n### MapMode\n\nCurrently, we offer two locking modes:\n\n- `blocking` (default),\n- `busy-waiting`.\n\n### JMH tests\n\nFor running JMH tests just execute:\n```bash\n./gradlew jmh\n```\n\nResults for `FastutilWrapper BusyWaiting mode` vs `FastutilWrapper Default mode` vs [java.util wrappers](https://docs.oracle.com/javase/tutorial/collections/implementations/wrapper.html)\n\nThroughput (more is better)\n\n```shell\nBenchmark                                                        Mode  Cnt         Score         Error  Units\n\nFastutilWrapperBusyWaitingBenchmark.testRandomAllOpsThroughput  thrpt   15  14517457,055 ?  795637,784  ops/s\nFastutilWrapperBusyWaitingBenchmark.testRandomGetThroughput     thrpt   15  16610181,320 ? 1456776,589  ops/s\nFastutilWrapperBusyWaitingBenchmark.testRandomPutThroughput     thrpt   13  11706178,916 ? 2547333,524  ops/s\n\nFastutilWrapperDefaultBenchmark.testRandomAllOpsThroughput      thrpt   15   7385357,514 ? 1127356,032  ops/s\nFastutilWrapperDefaultBenchmark.testRandomGetThroughput         thrpt   15  16190621,923 ? 1836415,022  ops/s\nFastutilWrapperDefaultBenchmark.testRandomPutThroughput         thrpt   15   8945369,395 ? 1225460,217  ops/s\n\nJavaUtilWrapperBenchmark.testRandomAllOpsThroughput             thrpt   15   4921201,916 ?  410471,239  ops/s\nJavaUtilWrapperBenchmark.testRandomGetThroughput                thrpt   15   7827123,690 ?  557193,670  ops/s\nJavaUtilWrapperBenchmark.testRandomPutThroughput                thrpt   15   4832517,371 ? 1122344,647  ops/s\n```\nAverageTime per ops (less is better)\n\n```shell\nBenchmark                                                        Mode  Cnt         Score         Error  Units\n\nFastutilWrapperBusyWaitingBenchmark.testRandomAllOpsAvgTime      avgt   15       268,790 ?      22,526  ns/op\nFastutilWrapperBusyWaitingBenchmark.testRandomGetAvgTime         avgt   15       231,552 ?      16,116  ns/op\nFastutilWrapperBusyWaitingBenchmark.testRandomPutAvgTime         avgt   10       292,246 ?      49,757  ns/op\n\nFastutilWrapperDefaultBenchmark.testRandomAllOpsAvgTime          avgt   15       467,381 ?       9,790  ns/op\nFastutilWrapperDefaultBenchmark.testRandomGetAvgTime             avgt   15       237,683 ?      14,167  ns/op\nFastutilWrapperDefaultBenchmark.testRandomPutAvgTime             avgt   15       427,441 ?      25,116  ns/op\n\nJavaUtilWrapperBenchmark.testRandomAllOpsAvgTime                 avgt   15       781,869 ?     191,081  ns/op\nJavaUtilWrapperBenchmark.testRandomGetAvgTime                    avgt   15       470,869 ?      33,198  ns/op\nJavaUtilWrapperBenchmark.testRandomPutAvgTime                    avgt   15       964,613 ?     422,648  ns/op\n```\n\nThe machine\n```shell\nMacBook Pro (15-inch, 2019)\nProcessor 2,6 GHz 6-Core Intel Core i7\nMemory 16 GB 2400 MHz DDR4\n```\n\n## Maintainers\nA-Z surname order\n\n- [@mchernyakov](https://github.com/mchernyakov)\n- [@erdoganf](https://github.com/erdoganf)\n- [@sarveswaran-m](https://github.com/sarveswaran-m)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrivago%2Ffastutil-concurrent-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrivago%2Ffastutil-concurrent-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrivago%2Ffastutil-concurrent-wrapper/lists"}