PCollectionViews$SimplePCollectionView.hashCode once again allocates memory (fix reverted, then fixed again)
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
I'm currently profiling memory consumption of our Beam pipeline and have noticed that
org.apache.beam.sdk.values.PCollectionViews$SimplePCollectionView.hashCode()
makes noticeable heap allocations. The implementation is:
return Objects.hash(tag);
That itself translates to:
return Arrays.hashCode(values);
Which performs implicit array creation in order to call:
public static int Arrays.hashCode(Object a[]);
Instead of the helper call, doing simple:
tag.hashCode();
Seems more appropriate.
Imported from Jira [BEAM-6503](https://issues.apache.org/jira/browse/BEAM-6503). Original Jira may contain additional context.
Reported by: janotav.
Contributor guide
Research direction
Start at org.apache.beam.sdk.values.PCollectionViews$SimplePCollectionView.hashCode() and inspect how its tag is used. Replace the allocation-producing hash calculation with the direct tag hash, then run the relevant Apache Beam Java tests to confirm behavior and verify that profiling no longer shows the avoidable allocation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100