{"id":15282536,"url":"https://github.com/jschwinger233/gofuncgraph","last_synced_at":"2026-04-01T17:44:45.495Z","repository":{"id":41529366,"uuid":"480296440","full_name":"jschwinger233/gofuncgraph","owner":"jschwinger233","description":"bpf(2)-based ftrace(1)-like function graph tracer for golang processes.","archived":false,"fork":false,"pushed_at":"2023-08-18T09:04:26.000Z","size":6607,"stargazers_count":30,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-16T10:43:21.958Z","etag":null,"topics":["bpf","debugger","ebpf","golang","tracing"],"latest_commit_sha":null,"homepage":"","language":"C","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/jschwinger233.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}},"created_at":"2022-04-11T08:42:40.000Z","updated_at":"2025-07-31T13:28:47.000Z","dependencies_parsed_at":"2024-01-27T04:57:38.098Z","dependency_job_id":null,"html_url":"https://github.com/jschwinger233/gofuncgraph","commit_stats":null,"previous_names":["jschwinger233/ufuncgraph"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/jschwinger233/gofuncgraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jschwinger233%2Fgofuncgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jschwinger233%2Fgofuncgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jschwinger233%2Fgofuncgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jschwinger233%2Fgofuncgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jschwinger233","download_url":"https://codeload.github.com/jschwinger233/gofuncgraph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jschwinger233%2Fgofuncgraph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: 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":["bpf","debugger","ebpf","golang","tracing"],"created_at":"2024-09-30T14:26:44.311Z","updated_at":"2026-04-01T17:44:45.476Z","avatar_url":"https://github.com/jschwinger233.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gofuncgraph\n\nbpf(2)-based ftrace(1)-like function graph tracer for Golang processes.\n\nLimits:\n\n1. `.symtab` ELF section and `.(z)debug_info` is required;\n2. Running on x86-64 little-endian Linux only;\n4. Kernel version has to support bpf(2) and uprobe;\n\n\n# Usage \u0026 Example\n\n## Issue Description\n\nLet's debug a demo project under the [exmaple/](https://github.com/jschwinger233/gofuncgraph/tree/main/example)!\n\nThere is a simple and small HTTP server binding 8080 port, and we can access its `/bar` uri:\n\n```shell\n$ curl localhost:8080/bar\nHello, \"/bar\"\n```\n\nThe problem here is, this HTTP API doesn't seem stable in terms of performance. Sometime the latency even goes as long as nearly one second:\n\n```\n$ time curl localhost:8080/bar\nHello, \"/bar\"\nreal\t0m0.714s\nuser\t0m0.005s\nsys\t0m0.000s\n```\n\nLet's investigate this issue using `gofuncgraph`.\n\n## Investigation using gofuncgraph\n\nWe must find the HTTP handler for `/bar`, which is `handleBar` function. This requires some basic source code reading, luckily that's the only information we need from source.\n\n### First run\n\nLet's confirm it's the HTTP handler responsible for slow reply:\n\n```\n$ sudo gofuncgraph --uprobe-wildcards '*handleBar' ./example '*handleBar'\nfound 3 uprobes, large number of uprobes (\u003e1000) need long time for attaching and detaching, continue? [Y/n]\ny\nINFO[0001] start tracing\n\n18 15:48:05.4114           main.handleBar() { net/http.HandlerFunc.ServeHTTP+47 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:2122\n18 15:48:05.9347 000.5233  } main.handleBar+192 /home/gray/src/github.com/jschwinger233/gofuncgraph/example/main.go:20\n```\n\nThe tracing command has the same tailing argument `*handleBar` as `--uprobe-wildcards`, I'll explain that later.\n\n`*handleBar` is a wildcard to match the full symbol `main.handleBar`. We can always specify a full symbol rather than a wildcard, I was just too lazy to type.\n\nThe output showed the function `main.handleBar` returned in 0.5 second, which confirmed it was this function causing the unexpected latency.\n\n### Second run\n\nIt is reasonable to suspect `net/http` to have caused latency, so let's measure the time cost for `net/http`.\n\n```\n$ sudo gofuncgraph --uprobe-wildcards 'net/http*' ./example '*handleBar'\nfound 1637 uprobes, large number of uprobes (\u003e1000) need long time for attaching and detaching, continue? [Y/n]\ny\nINFO[0001] start tracing\n\n18 16:01:17.0181           main.handleBar() { net/http.HandlerFunc.ServeHTTP+47 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:2122\n18 16:01:17.7443             net/http.(*response).Write() { fmt.Fprintf+155 /home/gray/.gvm/gos/go1.20/src/fmt/print.go:225\n18 16:01:17.7443               net/http.(*response).write() { net/http.(*response).Write+48 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1594\n18 16:01:17.7443                 net/http.(*conn).hijacked() { net/http.(*response).write+105 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1603\n18 16:01:17.7443                   net/http.(*conn).hijacked.func1() { net/http.(*conn).hijacked+167 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:312\n18 16:01:17.7443 000.0000          } net/http.(*conn).hijacked.func1+47 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:311\n18 16:01:17.7443 000.0000        } net/http.(*conn).hijacked+181 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:312\n18 16:01:17.7443                 net/http.(*response).WriteHeader() { net/http.(*response).write+345 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1622\n18 16:01:17.7444                   net/http.(*conn).hijacked() { net/http.(*response).WriteHeader+69 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1136\n18 16:01:17.7444                     net/http.(*conn).hijacked.func1() { net/http.(*conn).hijacked+167 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:312\n18 16:01:17.7444 000.0000            } net/http.(*conn).hijacked.func1+47 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:311\n18 16:01:17.7444 000.0000          } net/http.(*conn).hijacked+181 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:312\n18 16:01:17.7444 000.0000        } net/http.(*response).WriteHeader+1786 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1183\n18 16:01:17.7444 000.0001      } net/http.(*response).write+557 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1636\n18 16:01:17.7444 000.0001    } net/http.(*response).Write+57 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1594\n18 16:01:17.7444 000.7263  } main.handleBar+192 /home/gray/src/github.com/jschwinger233/gofuncgraph/example/main.go:20\n```\n\nThere were multiple blocks displayed, in which only the one for `main.handleBar` is of our interests, as I showed above.\n\nThe `--uprobe-wildcards` in the command was changed to `net/http*`, so we can see the their invocation situations.\n\nGenerally, the wildcard in the tailing arguments are the ones we really care, let's call them \"target functions\"; on the other hand, `--uprobe-wildcards` means **we want to see how these functions are called by target functions**.\n\nGetting back to the command, `gofuncgraph --uprobe-wildcards 'net/http*' ./example '*handleBar'` indicates that **we want to see how those net/http functions are called inside the main.handleBar**.\n\nLook at the output, `main.handleBar` cost 0.7s, while `net/http.(*response).Write` cost less then 0.0001s. The problem isn't on the golang's http library!\n\n### Third run\n\nWe'll have to look at the assembly code of `main.handleBar`:\n\n```\n(gdb) disas/m 'main.handleBar'\nDump of assembler code for function main.handleBar:\n17\tfunc handleBar(w http.ResponseWriter, r *http.Request) {\n   0x00000000006178c0 \u003c+0\u003e:\tcmp    0x10(%r14),%rsp\n   0x00000000006178c4 \u003c+4\u003e:\tjbe    0x617981 \u003cmain.handleBar+193\u003e\n   0x00000000006178ca \u003c+10\u003e:\tsub    $0x58,%rsp\n   0x00000000006178ce \u003c+14\u003e:\tmov    %rbp,0x50(%rsp)\n   0x00000000006178d3 \u003c+19\u003e:\tlea    0x50(%rsp),%rbp\n   0x00000000006178d8 \u003c+24\u003e:\tmov    %rax,0x60(%rsp)\n   0x00000000006178dd \u003c+29\u003e:\tmov    %rcx,0x70(%rsp)\n   0x0000000000617981 \u003c+193\u003e:\tmov    %rax,0x8(%rsp)\n   0x0000000000617986 \u003c+198\u003e:\tmov    %rbx,0x10(%rsp)\n   0x000000000061798b \u003c+203\u003e:\tmov    %rcx,0x18(%rsp)\n   0x0000000000617990 \u003c+208\u003e:\tcall   0x4645e0 \u003cruntime.morestack_noctxt\u003e\n   0x0000000000617995 \u003c+213\u003e:\tmov    0x8(%rsp),%rax\n   0x000000000061799a \u003c+218\u003e:\tmov    0x10(%rsp),%rbx\n   0x000000000061799f \u003c+223\u003e:\tmov    0x18(%rsp),%rcx\n   0x00000000006179a4 \u003c+228\u003e:\tjmp    0x6178c0 \u003cmain.handleBar\u003e\n\n18\t\tlog.Debug(\"received request for /bar\")\n   0x00000000006178ec \u003c+44\u003e:\txor    %edi,%edi\n   0x00000000006178ee \u003c+46\u003e:\tmov    %rdi,%rsi\n   0x00000000006178f1 \u003c+49\u003e:\tlea    0x67bdc(%rip),%rax        # 0x67f4d4\n   0x00000000006178f8 \u003c+56\u003e:\tmov    $0x19,%ebx\n   0x00000000006178fd \u003c+61\u003e:\txor    %ecx,%ecx\n   0x00000000006178ff \u003c+63\u003e:\tnop\n   0x0000000000617900 \u003c+64\u003e:\tcall   0x6177a0 \u003cgithub.com/jschwinger233/gofuncgraph/example/internal/log.Debug\u003e\n\n19\t\tfmt.Fprintf(w, \"Hello, %q\", html.EscapeString(r.URL.Path))\n```\n\nWe can tell from gdb's output that there is a `log.Debug` prior to net/http functions.\n\nLet's trace that suspicious log statement.\n\n```\n$ sudo gofuncgraph --uprobe-wildcards 'net/http*' --uprobe-wildcards '*gofuncgraph/example/internal/log*' ./example '*handleBar'\nfound 1639 uprobes, large number of uprobes (\u003e1000) need long time for attaching and detaching, continue? [Y/n]\ny\nINFO[0002] start tracing\n\n18 16:21:55.2553           main.handleBar() { net/http.HandlerFunc.ServeHTTP+47 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:2122\n18 16:21:55.2553             github.com/jschwinger233/gofuncgraph/example/internal/log.Debug() { main.handleBar+69 /home/gray/src/github.com/jschwinger233/gofuncgraph/example/main.go:18\n18 16:21:55.6098 000.3545    } github.com/jschwinger233/gofuncgraph/example/internal/log.Debug+58 /home/gray/src/github.com/jschwinger233/gofuncgraph/example/internal/log/log.go:11\n18 16:21:55.6098             net/http.(*response).Write() { fmt.Fprintf+155 /home/gray/.gvm/gos/go1.20/src/fmt/print.go:225\n18 16:21:55.6098               net/http.(*response).write() { net/http.(*response).Write+48 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1594\n18 16:21:55.6098                 net/http.(*conn).hijacked() { net/http.(*response).write+105 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1603\n18 16:21:55.6098                   net/http.(*conn).hijacked.func1() { net/http.(*conn).hijacked+167 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:312\n18 16:21:55.6099 000.0000          } net/http.(*conn).hijacked.func1+47 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:311\n18 16:21:55.6099 000.0000        } net/http.(*conn).hijacked+181 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:312\n18 16:21:55.6099                 net/http.(*response).WriteHeader() { net/http.(*response).write+345 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1622\n18 16:21:55.6099                   net/http.(*conn).hijacked() { net/http.(*response).WriteHeader+69 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1136\n18 16:21:55.6099                     net/http.(*conn).hijacked.func1() { net/http.(*conn).hijacked+167 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:312\n18 16:21:55.6099 000.0000            } net/http.(*conn).hijacked.func1+47 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:311\n18 16:21:55.6099 000.0000          } net/http.(*conn).hijacked+181 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:312\n18 16:21:55.6099 000.0000        } net/http.(*response).WriteHeader+1786 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1183\n18 16:21:55.6099 000.0000      } net/http.(*response).write+557 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1636\n18 16:21:55.6099 000.0001    } net/http.(*response).Write+57 /home/gray/.gvm/gos/go1.20/src/net/http/server.go:1594\n18 16:21:55.6099 000.3546  } main.handleBar+192 /home/gray/src/github.com/jschwinger233/gofuncgraph/example/main.go:20\n```\n\nNo need to replace the `net/http*`, jsut adding a new `--uprobe-wildcards '*gofuncgraph/example/internal/log*'` will do.\n\nThe output clearly showed it was this internal `log.Debug` dragging down the HTTP handle.\n\nAlright, I think that's enough to close this issue. If you inspect how `log.Debug` is implemented, you'll find a `time.Sleep()` inside to stimulate the real world random latency.\n\n# Use cases\n\n1. Wall time profiling;\n2. Execution flow observing;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjschwinger233%2Fgofuncgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjschwinger233%2Fgofuncgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjschwinger233%2Fgofuncgraph/lists"}