Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v4]

2024-08-14 Thread Aleksey Shipilev
On Thu, 20 Jun 2024 19:17:25 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to s

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v4]

2024-08-14 Thread duke
On Thu, 20 Jun 2024 19:17:25 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to s

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v4]

2024-08-14 Thread jengebr
On Thu, 20 Jun 2024 19:17:25 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to s

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-08-14 Thread Alan Bateman
On Wed, 19 Jun 2024 12:52:46 GMT, Alan Bateman wrote: >> @AlanBateman -- could you please take a look? Thanks. > >> @AlanBateman -- could you please take a look? Thanks. > > There was a lot of heap analysis done a few years ago that shined a light on > the number of empty collections in a typic

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v4]

2024-08-14 Thread Alan Bateman
On Thu, 20 Jun 2024 19:17:25 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to s

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-08-13 Thread jengebr
On Wed, 19 Jun 2024 12:52:46 GMT, Alan Bateman wrote: >> @AlanBateman -- could you please take a look? Thanks. > >> @AlanBateman -- could you please take a look? Thanks. > > There was a lot of heap analysis done a few years ago that shined a light on > the number of empty collections in a typic

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v4]

2024-08-12 Thread jengebr
On Thu, 20 Jun 2024 19:17:25 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to s

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-07-15 Thread jengebr
On Wed, 19 Jun 2024 12:52:46 GMT, Alan Bateman wrote: >> @AlanBateman -- could you please take a look? Thanks. > >> @AlanBateman -- could you please take a look? Thanks. > > There was a lot of heap analysis done a few years ago that shined a light on > the number of empty collections in a typic

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v4]

2024-07-15 Thread Aleksey Shipilev
On Thu, 20 Jun 2024 19:17:25 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to s

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-20 Thread jengebr
On Thu, 6 Jun 2024 12:46:36 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to si

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v4]

2024-06-20 Thread jengebr
> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless > cloning of Object[0] instances. This cloning is intended to prevent callers > from changing array contents, but many `CopyOnWriteArrayList`s are allocated > to size zero, or are otherwise maintained empty, so cloning

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-19 Thread Alan Bateman
On Wed, 19 Jun 2024 11:58:07 GMT, Aleksey Shipilev wrote: > @AlanBateman -- could you please take a look? Thanks. There was a lot of heap analysis done a few years ago that shined a light on the number of empty collections in a typical heap. I don't recall seeing COWAL in any of the data but i

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-19 Thread Aleksey Shipilev
On Thu, 6 Jun 2024 12:46:36 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to si

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-10 Thread Viktor Klang
On Thu, 6 Jun 2024 12:46:36 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to si

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-10 Thread Viktor Klang
On Thu, 6 Jun 2024 14:29:46 GMT, Aleksey Shipilev wrote: >> `clone()` performs a shallow copy, so there is currently no `Object[]` >> allocated and therefore nothing to optimize. I don't think there's any work >> to do here. >> >> @DougLea @viktorklang-ora can you confirm? > >> clone() perfor

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-06 Thread Doug Lea
On Thu, 6 Jun 2024 12:46:36 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to si

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-06 Thread Aleksey Shipilev
On Thu, 6 Jun 2024 12:46:36 GMT, jengebr wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >> to si

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-06 Thread Aleksey Shipilev
On Wed, 5 Jun 2024 14:56:26 GMT, jengebr wrote: > clone() performs a shallow copy, so there is currently no Object[] allocated > and therefore nothing to optimize. Yes, I believe so. - PR Review Comment: https://git.openjdk.org/jdk/pull/19527#discussion_r1629666551

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v3]

2024-06-06 Thread jengebr
> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless > cloning of Object[0] instances. This cloning is intended to prevent callers > from changing array contents, but many `CopyOnWriteArrayList`s are allocated > to size zero, or are otherwise maintained empty, so cloning

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v2]

2024-06-05 Thread jengebr
On Tue, 4 Jun 2024 19:58:41 GMT, jengebr wrote: >> Agreed. You might as well be consistent with this so that no one will need >> to re-address if some application does zillions of clones of empty lists. > > Sorry, I crossed wires with @DougLea 's comment, will add `clone`. `clone()` performs a

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v2]

2024-06-04 Thread jengebr
On Tue, 4 Jun 2024 19:41:15 GMT, Doug Lea wrote: >> src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java >> line 103: >> >>> 101: private static final long serialVersionUID = 8673264195747942595L; >>> 102: >>> 103: private static final Object[] EMPTY_ELEMENTDATA =

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations [v2]

2024-06-04 Thread jengebr
> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless > cloning of Object[0] instances. This cloning is intended to prevent callers > from changing array contents, but many `CopyOnWriteArrayList`s are allocated > to size zero, or are otherwise maintained empty, so cloning

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations

2024-06-04 Thread Doug Lea
On Tue, 4 Jun 2024 13:03:45 GMT, Viktor Klang wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated >>

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations

2024-06-04 Thread Viktor Klang
On Mon, 3 Jun 2024 16:47:20 GMT, jengebr wrote: > Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless > cloning of Object[0] instances. This cloning is intended to prevent callers > from changing array contents, but many `CopyOnWriteArrayList`s are allocated > to size z

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations

2024-06-04 Thread jengebr
On Mon, 3 Jun 2024 18:48:48 GMT, Doug Lea wrote: > The jmh benchmark checks only the empty case, you need to also show lack of > impact on non-empty cases. After removing `toArray`, I think this is covered. Can you please confirm? > Assuming you demonstrate this, it seems basically OK, (Deja

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations

2024-06-03 Thread jengebr
On Mon, 3 Jun 2024 17:07:28 GMT, Aleksey Shipilev wrote: >> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless >> cloning of Object[0] instances. This cloning is intended to prevent callers >> from changing array contents, but many `CopyOnWriteArrayList`s are allocated

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations

2024-06-03 Thread Doug Lea
On Mon, 3 Jun 2024 16:47:20 GMT, jengebr wrote: > Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless > cloning of Object[0] instances. This cloning is intended to prevent callers > from changing array contents, but many `CopyOnWriteArrayList`s are allocated > to size z

RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations

2024-06-03 Thread jengebr
Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless cloning of Object[0] instances. This cloning is intended to prevent callers from changing array contents, but many `CopyOnWriteArrayList`s are allocated to size zero, or are otherwise maintained empty, so cloning is unne

Re: RFR: 8332842: Optimize empty CopyOnWriteArrayList allocations

2024-06-03 Thread Aleksey Shipilev
On Mon, 3 Jun 2024 16:47:20 GMT, jengebr wrote: > Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless > cloning of Object[0] instances. This cloning is intended to prevent callers > from changing array contents, but many `CopyOnWriteArrayList`s are allocated > to size z