Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/convert: reduce allocation #1886

Merged
merged 5 commits into from
Jul 28, 2023
Merged

pkg/convert: reduce allocation #1886

merged 5 commits into from
Jul 28, 2023

Conversation

zdyj3170101136
Copy link
Contributor

Why?

in my company, the jfr to pprof allocate too much times of objects, and those cost most of cpu.
this is the allocation memory profile of my parca-agent:
image

What?

this pr reduce 99% percent of memory allocation and reduce 80% of cpu cost in jfr to pprof.
image

How?

1, cache parseArgs and getFileName and getPid and dimensions.
2, reuse slice as more as we can.
3, use bytes.buffer to build function key, and use unsafe string in map search to avoid memory allocation.
4, use unsafe string sample key in map search, only create locations when new sample created.
5, use uint64 as location key to avoid int to string convert.

@zdyj3170101136 zdyj3170101136 requested a review from a team as a code owner July 27, 2023 11:00
Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

pkg/convert/jfr.go Outdated Show resolved Hide resolved
@brancz
Copy link
Member

brancz commented Jul 28, 2023

Nice work!!

@brancz brancz merged commit 98ab95e into parca-dev:main Jul 28, 2023
22 checks passed
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.

None yet

2 participants