Skip to content

Conversation

@kbendick
Copy link
Contributor

@kbendick kbendick commented Oct 9, 2021

The number of ErrorProne warnings has gotten larger lately.

This fixes AvoidNewHashMapInt as it has performance implications.

Replaces all instance of new HashMap(int) with newHashMapWithExpectedSize, as new HashMap(int) will initially allocate a map with 3/4th of the passed in size and then require growing / reallocating once it's actually filled with all of the values.

@kbendick kbendick changed the title Fix ErrorProne NewHashMapInt by using newHashMapWithExpectedSize for perf reasons Fix ErrorProne AvoidNewHashMapInt by using newHashMapWithExpectedSize for perf reasons Oct 9, 2021
@kbendick kbendick changed the title Fix ErrorProne AvoidNewHashMapInt by using newHashMapWithExpectedSize for perf reasons Reduce Excessive Build Logs - Fix ErrorProne AvoidNewHashMapInt which adds perf gains Oct 9, 2021

} else {
Map<Integer, ByteBuffer> result = new HashMap<>(size);
Map<Integer, ByteBuffer> result = Maps.newHashMapWithExpectedSize(size);
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 This is one of the reasons why we prefer using factory methods in Maps.

@rdblue rdblue merged commit 6ca31fc into apache:master Oct 10, 2021
@rdblue
Copy link
Contributor

rdblue commented Oct 10, 2021

Thanks, @kbendick!

@kbendick kbendick deleted the fix-errorprone-avoidhashmapint branch October 27, 2021 04:00
@kbendick
Copy link
Contributor Author

Adding this to the 0.12.1 release as it makes cherry-picking cleaner.

@kbendick kbendick added this to the Java 0.12.1 Release milestone Oct 27, 2021
kbendick added a commit to kbendick/iceberg that referenced this pull request Oct 27, 2021
This should improve performance by allocating the correct size directly rather than reallocating later.
RussellSpitzer pushed a commit to RussellSpitzer/iceberg that referenced this pull request Oct 29, 2021
This should improve performance by allocating the correct size directly rather than reallocating later.
kbendick added a commit to kbendick/iceberg that referenced this pull request Oct 31, 2021
This should improve performance by allocating the correct size directly rather than reallocating later.
rdblue pushed a commit that referenced this pull request Nov 1, 2021
This should improve performance by allocating the correct size directly rather than reallocating later.
izchen pushed a commit to izchen/iceberg that referenced this pull request Dec 7, 2021
This should improve performance by allocating the correct size directly rather than reallocating later.
Initial-neko pushed a commit to Initial-neko/iceberg that referenced this pull request Dec 13, 2021
Initial-neko pushed a commit to Initial-neko/iceberg that referenced this pull request Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants