Skip to content

WIP: add metadata package summary model#1866

Draft
luoliwoshang wants to merge 6 commits into
xgo-dev:mainfrom
luoliwoshang:wip/metadata-global-summary
Draft

WIP: add metadata package summary model#1866
luoliwoshang wants to merge 6 commits into
xgo-dev:mainfrom
luoliwoshang:wip/metadata-global-summary

Conversation

@luoliwoshang
Copy link
Copy Markdown
Contributor

Summary

  • add internal/metadata PackageMeta model with Symbol/Name typed references
  • add LLPS binary encode/decode and stable formatted output for golden tests
  • add GlobalSummary merging with local-to-global Symbol/Name remapping

Test Plan

  • go test -count=1 ./internal/metadata

Notes

  • WIP: not yet integrated with build cache, cl/ssa metadata production, or DCE consumption.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 20, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 77.72622% with 192 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/metadata/decode.go 48.54% 53 Missing and 53 partials ⚠️
internal/metadata/global_summary.go 77.38% 24 Missing and 21 partials ⚠️
internal/metadata/meta.go 67.56% 14 Missing and 10 partials ⚠️
internal/metadata/builder.go 84.84% 5 Missing and 5 partials ⚠️
internal/metadata/format.go 93.97% 3 Missing and 2 partials ⚠️
internal/metadata/encode.go 98.79% 0 Missing and 1 partial ⚠️
ssa/abitype.go 98.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@luoliwoshang
Copy link
Copy Markdown
Contributor Author

Cache hit 下 .meta 读取 + 反序列化的临时观测结果如下。

当前统计口径是包命中缓存后执行 readMeta(paths.Meta) 的耗时,因此包含 .meta 文件 open/read 和 metadata.ReadMeta 反序列化,不包含 manifest 读取/解析、archive 检查或后续 cache-hit build 流程。

cache hit packages: 73
total meta read:    15.235 ms
avg per package:    208.7 us
min:                36.9 us
max:                981.2 us

最慢的几个包:

reflect                                             981.166 us
fmt                                                 886.542 us
os                                                  798.875 us
internal/runtime/maps                               687.667 us
sync/atomic                                         670.084 us
internal/runtime/math                               626.500 us
github.com/goplus/llgo/runtime/internal/runtime     463.708 us
internal/godebug                                    438.000 us
time                                                425.375 us
github.com/goplus/llgo/runtime/internal/clite/syscall 390.875 us

结论:这个 case 里当前 .meta 格式的读取 + 反序列化看起来不是主要瓶颈。73 个包总共约 15ms,单包基本在几十到几百微秒,最大不到 1ms。短期看不需要优先做 mmap/零拷贝这类复杂优化;更值得继续看 cache hit 后其他阶段的耗时。

@luoliwoshang
Copy link
Copy Markdown
Contributor Author

补充:上面这组数据来自本地运行 _demo/go/abimethod 这个 abiMethod 示例程序时的 cache hit 观测。

@luoliwoshang
Copy link
Copy Markdown
Contributor Author

补充一个更接近 CI 慢用例的观测:本地 test/std/net/http/cookiejar 这个 case 在 CI 上大约会跑 68s,因此更有代表性。

当前统计口径仍然是 cache hit 后执行 readMeta(paths.Meta) 的耗时,也就是 .meta 文件读取 + metadata.ReadMeta 反序列化,不包含 manifest 读取/解析、archive 检查或后续 cache-hit build 流程。

cache hits: 209
cache misses: 1
total meta read: 59.223 ms
avg per package: 283.363 us
min: 38.500 us
max: 2.908 ms
p50: 150.666 us
p90: 701.916 us
p95: 936.333 us
p99: 1.283 ms

最慢的几个 cache hit:

net/http        2.907834 ms
time            1.528417 ms
go/ast          1.462417 ms
crypto/tls      1.283375 ms
encoding/asn1   1.172792 ms
net             1.095833 ms
os/exec         1.020917 ms
reflect         1.020583 ms
encoding/json   1.011542 ms
fmt             994.375 us

结论:即使用这个比较大的 std/net/http/cookiejar case,.meta 读取 + 反序列化总耗时也只有约 59ms,占 68s 级别总耗时很小。当前瓶颈基本不在 package summary 的读取反序列化上。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants