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

lhef: reduce number of allocs in Decoder #938

Merged
merged 3 commits into from
May 10, 2022

Conversation

dolmen
Copy link
Contributor

@dolmen dolmen commented Apr 27, 2022

In the lhef.Decoder, allocate slices using sliced bigger chunks in order to reduce the number of allocations.

Example:

a := make([]int32, n)
b := make([]int32, n)
c := make([]int32, n)

is replaced with:

n32 := make([]int32, 3*n)
a := n32[:n:n]
b := n32[n : 2*n : 2*n]
b := n32[2*n:]

dolmen added 3 commits April 27, 2022 22:49
Allocate arrays in one block in lhef.NewDecoder.
When decoding an event block, allocate memory for slices in bigger
blocks to reduce the number of memory allocations.
Copy link
Member

@sbinet sbinet left a comment

Choose a reason for hiding this comment

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

LGTM

thanks for improving this. (it feels like good old FORTRAN column blocks, but hey :P)

@sbinet sbinet merged commit 1992369 into go-hep:main May 10, 2022
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