cmd/trace: generate jsontrace data in a streaming fashion

Update #21870

The Sys went down to 4.25G from 6.2G.

$ DEBUG_MEMORY_USAGE=1 go tool trace trace.out
2018/03/07 08:49:01 Parsing trace...
after parsing trace
 Alloc:	3385757184 Bytes
 Sys:	3661195896 Bytes
 HeapReleased:	0 Bytes
 HeapSys:	3488841728 Bytes
 HeapInUse:	3426516992 Bytes
 HeapAlloc:	3385757184 Bytes
Enter to continue...
2018/03/07 08:49:18 Splitting trace...
after spliting trace
 Alloc:	2352071904 Bytes
 Sys:	4243825464 Bytes
 HeapReleased:	0 Bytes
 HeapSys:	4025712640 Bytes
 HeapInUse:	2377703424 Bytes
 HeapAlloc:	2352071904 Bytes
Enter to continue...
after httpJsonTrace
 Alloc:	3228697832 Bytes
 Sys:	4250379064 Bytes
 HeapReleased:	0 Bytes
 HeapSys:	4025647104 Bytes
 HeapInUse:	3260014592 Bytes
 HeapAlloc:	3228697832 Bytes

Change-Id: I546f26bdbc68b1e58f1af1235a0e299dc0ff115e
Reviewed-on: https://go-review.googlesource.com/92375
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Hana Kim 2018-02-06 14:34:32 -05:00 committed by Hyang-Ah Hana Kim
parent 083f3957b8
commit ee465831ec
4 changed files with 217 additions and 108 deletions

View file

@ -120,19 +120,8 @@ func main() {
}
reportMemoryUsage("after parsing trace")
log.Print("Serializing trace...")
params := &traceParams{
parsed: res,
endTime: int64(1<<63 - 1),
}
data, err := generateTrace(params)
if err != nil {
dief("%v\n", err)
}
reportMemoryUsage("after generating trace")
log.Print("Splitting trace...")
ranges = splitTrace(data)
ranges = splitTrace(res)
reportMemoryUsage("after spliting trace")
addr := "http://" + ln.Addr().String()