Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-17 Thread Joshua Cao
On Fri, 12 Jan 2024 08:51:16 GMT, Volker Simonis wrote: >>> tryPresize(int size) is doing and if its size argument is supposed to >>> contain the additional number of elements which will be inserted into the >>> hash map or if it is a hint for the new total size of the hash map >> >> Argument

Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-12 Thread Volker Simonis
On Thu, 11 Jan 2024 19:21:00 GMT, Joshua Cao wrote: >>> We don't need to compute max() here. >>> [tryPresize()](https://github.com/openjdk/jdk/blob/8a4dc79e1a40e7115e2971af81623b6b0368f41c/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2397) >>> does that already. >>

Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-11 Thread Joshua Cao
On Thu, 11 Jan 2024 09:40:07 GMT, Volker Simonis wrote: > tryPresize(int size) is doing and if its size argument is supposed to contain > the additional number of elements which will be inserted into the hash map or > if it is a hint for the new total size of the hash map Argument `size` for

Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-11 Thread Volker Simonis
On Mon, 8 Jan 2024 20:27:59 GMT, Joshua Cao wrote: > We don't need to compute max() here. > [tryPresize()](https://github.com/openjdk/jdk/blob/8a4dc79e1a40e7115e2971af81623b6b0368f41c/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2397) > does that already. The code

Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-08 Thread Joshua Cao
On Mon, 8 Jan 2024 15:59:17 GMT, Volker Simonis wrote: > Shouldn't this be something like tryPresize(this.size() + m.size()) to > accommodate for the worst case where there are no common keys in this map and > m? Its a good callout. Not sure if it is a miss, or intentionally conservative. >

Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-08 Thread Volker Simonis
On Wed, 3 Jan 2024 21:29:57 GMT, Joshua Cao wrote: >> ConcurrentHashMap's copy constructor calls `putAll()` -> `tryPresize()` -> >> `transfer()`. When coming from the copy constructor, the Map is empty, so >> there is nothing to transfer. But `transfer()` will still copy all the empty >>

Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-04 Thread Aleksey Shipilev
On Wed, 3 Jan 2024 21:29:57 GMT, Joshua Cao wrote: >> ConcurrentHashMap's copy constructor calls `putAll()` -> `tryPresize()` -> >> `transfer()`. When coming from the copy constructor, the Map is empty, so >> there is nothing to transfer. But `transfer()` will still copy all the empty >>

Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-03 Thread Joshua Cao
On Wed, 3 Jan 2024 19:52:34 GMT, Joshua Cao wrote: >> test/micro/org/openjdk/bench/java/util/concurrent/Maps.java line 122: >> >>> 120: public void testCopyConstructor() { >>> 121: ConcurrentHashMap clone = new >>> ConcurrentHashMap<>(staticMap); >>> 122: dummy = clone; >>

Re: RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

2024-01-03 Thread Joshua Cao
> ConcurrentHashMap's copy constructor calls `putAll()` -> `tryPresize()` -> > `transfer()`. When coming from the copy constructor, the Map is empty, so > there is nothing to transfer. But `transfer()` will still copy all the empty > nodes from the old table to the new table. > > This patch