You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Attila Doroszlai (Jira)" <ji...@apache.org> on 2024/10/10 17:14:00 UTC

[jira] [Updated] (HDDS-11544) Improve work with arrays

     [ https://issues.apache.org/jira/browse/HDDS-11544?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Attila Doroszlai updated HDDS-11544:
------------------------------------
    Summary: Improve work with arrays  (was: Improve work with arrays\)

> Improve work with arrays
> ------------------------
>
>                 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
>            Priority: Major
>              Labels: ozone-performance, patch-available, pull-request-available
>             Fix For: 2.0.0
>
>
> 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: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org