Ivan Zlenko created HDDS-11544:
----------------------------------
Summary: Inefficient work with arrays in Ozone
Key: HDDS-11544
URL: https://issues.apache.org/jira/browse/HDDS-11544
Project: Apache Ozone
Issue Type: Improvement
Components: common
Affects Versions: 2.0.0
Reporter: Ivan Zlenko
Assignee: Ivan Zlenko
We have a few places where we are working with arrays quite inefficiently.
First of all we are using old style conversion to arrays by passing number of
expected elements instead of 0.
{quote}
In older Java versions, using a pre-sized array was recommended, as the
reflection call necessary to create an array of proper size was quite slow.
However, since late updates of OpenJDK 6, this call was intrinsified, making
the performance of the empty array version the same, and sometimes even better,
compared to the pre-sized version. Also, passing a pre-sized array is dangerous
for a concurrent or synchronized collection as a data race is possible between
the size and toArray calls. This may result in extra nulls at the end of the
array if the collection was concurrently shrunk during the operation.
{quote}
The other case is double array conversion where we firstly convert to a list
and after that we convert this list into an array. This can lead to up to 50%
performance degradation on a single method call.
For example we have it in ECContainerOperationClient in listBlock method which
I do believe called quite often for EC keys.
Line 99:
{code:java}
}).collect(Collectors.toList())
.toArray(new BlockData[blockDataList.size()]);
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]