What is The compiler's -json optimization logging

189 views
Skip to first unread message

Falco Wockenfuß

unread,
Sep 4, 2020, 4:17:04 PM9/4/20
to golang-nuts
Hi,

sorry if this is a dumb question, but the Release Notes for go 1.15 have the Note:
The compiler's -json optimization logging now reports large (>= 128 byte) copies and includes explanations of escape analysis decisions. 

But I didn't find anything about "-json" as a flag for go build or similar and google dind't yield anything for go compiler json optimization logging or similar.

Can anyone clarify what this json optimiziation logging is and how it can be used/invoked ? 

Ian Lance Taylor

unread,
Sep 4, 2020, 4:28:02 PM9/4/20
to Falco Wockenfuß, David Chase, golang-nuts
[ + drchase ]
It does seem that this option should be mentioned in cmd/compile/doc.go.

To use it, try "go build -gcflags=json=0,/my/json/dir".

Ian

Peter Weinberger (温博格)

unread,
Sep 4, 2020, 4:52:44 PM9/4/20
to Ian Lance Taylor, Falco Wockenfuß, David Chase, golang-nuts
And gopls will compute them as diagnostics. For instance, if using vscode and gopls, then in setting.json:
"gopls": {
  "codelens": {
    "gc_details": true,
  }
}

and a clickable 'Toggle gc annotation details' should appear just above the package statement.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVB-pJUf6AxSDsAqoEJbzBm_h7Qt4%2BTJyUg0mE63RyDcQ%40mail.gmail.com.

David Chase

unread,
Sep 4, 2020, 10:48:26 PM9/4/20
to Peter Weinberger (温博格), Ian Lance Taylor, Falco Wockenfuß, golang-nuts
There is also a command-line proof-of-concept that combines it with profiling information to show you only the missed/unabled optimizations that are also hot spots in the profile.


There's a lot of checks and things that can't be optimized away, but very few have any effect on a typical program's performance.
Reply all
Reply to author
Forward
0 new messages