Fix calculation error in deepInstanceSize of BlockBuilderStatus#11710
Merged
sopel39 merged 1 commit intotrinodb:masterfrom Apr 5, 2022
Merged
Fix calculation error in deepInstanceSize of BlockBuilderStatus#11710sopel39 merged 1 commit intotrinodb:masterfrom
sopel39 merged 1 commit intotrinodb:masterfrom
Conversation
sopel39
reviewed
Mar 31, 2022
Member
sopel39
left a comment
There was a problem hiding this comment.
it seems that this deepInstanceSize is only used in BlockBuilderStatus, which seems overly complicated for
Member
There was a problem hiding this comment.
it seems that this deepInstanceSize is only used in BlockBuilderStatus, which seems overly complicated to just compute instance size. Could we BlockBuilderStatus.INSTANCE_SIZE as we do in every other place, e.g:
ClassLayout.parseClass(BlockBuilderStatus.class).instanceSize() + PageBuilderStatus.INSTANCE_SIZE
7bd0b69 to
037bde0
Compare
Contributor
Author
I've already squashed the commits, PTAL :) |
sopel39
approved these changes
Apr 5, 2022
Member
|
merged, thanks! |
v-jizhang
added a commit
to v-jizhang/presto
that referenced
this pull request
Apr 11, 2022
Cherry-pick of trinodb/trino#11710 Currently, in the deepInstanceSize function of BlockBuilderStatus class, we recursively calculate the size of one BlockBuilderStatus instance. However, we should exclude the static field which is not the size for one instance, it's the size for the whole class and is shared by each intance. Co-authored-by: JackieTien97 <jackietien97@gmail.com>
highker
pushed a commit
to prestodb/presto
that referenced
this pull request
Apr 20, 2022
Cherry-pick of trinodb/trino#11710 Currently, in the deepInstanceSize function of BlockBuilderStatus class, we recursively calculate the size of one BlockBuilderStatus instance. However, we should exclude the static field which is not the size for one instance, it's the size for the whole class and is shared by each intance. Co-authored-by: JackieTien97 <jackietien97@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, in the
deepInstanceSizefunction ofBlockBuilderStatusclass, we recursively calculate the size of oneBlockBuilderStatusinstance. However, we should exclude thestaticfield which is not the size for one instance, it's the size for the whole class and is shared by each intance.Besides, we should also exclude the synthetic field in this class, especially if you use something like
jacocoinmavenwhich is used to calculate code coverage.jacocoinmavenwill add some synthetic fields in class, and if we use the currentdeepInstanceSizefunction ofBlockBuilderStatusclass, we will get some errors like the following picture:I was confused about this error at first, I didn't explicitly declare
boolean[]in this class. Then I print all the fields for the class, I got the following:The last one field:
boolean[] $jacocoDatais not declared in my class which is a synthetic field and generated byjacocoinmaven, so when I iterate the fields in this class using Class<?>.getDeclaredFields() method, we will get this unexpected one. When we keep recursively callingdeepInstanceSizefunction for thisboolean[] $jacocoDatafield, we will get theIllegalArgumentExceptionin the first picture.