{"id":18621271,"url":"https://github.com/yiling-j/go-cache-benchmark-plus","last_synced_at":"2025-04-11T02:31:39.591Z","repository":{"id":160875169,"uuid":"630002417","full_name":"Yiling-J/go-cache-benchmark-plus","owner":"Yiling-J","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-10T01:35:10.000Z","size":1513,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T08:22:16.655Z","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":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yiling-J.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-04-19T13:15:29.000Z","updated_at":"2024-08-10T01:35:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"d991a044-954a-42f7-b9b1-69b4e2d1a2b5","html_url":"https://github.com/Yiling-J/go-cache-benchmark-plus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yiling-J%2Fgo-cache-benchmark-plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yiling-J%2Fgo-cache-benchmark-plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yiling-J%2Fgo-cache-benchmark-plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yiling-J%2Fgo-cache-benchmark-plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yiling-J","download_url":"https://codeload.github.com/Yiling-J/go-cache-benchmark-plus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248329596,"owners_count":21085565,"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-11-07T04:10:06.734Z","updated_at":"2025-04-11T02:31:34.580Z","avatar_url":"https://github.com/Yiling-J.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Cache comparison benchmark for Go\n\nThis benchmark compares throughput and hit ratios of different cache packages. The benchmark is original used in [Theine](https://github.com/Yiling-J/theine-go).\n\nFeel free to create PR if you want to include your cache package, or open issue/discussion if you have question/requirement.\n\n\n## throughput\n\nThroughput benchmark uses Go parallel benchmark, you can run it with:\n```\nmake bench-throughput\n```\n\nOr\n\n```\ngo test -bench=. -run=^$ -benchmem\n```\n\n\n## hit ratios\n\nhit ratio benchmarks use several widely adopted trace files:\n\n| Name     | Source                                           |\n|----------|--------------------------------------------------|\n| DS1      | Authors of the ARC algorithm                     |\n| S3       | Authors of the ARC algorithm                     |\n| SCARAB1H | https://github.com/ben-manes/caffeine/issues/106 |\n| META     | cachelib shared Meta [trace](https://cachelib.org/docs/Cache_Library_User_Guides/Cachebench_FB_HW_eval/#running-cachebench-with-the-trace-workload)                       |\n\n\u003e The Meta trace file is too larger(\u003e 1gb even gzipped), please download it from the link and put it in trace directory.\n\nyou can run it with:\n\n```\nmake bench-ratios\n```\n\nYou will see progress indicator(each dot represents 100k requests) when benchmark is running, result plots will be **generated automatically** in *results* directory after bench done.\n\nBench results will be cached in *results* directory with name: `{client name}-{bench name}.data`, this can make benchmark much faster when you are testing your package and run benchmark frequently. Just delete the file if you want to invalid cache.\n\n## throughput result\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/Yiling-J/go-cache-benchmark-plus\ncpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz\nBenchmarkGetParallel/theine-12          40604346                28.72 ns/op            0 B/op          0 allocs/op\nBenchmarkGetParallel/ristretto-12       60166238                23.50 ns/op           17 B/op          1 allocs/op\nBenchmarkSetParallel/theine-12          16067138                67.55 ns/op            0 B/op          0 allocs/op\nBenchmarkSetParallel/ristretto-12       12830085                79.30 ns/op          116 B/op          3 allocs/op\nBenchmarkZipfParallel/theine-12         15908767                70.07 ns/op            0 B/op          0 allocs/op\nBenchmarkZipfParallel/ristretto-12      17200935                80.05 ns/op          100 B/op          3 allocs/op\n```\n\n## hit ratios result\n\n**zipf**\n\n![hit ratios](results/zipf.png)\n**search**\n\nThis trace is described as \"disk read accesses initiated by a large commercial search engine in response to various web search requests.\"\n\n![hit ratios](results/s3.png)\n**database**\n\nThis trace is described as \"a database server running at a commercial site running an ERP application on top of a commercial database.\"\n\n![hit ratios](results/ds1.png)\n**Scarabresearch database trace**\n\nScarabresearch 1 hour database trace from this [issue](https://github.com/ben-manes/caffeine/issues/106)\n\n![hit ratios](results/scarab1h.png)\n**Meta anonymized trace**\n\nMeta shared anonymized trace captured from large scale production cache services, from [cachelib](https://cachelib.org/docs/Cache_Library_User_Guides/Cachebench_FB_HW_eval/#running-cachebench-with-the-trace-workload)\n\n![hit ratios](results/meta.png)\n\n## add your cache package\nFirst thing you need to do is wrapping your package to match `Client` interface:\n```Go\ntype Style struct {\n\tColor color.Color\n\tShape draw.GlyphDrawer\n}\n\ntype Client[K comparable, V any] interface {\n\tInit(cap int)\n\tGet(key K) (V, bool)\n\tSet(key K, value V)\n\tName() string\n\tStyle() *Style\n\tClose()\n}\n```\nStyle is used to plot hit ratio results. if you only want throughput results, you can leave it empty. You can find more examples in *clients* directory.\n\nThen you can add your client to either [throughput](https://github.com/Yiling-J/go-cache-benchmark-plus/blob/main/benchmark_test.go) or [hit ratio](https://github.com/Yiling-J/go-cache-benchmark-plus/blob/main/hr/main.go) benchmarks. Just update the `benchClients` var and add yours. You can include your plot results in PR, but I will generate them again and update README after merged.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiling-j%2Fgo-cache-benchmark-plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiling-j%2Fgo-cache-benchmark-plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiling-j%2Fgo-cache-benchmark-plus/lists"}