grafana / jfr-parser

Java Flight Recorder parser library written in Go.
Apache License 2.0
43 stars 16 forks source link

fix string and bytes convert use large memory #19

Closed ethan256 closed 1 year ago

ethan256 commented 1 year ago

jfr-parser consumes a lot of memory when processing large chunk files.

Part of the reason is that the read module has a lot of []byte and string interconversions.

ethan256 commented 1 year ago

@korniltsev

before benchmark:

goos: darwin
goarch: amd64
pkg: github.com/pyroscope-io/jfr-parser/parser
cpu: Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
BenchmarkParse-8          62      18903331 ns/op     6733755 B/op     169267 allocs/op

after benchmark:

goos: darwin
goarch: amd64
pkg: github.com/pyroscope-io/jfr-parser/parser
cpu: Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
=== RUN   BenchmarkParse
BenchmarkParse
BenchmarkParse-8              63          19262599 ns/op         6552339 B/op     106477 allocs/op
CLAassistant commented 1 year ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

zdyj3170101136 commented 1 year ago

you reuse the r.body, and unsafe convert it from []byte to string.

korniltsev commented 1 year ago

I will close this due to inactivity. This will be addressed by #22