{"id":37117392,"url":"https://github.com/fangwentong/gogctuner","last_synced_at":"2026-01-14T13:44:10.067Z","repository":{"id":236053437,"uuid":"743516056","full_name":"fangwentong/gogctuner","owner":"fangwentong","description":"port MaxRAMPercentage to Golang, adjust GC parameters(SetGCPercent/SetMemoryLimit) based on the target memory usage percentage, optimize the GC overhead of Go runtime.","archived":false,"fork":false,"pushed_at":"2024-11-25T08:13:56.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-25T09:20:45.701Z","etag":null,"topics":["cpu-optimization","gc","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/fangwentong.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":"2024-01-15T12:04:01.000Z","updated_at":"2024-11-25T08:12:20.000Z","dependencies_parsed_at":"2024-06-19T11:21:02.270Z","dependency_job_id":null,"html_url":"https://github.com/fangwentong/gogctuner","commit_stats":null,"previous_names":["fangwentong/gogctuner"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/fangwentong/gogctuner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fangwentong%2Fgogctuner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fangwentong%2Fgogctuner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fangwentong%2Fgogctuner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fangwentong%2Fgogctuner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fangwentong","download_url":"https://codeload.github.com/fangwentong/gogctuner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fangwentong%2Fgogctuner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28421914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["cpu-optimization","gc","golang"],"created_at":"2026-01-14T13:44:09.332Z","updated_at":"2026-01-14T13:44:10.052Z","avatar_url":"https://github.com/fangwentong.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gogctuner: GC Tuner for Go Applications\n\n`gogctuner` is a Go library designed to automatically adjust the garbage collection (GC) parameters to optimize CPU\nusage based on the target memory usage percentage.\n\n## How it works\n\n- **Pre Go1.19 Versions**: Utilizes a tuning strategy inspired\n  by [Uber's article](https://www.uber.com/blog/how-we-saved-70k-cores-across-30-mission-critical-services/), which\n  adjusts the `GOGC` parameter based on the live heap size and target memory limit.\n- **Go1.19 and Later**: Takes advantage of\n  the [soft memory limit feature](https://github.com/golang/proposal/blob/master/design/48409-soft-memory-limit.md)\n  introduced in Go 1.19, offering more granular control over GC behavior.\n\n## Features\n\n- **Memory Usage Based Tuning**: Automatically adjusts GC parameters to maintain a specified percentage of memory usage.\n- **Cross-Version Compatibility**: Compatible with Go versions below 1.19 and leverages the `SetMemoryLimit` features in\n  Go 1.19 and above.\n- **cgroups Support**: Works seamlessly with both cgroups and cgroupsv2 for enhanced resource management.\n- **Cross-OS Compatibility**: Ensures functionality across multiple operating systems.\n\n## Usage\n\n### Static Configuration\n\nUse static configuration by setting the `MaxRAMPercentage` at the initialization of your application:\n\n```go\npackage main\n\nimport (\n  \"github.com/fangwentong/gogctuner\"\n)\n\nfunc main() {\n  gogctuner.EnableGCTuner(\n    gogctuner.WithStaticConfig(gogctuner.Config{MaxRAMPercentage: 90}),\n  )\n  // Your application code here\n}\n\n```\n\n### Dynamic Configuration\n\nFor dynamic configuration that allows runtime updates, you can use a configurator:\n\n```go\npackage main\n\nimport (\n  \"github.com/fangwentong/gogctuner\"\n)\n\nfunc main() {\n  configurator := gogctuner.NewGcConfigurator()\n\n  // Integrate with your dynamic config implementation here:\n  conf := readFromYourConfigCenter(\"your_config_key\")\n  configurator.SetConfig(conf) // set initial config\n  // register config updates callback\n  registerConfigUpdateCallback(\"your_config_key\", func(conf gogctuner.Config) {\n    configurator.SetConfig(conf)\n  })\n\n  gogctuner.EnableGCTuner(\n    gogctuner.WithConfigurator(configurator),\n  )\n  // Your application code here\n}\n\n```\n\n### Reference\n\n- Golang GC Guide: https://tip.golang.org/doc/gc-guide\n- How We Saved 70K Cores Across 30 Mission-Critical Services (Large-Scale, Semi-Automated Go GC Tuning\n  @Uber): https://www.uber.com/blog/how-we-saved-70k-cores-across-30-mission-critical-services/\n- https://github.com/cch123/gogctuner\n- https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master/lib/cgroup\n\n### License\n\nThis project is licensed under the MIT License, see the [LICENSE](LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffangwentong%2Fgogctuner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffangwentong%2Fgogctuner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffangwentong%2Fgogctuner/lists"}