{"id":13616702,"url":"https://github.com/google/slowjam","last_synced_at":"2025-04-14T03:31:19.552Z","repository":{"id":53076155,"uuid":"258326981","full_name":"google/slowjam","owner":"google","description":"SlowJam: latency profiler for Go programs","archived":false,"fork":false,"pushed_at":"2025-03-24T21:33:34.000Z","size":4717,"stargazers_count":249,"open_issues_count":6,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-08T20:07:46.307Z","etag":null,"topics":["analysis","golang","performance","profiling"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2020-04-23T20:49:00.000Z","updated_at":"2025-03-26T08:24:03.000Z","dependencies_parsed_at":"2024-01-13T15:20:49.632Z","dependency_job_id":"9b3f8e69-969c-43f5-abf3-75b30603bdd7","html_url":"https://github.com/google/slowjam","commit_stats":{"total_commits":32,"total_committers":8,"mean_commits":4.0,"dds":0.46875,"last_synced_commit":"18c9e8081dde2dd15d377bd9e79502ffa37894ca"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fslowjam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fslowjam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fslowjam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fslowjam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/slowjam/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248815520,"owners_count":21165939,"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":["analysis","golang","performance","profiling"],"created_at":"2024-08-01T20:01:32.165Z","updated_at":"2025-04-14T03:31:19.543Z","avatar_url":"https://github.com/google.png","language":"HTML","readme":"# ![logo](docs/slowjam.png)\n\n`NOTE: This is not an officially supported Google product`\n\nSlowJam is a two-part tool for analyzing function latency within Go programs.\n\n* `stacklog` - a library for sampling the stack of a Go program during runtime\n* `slowjam` - a binary for visualizing the latency from recorded stack samples\n\nSlowJam excels at finding optimization opportunities in automation workflows, as they tend to block on command-line execution or remote resources, rather than CPU resources. This tool was created from a hackathon hosted by Google's Container DevEx  team, with the goal of finding ways to reduce the start-up latency within [minikube](http://minikube.sigs.k8s.io/).\n\n## Features\n\n* Hybrid Gantt/Flamegraph visualizations\n* Automated sampling of all function calls\n* Trivial to integrate\n* Zero overhead when inactive, \u003c1% overhead when activated\n\n## Screenshot\n\n![screenshot](docs/screenshot.png)\n\nSee [example/minikube.html](example/minikube.html) for example output.\n\n## Requirements\n\n* Go v1.21 or higher\n\n## Usage\n\n### Recording\n\nAdd this to the `main()` method of your program, or within any other function you wish to record stack samples for:\n\n\n```go\ns := stacklog.MustStartFromEnv(\"STACKLOG_PATH\")\ndefer s.Stop()\n```\n\nThis will invoke the stack sampler if the `STACKLOG_PATH` environment is set, and will write the stack samples to that location. If you prefer greater control over the configuration, you can also use:\n\n```go\ncfg := stacklog.Config{\n  Path: \"out.slog\",\n  Poll: 100 * time.Millisecond,\n\tQuiet: true\n}\n  \ns, err := stacklog.Start(cfg)\ndefer s.Stop()\n```\n\nBy default, this will poll the stack every 125ms.\n\n## Visualization\n\nInstall slowjam:\n\n`go install github.com/google/slowjam/cmd/slowjam@latest`\n\nAnalyze a stacklog using the interactive webserver:\n\n```shell\nslowjam --http localhost:8080 /path/to/stack.slog\n```\n\nTo output a Gantt/Flamegraph chart to `out.html`:\n\n```shell\nslowjam --html out.html /path/to/stack.slog\n```\n\nTo output a text summary to `out.txt`:\n\n```shell\nslowjam --html out.txt /path/to/stack.slog\n```\n\n## Real World Examples\n\n1. Integrating SlowJam with Go binary.\n\nHere's an example PR to integrate SlowJam analysis into minikube: [minikube#8329](https://github.com/kubernetes/minikube/pull/8329). \n\nWith this PR, anyone can generate a slowjam profile:\n\n`env STACKLOG_PATH=minikube.slog minikube start`\n\nYou can then convert the data to various forms, as per the examples/ directory:\n\n`slowjam --goroutines 1 --pprof example/minikube.pprof example/minikube.slog`\n`slowjam --html example/minikube.html example/minikube.slog`\n\nWhat minikube contributors discovered with these results were:\n\n* Functions which could obviously be run in parallel were executed in serial.\n* Functions which we expected to be fast (\u003c1s) were slow (10s). In many cases we were able to remove or rewrite these functions to do less work.\n\nThe net result was a 2.5X reduction in start-up latency: from ~66 seconds to ~26 seconds.\n\n2. Analyzing an integrated Go binary in Kubernetes cluster.\n\nHere's an pod config to analyze a Go binary running on a Kubernetes cluster: [Pod SlowJam Profile](https://github.com/GoogleContainerTools/kaniko/blob/master/examples/pod-build-profile.yaml)\n\nIn this Pod Config, \n1. Set the environment variable `STACKLOG_PATH` to  to generate slowjam profile.\n2. Copy the generated stack samples to a accessible location in [Container Lifecyle hooks](https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#define-poststart-and-prestop-handlers) `pre-stop`.\n\n\n","funding_links":[],"categories":["3. Application","HTML"],"sub_categories":["Golang"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fslowjam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fslowjam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fslowjam/lists"}