{"id":13813561,"url":"https://github.com/phuslu/shardmap","last_synced_at":"2025-05-15T00:33:34.806Z","repository":{"id":196217270,"uuid":"695190141","full_name":"phuslu/shardmap","owner":"phuslu","description":"A simple and efficient thread-safe sharded hashmap for Go","archived":false,"fork":true,"pushed_at":"2023-09-29T15:05:40.000Z","size":20,"stargazers_count":28,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-04T04:04:17.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"tidwall/shardmap","license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phuslu.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}},"created_at":"2023-09-22T14:51:06.000Z","updated_at":"2024-07-22T23:49:09.000Z","dependencies_parsed_at":"2023-09-23T12:33:42.399Z","dependency_job_id":"fe98c216-5a7f-4f03-b80a-0560666f3e98","html_url":"https://github.com/phuslu/shardmap","commit_stats":null,"previous_names":["phuslu/shardmap"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fshardmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fshardmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fshardmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phuslu%2Fshardmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phuslu","download_url":"https://codeload.github.com/phuslu/shardmap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225319269,"owners_count":17455737,"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":[],"created_at":"2024-08-04T04:01:21.416Z","updated_at":"2024-11-19T08:30:44.845Z","avatar_url":"https://github.com/phuslu.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# `shardmap`\n\n[![GoDoc](https://img.shields.io/badge/api-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/phuslu/shardmap)\n\nA simple and efficient thread-safe sharded hashmap for Go.\nThis is an alternative to the standard Go map and `sync.Map`, and is optimized\nfor when your map needs to perform lots of concurrent reads and writes.\n\nUnder the hood `shardmap` uses \n[robinhood hashmap](https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing) and \n[wyhash](https://github.com/zeebo/wyhash).\n\n# Getting Started\n\n## Installing\n\nTo start using `shardmap`, install Go and run `go get`:\n\n```sh\n$ go get -u github.com/phuslu/shardmap\n```\n\nThis will retrieve the library.\n\n## Usage\n\nThe `Map` type works similar to a standard Go map, and includes four methods:\n`Set`, `Get`, `Delete`, `Len`.\n\n```go\nm := shardmap.New[string, string](0)\nm.Set(\"Hello\", \"Dolly!\")\nval, _ := m.Get(\"Hello\")\nfmt.Printf(\"%v\\n\", val)\nval, _ = m.Delete(\"Hello\")\nfmt.Printf(\"%v\\n\", val)\nval, _ = m.Get(\"Hello\")\nfmt.Printf(\"%v\\n\", val)\n\n// Output:\n// Dolly!\n// Dolly!\n// \n```\n\n## Performance\n\nBenchmarking concurrent SET, GET, and DELETE operations for \n    `sync.Map`, `orcaman/concurrent-map`, `phuslu/shardmap`. \n\n```\ngo version go1.21.1 linux/amd64 (Intel(R) Xeon(R) Silver 4216 CPU @ 2.10GHz)\n\n     number of cpus: 64\n     number of keys: 10000000\n            keysize: 16\n        random seed: 1695872462865986967\n\n-- sync.Map --\nset: 10,000,000 ops over 64 threads in 16141ms, 619,553/sec, 1614 ns/op\nget: 10,000,000 ops over 64 threads in 6919ms, 1,445,229/sec, 691 ns/op\ndel: 10,000,000 ops over 64 threads in 5016ms, 1,993,464/sec, 501 ns/op\n\n-- github.com/orcaman/concurrent-map/v2 --\nset: 10,000,000 ops over 64 threads in 1327ms, 7,533,463/sec, 132 ns/op\nget: 10,000,000 ops over 64 threads in 252ms, 39,742,423/sec, 25 ns/op\ndel: 10,000,000 ops over 64 threads in 769ms, 12,995,480/sec, 76 ns/op\n\n-- tailscale.com/syncs --\nset: 10,000,000 ops over 64 threads in 473ms, 21,120,763/sec, 47 ns/op\nget: 10,000,000 ops over 64 threads in 107ms, 93,572,966/sec, 10 ns/op\ndel: 10,000,000 ops over 64 threads in 124ms, 80,512,652/sec, 12 ns/op\n\n-- github.com/alphadose/haxmap --\nset: 10,000,000 ops over 64 threads in 13285ms, 752,728/sec, 1328 ns/op\nget: 10,000,000 ops over 64 threads in 84ms, 119,259,602/sec, 8 ns/op\ndel: 10,000,000 ops over 64 threads in 1641ms, 6,092,923/sec, 164 ns/op\n\n-- github.com/phuslu/shardmap --\nset: 10,000,000 ops over 64 threads in 281ms, 35,588,233/sec, 28 ns/op\nget: 10,000,000 ops over 64 threads in 80ms, 125,519,306/sec, 7 ns/op\ndel: 10,000,000 ops over 64 threads in 121ms, 82,783,512/sec, 12 ns/op\n```\n\n## License\n\n`shardmap` source code is available under the MIT [License](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphuslu%2Fshardmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphuslu%2Fshardmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphuslu%2Fshardmap/lists"}