{"id":17531007,"url":"https://github.com/danp/trace2sqlite","last_synced_at":"2025-08-23T19:20:55.323Z","repository":{"id":152741609,"uuid":"609999136","full_name":"danp/trace2sqlite","owner":"danp","description":"Convert Go execution traces to SQLite databases.","archived":false,"fork":false,"pushed_at":"2023-03-05T21:27:38.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-17T18:57:01.485Z","etag":null,"topics":["golang","sqlite","tracing"],"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/danp.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,"zenodo":null}},"created_at":"2023-03-05T21:09:28.000Z","updated_at":"2023-03-13T03:35:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"2e442c0f-78b5-4499-b583-d3e10ddd6b84","html_url":"https://github.com/danp/trace2sqlite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danp/trace2sqlite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Ftrace2sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Ftrace2sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Ftrace2sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Ftrace2sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danp","download_url":"https://codeload.github.com/danp/trace2sqlite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danp%2Ftrace2sqlite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271766309,"owners_count":24817540,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["golang","sqlite","tracing"],"created_at":"2024-10-20T17:14:28.899Z","updated_at":"2025-08-23T19:20:55.313Z","avatar_url":"https://github.com/danp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# trace2sqlite\n\nConvert Go execution traces to SQLite databases.\n\n## Usage\n\nCreate `trace.db` from `my.trace`:\n\n``` sh\ntrace2sqlite trace.db my.trace\n```\n\n## Quick tour\n\nUsing a database generated from [this gotraceui test trace](https://github.com/dominikh/gotraceui/blob/dfa752a689cdbaa1f7d648546e5f1715320439c9/trace/testdata/stress_1_20_good).\n\n```\n$ sqlite3 trace.db\nsqlite\u003e .schema\nCREATE TABLE pcs (pc integer primary key, file text, line integer, fn text);\nCREATE TABLE stacks (id integer, depth integer, pc integer, primary key(id, depth));\nCREATE TABLE events (id integer primary key, ts integer, type text, p integer, g integer, args text, link integer, stack_id integer);\nsqlite\u003e select * from events limit 10;\n┌────┬──────┬─────────────┬───┬────┬────────────────────┬──────┬──────────┐\n│ id │  ts  │    type     │ p │ g  │        args        │ link │ stack_id │\n├────┼──────┼─────────────┼───┼────┼────────────────────┼──────┼──────────┤\n│ 0  │ 0    │ GoCreate    │ 1 │ 0  │ {\"g\":1,\"stack\":2}  │      │ 1        │\n│ 1  │ 164  │ GoWaiting   │ 1 │ 1  │ {\"g\":1}            │      │          │\n│ 2  │ 2235 │ GoCreate    │ 1 │ 0  │ {\"g\":17,\"stack\":3} │      │ 1        │\n│ 3  │ 2290 │ GoInSyscall │ 1 │ 17 │ {\"g\":17}           │      │          │\n│ 4  │ 4341 │ GoCreate    │ 1 │ 0  │ {\"g\":2,\"stack\":4}  │      │ 1        │\n│ 5  │ 4396 │ GoWaiting   │ 1 │ 2  │ {\"g\":2}            │      │          │\n│ 6  │ 6357 │ GoCreate    │ 1 │ 0  │ {\"g\":3,\"stack\":5}  │      │ 1        │\n│ 7  │ 6393 │ GoWaiting   │ 1 │ 3  │ {\"g\":3}            │ 580  │          │\n│ 8  │ 8280 │ GoCreate    │ 1 │ 0  │ {\"g\":4,\"stack\":6}  │      │ 1        │\n│ 9  │ 8299 │ GoWaiting   │ 1 │ 4  │ {\"g\":4}            │ 348  │          │\n└────┴──────┴─────────────┴───┴────┴────────────────────┴──────┴──────────┘\nsqlite\u003e select type, count(*) from events group by 1 order by 2 desc limit 10;\n┌──────────────┬──────────┐\n│     type     │ count(*) │\n├──────────────┼──────────┤\n│ ProcStart    │ 52271    │\n│ ProcStop     │ 52270    │\n│ GoStart      │ 23728    │\n│ GoSched      │ 22131    │\n│ GoUnblock    │ 7813     │\n│ GoBlock      │ 7009     │\n│ GoStartLabel │ 6539     │\n│ HeapAlloc    │ 1438     │\n│ Gomaxprocs   │ 673      │\n│ GCSTWStart   │ 670      │\n└──────────────┴──────────┘\nsqlite\u003e select * from pcs limit 10;\n┌─────────┬─────────────────────────────────────────────┬──────┬────────────────────────────┐\n│   pc    │                    file                     │ line │             fn             │\n├─────────┼─────────────────────────────────────────────┼──────┼────────────────────────────┤\n│ 0       │                                             │ 0    │                            │\n│ 4223036 │ /home/dominikh/prj/go/src/runtime/chan.go   │ 145  │ runtime.chansend1          │\n│ 4226455 │ /home/dominikh/prj/go/src/runtime/chan.go   │ 442  │ runtime.chanrecv1          │\n│ 4230932 │ /home/dominikh/prj/go/src/runtime/debug.go  │ 33   │ runtime.GOMAXPROCS         │\n│ 4252879 │ /home/dominikh/prj/go/src/runtime/malloc.go │ 932  │ runtime.mallocgc           │\n│ 4253942 │ /home/dominikh/prj/go/src/runtime/malloc.go │ 1053 │ runtime.mallocgc           │\n│ 4254441 │ /home/dominikh/prj/go/src/runtime/malloc.go │ 1150 │ runtime.mallocgc           │\n│ 4254567 │ /home/dominikh/prj/go/src/runtime/malloc.go │ 1171 │ runtime.mallocgc           │\n│ 4254582 │ /home/dominikh/prj/go/src/runtime/malloc.go │ 1172 │ runtime.mallocgc           │\n│ 4254905 │ /home/dominikh/prj/go/src/runtime/malloc.go │ 1217 │ runtime.deductAssistCredit │\n└─────────┴─────────────────────────────────────────────┴──────┴────────────────────────────┘\nsqlite\u003e select * from stacks limit 10;\n┌────┬───────┬─────────┐\n│ id │ depth │   pc    │\n├────┼───────┼─────────┤\n│ 80 │ 0     │ 4696772 │\n│ 80 │ 1     │ 4785133 │\n│ 80 │ 2     │ 4785109 │\n│ 80 │ 3     │ 4784469 │\n│ 80 │ 4     │ 4800349 │\n│ 80 │ 5     │ 4800341 │\n│ 80 │ 6     │ 4772089 │\n│ 80 │ 7     │ 5559190 │\n│ 80 │ 8     │ 5559150 │\n│ 80 │ 9     │ 5565332 │\n└────┴───────┴─────────┘\nsqlite\u003e with top_go_create_stacks as (select stack_id, count(*) from events where type='GoCreate' group by 1 order by 2 desc) select * from top_go_create_stacks join stacks on (stack_id=id), pcs on (stacks.pc=pcs.pc and depth=0);\n┌──────────┬──────────┬─────┬───────┬─────────┬─────────┬───────────────────────────────────────────────────────┬──────┬────────────────────────────────────┐\n│ stack_id │ count(*) │ id  │ depth │   pc    │   pc    │                         file                          │ line │                 fn                 │\n├──────────┼──────────┼─────┼───────┼─────────┼─────────┼───────────────────────────────────────────────────────┼──────┼────────────────────────────────────┤\n│ 63       │ 10       │ 63  │ 0     │ 5679942 │ 5679942 │ /home/dominikh/prj/go/src/runtime/trace/trace_test.go │ 260  │ runtime/trace_test.TestTraceStress │\n│ 23       │ 10       │ 23  │ 0     │ 4308676 │ 4308676 │ /home/dominikh/prj/go/src/runtime/mgc.go              │ 1199 │ runtime.gcBgMarkStartWorkers       │\n│ 1        │ 9        │ 1   │ 0     │ 5679707 │ 5679707 │ /home/dominikh/prj/go/src/runtime/trace/trace_test.go │ 226  │ runtime/trace_test.TestTraceStress │\n│ 107      │ 1        │ 107 │ 0     │ 5680836 │ 5680836 │ /home/dominikh/prj/go/src/runtime/trace/trace_test.go │ 313  │ runtime/trace_test.TestTraceStress │\n│ 86       │ 1        │ 86  │ 0     │ 5680604 │ 5680604 │ /home/dominikh/prj/go/src/runtime/trace/trace_test.go │ 295  │ runtime/trace_test.TestTraceStress │\n│ 67       │ 1        │ 67  │ 0     │ 5680298 │ 5680298 │ /home/dominikh/prj/go/src/runtime/trace/trace_test.go │ 283  │ runtime/trace_test.TestTraceStress │\n│ 65       │ 1        │ 65  │ 0     │ 5680218 │ 5680218 │ /home/dominikh/prj/go/src/runtime/trace/trace_test.go │ 274  │ runtime/trace_test.TestTraceStress │\n│ 18       │ 1        │ 18  │ 0     │ 5679882 │ 5679882 │ /home/dominikh/prj/go/src/runtime/trace/trace_test.go │ 233  │ runtime/trace_test.TestTraceStress │\n│ 13       │ 1        │ 13  │ 0     │ 5025742 │ 5025742 │ /home/dominikh/prj/go/src/runtime/trace/trace.go      │ 128  │ runtime/trace.Start                │\n└──────────┴──────────┴─────┴───────┴─────────┴─────────┴───────────────────────────────────────────────────────┴──────┴────────────────────────────────────┘\n```\n\n## Fun queries\n\n### FlameScope / perf\n\nGenerate data suitable for [FlameScope](https://github.com/Netflix/flamescope) (inspired by [traceutils](https://github.com/felixge/traceutils/#flamescope)) with:\n\n``` shell\nsqlite3 -tabs trace.db \\\n  \"select 'go 0 [0] ' || printf('%f', ts/1e9) || ': cpu-clock:' || x'0a' || (select group_concat(x'09' || printf('%x %s (go)', stacks.pc, pcs.fn), x'0a') from stacks join pcs on (pcs.pc=stacks.pc) where stacks.id=stack_id) from events where type='CPUSample' order by id\" \\\n  \u003e trace.perf\n```\n\nThen get trace.perf where FlameScope can read it.\n\nExample from encoding/json benchmarks:\n\n![](https://user-images.githubusercontent.com/2182/222985527-2bf892f0-dc98-498d-a07f-cea359ea6142.png)\n\n## Thanks\n\nThe bulk of the work in parsing and making traces more logically useful comes from the [gotraceui](https://github.com/dominikh/gotraceui) project.\nThis project really just puts the result of that into SQLite.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanp%2Ftrace2sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanp%2Ftrace2sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanp%2Ftrace2sqlite/lists"}