Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v34]

2022-03-16 Thread XenoAmess
On Thu, 17 Mar 2022 03:09:53 GMT, Stuart Marks wrote: > There's already a bug for this: > [JDK-8186958](https://bugs.openjdk.java.net/browse/JDK-8186958). This > includes creating a new API as well as fixing up a bunch of call sites. > There's a partial list of call sites in java.base there. G

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v34]

2022-03-16 Thread Stuart Marks
On Sat, 12 Mar 2022 01:35:23 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refine test There's already a bug for this: [JDK-8186

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v34]

2022-03-16 Thread XenoAmess
On Wed, 16 Mar 2022 16:46:58 GMT, Stuart Marks wrote: > No, you don't need to do any rebasing; when the change is integrated, all > these commits will automatically be squashed into a single commit. If that > can't be done, the bot will detect it and give a warning, which will probably > inclu

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v34]

2022-03-16 Thread Stuart Marks
On Sat, 12 Mar 2022 01:35:23 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refine test No, you don't need to do any rebasing; whe

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v33]

2022-03-16 Thread XenoAmess
On Fri, 11 Mar 2022 19:40:39 GMT, Stuart Marks wrote: >> XenoAmess has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - change KeyStructure to String >> - fix test > > Regarding the number of test cases for `tableSizeForCases` and > `popu

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v34]

2022-03-15 Thread Stuart Marks
On Sat, 12 Mar 2022 01:35:23 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refine test > what I worried is, the boundary this is

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v33]

2022-03-11 Thread XenoAmess
On Fri, 11 Mar 2022 19:40:39 GMT, Stuart Marks wrote: > I think we can rely on the monotonicity of these functions. If populating a > map both with 49 and with 96 mappings results in a table length of 128, we > don't need to test that all the intermediate inputs also result in a table > length

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v33]

2022-03-11 Thread XenoAmess
On Fri, 11 Mar 2022 19:40:39 GMT, Stuart Marks wrote: >> XenoAmess has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - change KeyStructure to String >> - fix test > > Regarding the number of test cases for `tableSizeForCases` and > `popu

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v34]

2022-03-11 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: refine test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.op

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v33]

2022-03-11 Thread XenoAmess
On Fri, 11 Mar 2022 19:09:25 GMT, Stuart Marks wrote: >> XenoAmess has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - change KeyStructure to String >> - fix test > > test/jdk/java/util/HashMap/WhiteBoxResizeTest.java line 61: > >> 59:

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v33]

2022-03-11 Thread Stuart Marks
On Fri, 11 Mar 2022 15:56:26 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with two additional > commits since the last revision: > > - change KeyStructure to String > - fix test Regardin

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v33]

2022-03-11 Thread XenoAmess
On Fri, 11 Mar 2022 15:56:26 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with two additional > commits since the last revision: > > - change KeyStructure to String > - fix test ![image]

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v33]

2022-03-11 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with two additional commits since the last revision: - change KeyStructure to String - fix test - Changes: - all: https://git.openjdk.java.net/jdk/pull/74

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v32]

2022-03-10 Thread XenoAmess
On Fri, 11 Mar 2022 01:42:19 GMT, XenoAmess wrote: >> XenoAmess has updated the pull request incrementally with one additional >> commit since the last revision: >> >> refine test > > oops seems I wronglly added a teat case 0/1 > will delete it later > @XenoAmess I don't think we need `KeySt

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v32]

2022-03-10 Thread Stuart Marks
On Fri, 11 Mar 2022 01:28:13 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refine test @RogerRiggs Good point about `Integer` bei

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v32]

2022-03-10 Thread XenoAmess
On Fri, 11 Mar 2022 01:28:13 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refine test oops seems I wronglly added a teat case 0/

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v32]

2022-03-10 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: refine test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.op

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v31]

2022-03-10 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: refine test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.op

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

2022-03-10 Thread XenoAmess
On Thu, 10 Mar 2022 22:37:58 GMT, Roger Riggs wrote: > Heads up here! java.lang.Integer is specified as a value based class and > should not be used where identity is needed. > https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/doc-files/ValueBased.html > > I don't have a r

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

2022-03-10 Thread XenoAmess
On Thu, 10 Mar 2022 22:21:28 GMT, Stuart Marks wrote: > The difficulty with having a loop instead of constants is that the expected > value now needs to be computed. We could probably use `tableSizeFor` to do > this. But this is starting to get uncomfortably close to a testing > antipattern wh

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v30]

2022-03-10 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: refine test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.op

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

2022-03-10 Thread Roger Riggs
On Thu, 10 Mar 2022 22:01:49 GMT, Stuart Marks wrote: >> @stuart-marks please have a look in changes in the latest commit, I think >> we'd better to manually create references for keys like that. > > Good point about WeakHashMap! I don't think we need a separate table. Since > the value is held

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

2022-03-10 Thread Stuart Marks
On Thu, 10 Mar 2022 16:10:31 GMT, XenoAmess wrote: >> XenoAmess has updated the pull request incrementally with five additional >> commits since the last revision: >> >> - clean out tests >> - Remove 'randomness' keyword. >> - Cleanup and commenting. >> - initial rewrite of WhiteBoxResizeTe

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

2022-03-10 Thread Stuart Marks
On Thu, 10 Mar 2022 16:22:29 GMT, XenoAmess wrote: >> test/jdk/java/util/HashMap/WhiteBoxResizeTest.java line 116: >> >>> 114: } >>> 115: >>> 116: void putN(Map map, int n) { >> >> @stuart-marks well we know this is correct for WeakHashMap when n < >> IntegerCache.high because we have

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v29]

2022-03-10 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: manually create reference for ensuring test for WeakHashMap when IntegerCache.high is configured/changed default valu

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

2022-03-10 Thread XenoAmess
On Thu, 10 Mar 2022 16:15:03 GMT, XenoAmess wrote: >> XenoAmess has updated the pull request incrementally with five additional >> commits since the last revision: >> >> - clean out tests >> - Remove 'randomness' keyword. >> - Cleanup and commenting. >> - initial rewrite of WhiteBoxResizeTe

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

2022-03-10 Thread XenoAmess
On Thu, 10 Mar 2022 16:13:42 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with five additional > commits since the last revision: > > - clean out tests > - Remove 'randomness' keyword. >

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v28]

2022-03-10 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with five additional commits since the last revision: - clean out tests - Remove 'randomness' keyword. - Cleanup and commenting. - initial rewrite of WhiteBoxResizeTest

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v27]

2022-03-10 Thread XenoAmess
On Thu, 10 Mar 2022 01:11:03 GMT, Stuart Marks wrote: > Sorry, the test changes look like they're heading in the wrong direction. I > tried to provide some hints for what I was looking for in my previous > comments. At this point, I felt it would have been too time-consuming to > provide a bun

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v27]

2022-03-09 Thread Stuart Marks
On Sat, 5 Mar 2022 19:06:03 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refactor tests Sorry, the test changes look like they'r

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v25]

2022-03-06 Thread XenoAmess
On Fri, 4 Mar 2022 21:02:50 GMT, Stuart Marks wrote: >>> This actually tests three things: 1) table is lazily allocated, 2) default >>> capacity is 16, and 3) using putAll to populate the map with 64 elements >>> results in a table size of 128. This should really be broken into three >>> separ

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v27]

2022-03-05 Thread XenoAmess
On Sat, 5 Mar 2022 19:29:17 GMT, liach wrote: > this looks wrong, and the class instance is used nowhere later. should > probably be removed. @liach already removed in the latest commit. - PR: https://git.openjdk.java.net/jdk/pull/7431

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v27]

2022-03-05 Thread liach
On Sat, 5 Mar 2022 19:06:03 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refactor tests test/jdk/java/util/HashMap/WhiteBoxHashM

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v27]

2022-03-05 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: refactor tests - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v26]

2022-03-05 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with three additional commits since the last revision: - refactor tests - refactor tests - refactor WhiteBoxResizeTest - Changes: - all: https://git.open

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v25]

2022-03-04 Thread Stuart Marks
On Fri, 4 Mar 2022 20:23:38 GMT, XenoAmess wrote: > would you mind if I break WhiteBoxResizeTest class into several smaller Test > classes, each focus on one of the test points you said? Well, separate classes wouldn't be the approach that I'd take myself. However, I'm interested in you contin

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v25]

2022-03-04 Thread XenoAmess
On Fri, 4 Mar 2022 20:05:23 GMT, Stuart Marks wrote: > This actually tests three things: 1) table is lazily allocated, 2) default > capacity is 16, and 3) using putAll to populate the map with 64 elements > results in a table size of 128. This should really be broken into three > separate test

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v25]

2022-03-04 Thread Stuart Marks
On Fri, 4 Mar 2022 17:30:48 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refine test > I see codes WhiteBoxResizeTest. If you wa

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v25]

2022-03-04 Thread XenoAmess
On Fri, 4 Mar 2022 17:43:25 GMT, liach wrote: > nitpick for the test code: for better performance, move method handle and var > handle to static final fields so the jvm can run faster will do it when we really migrate this test, but it should be done in another pr when I add WeakHashMap's tabl

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v25]

2022-03-04 Thread liach
On Fri, 4 Mar 2022 17:30:48 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > refine test nitpick for the test code: for better perfo

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v25]

2022-03-04 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: refine test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.op

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v24]

2022-03-04 Thread XenoAmess
On Thu, 3 Mar 2022 15:46:37 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > cast several float to double before calculation I would

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v24]

2022-03-04 Thread XenoAmess
On Fri, 4 Mar 2022 02:27:53 GMT, Stuart Marks wrote: >> XenoAmess has updated the pull request incrementally with one additional >> commit since the last revision: >> >> cast several float to double before calculation > > OK, I took a look at HashMapsPutAllOverAllocateTableTest.java. It's cer

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v24]

2022-03-04 Thread XenoAmess
On Fri, 4 Mar 2022 02:27:53 GMT, Stuart Marks wrote: > OK, I took a look at HashMapsPutAllOverAllocateTableTest.java. It's certainly > a good start at testing stuff in this area. However, I notice that > > ``` > test/jdk/java/util/HashMap/WhiteBoxResizeTest.java > ``` > > already exists and te

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v24]

2022-03-03 Thread Stuart Marks
On Thu, 3 Mar 2022 15:46:37 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > cast several float to double before calculation OK, I t

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v24]

2022-03-03 Thread Stuart Marks
On Thu, 3 Mar 2022 15:46:37 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > cast several float to double before calculation src/jav

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v19]

2022-03-03 Thread XenoAmess
On Fri, 18 Feb 2022 18:32:31 GMT, Stuart Marks wrote: >> XenoAmess has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - migrate to junit >> - change threshold > > Sigh. (I'm sighing at the author of the > Enum/ConstantDirectoryOptimalCapa

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v24]

2022-03-03 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: cast several float to double before calculation - Changes: - all: https://git.openjdk.java.net/jdk/pul

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v23]

2022-03-02 Thread Stuart Marks
On Wed, 2 Mar 2022 18:48:46 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > revert changes to IdentityHashMap src/java.base/share/c

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v19]

2022-03-02 Thread XenoAmess
On Fri, 18 Feb 2022 18:32:31 GMT, Stuart Marks wrote: >> XenoAmess has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - migrate to junit >> - change threshold > > Sigh. (I'm sighing at the author of the > Enum/ConstantDirectoryOptimalCapa

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v23]

2022-03-02 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: revert changes to IdentityHashMap - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-03-02 Thread XenoAmess
On Wed, 2 Mar 2022 01:44:24 GMT, Stuart Marks wrote: > I'm starting to look at this again. First, a quick note -- I don't think > there should be any IdentityHashMap changes here. That uses a completely > different internal structure and allocation policy, and it's kind of a > distraction from

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-03-01 Thread Stuart Marks
On Sun, 20 Feb 2022 19:50:01 GMT, liach wrote: >> @liach Hi. please have a look at the latest commit. >> do you think it be better now? > > Oops, didn't notice there was this helpful `init` method. Does look much more > straightforward now. I'm starting to look at this again. First, a quick not

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v22]

2022-02-20 Thread XenoAmess
On Mon, 21 Feb 2022 06:33:05 GMT, liach wrote: > Unfortunately I don't think there is any for now. @liach Yes. that is why I ask if there be evidence to show `(int) ((1 + m.size()) * 1.1)` be an optimization, but not otherwise. (IMO it is otherwise.) - PR: https://git.openjdk.ja

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v22]

2022-02-20 Thread liach
On Sun, 20 Feb 2022 20:30:29 GMT, XenoAmess wrote: >>> You should run benchmarks to see how bad the lookup performance degrades >>> after you saves memory used by the hash table. >> >> OK, would find some time for it. > >> > You should run benchmarks to see how bad the lookup performance degrad

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v22]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 20:03:07 GMT, XenoAmess wrote: > > You should run benchmarks to see how bad the lookup performance degrades > > after you saves memory used by the hash table. > > OK, would find some time for it. @liach which jmh test should I run by the way? Or is there some commandline t

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v22]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 20:02:09 GMT, XenoAmess wrote: > You should run benchmarks to see how bad the lookup performance degrades > after you saves memory used by the hash table. OK, would find some time for it. - PR: https://git.openjdk.java.net/jdk/pull/7431

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v22]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 19:11:26 GMT, liach wrote: > > I don't thik it reasonable. or is there eveidence it be? > > If this map is too dense, there may be a lot of hash collisions, and the > lookup performance would decrease because this hashmap is linear probe than > red-black tree buckets like t

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread liach
On Sun, 20 Feb 2022 19:41:22 GMT, XenoAmess wrote: >> In fact, if we do worry about the performance of adding from maps, calling >> `map.forEach(this::put);` would be a better alternative both in concurrency >> (as the concurrent map itself takes charage) and object allocation-wise (no >> allo

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v22]

2022-02-20 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: refine IdentityHashMap - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: htt

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 19:19:16 GMT, liach wrote: >> Imo you should just remove the `if (expectedSize == 0)` check than using >> this somewhat ugly trick to avoid calling `size()` twice (the second call is >> only used for this relatively useless fast-path, especially for the >> concurrent collec

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread liach
On Sun, 20 Feb 2022 19:08:39 GMT, liach wrote: >>> @liach implementations `size()` seems O1, and returns a single int number >>> field, but it actually defers in some Map implementations. >> >> @liach for example, in ConcurrentSkipListMap and ConcurrentHashMap, `size()` >> function is far com

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread liach
On Sun, 20 Feb 2022 18:44:09 GMT, XenoAmess wrote: >> src/java.base/share/classes/java/util/IdentityHashMap.java line 281: >> >>> 279: * @throws NullPointerException if the specified map is null >>> 280: */ >>> 281: private IdentityHashMap(Map map, int >>> expectedSize) { >> >> W

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread liach
On Sun, 20 Feb 2022 18:08:24 GMT, XenoAmess wrote: > I don't thik it reasonable. or is there eveidence it be? If this map is too dense, there may be a lot of hash collisions, and the lookup performance would decrease because this hashmap is linear probe than red-black tree buckets like the reg

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 18:20:27 GMT, liach wrote: >> XenoAmess has updated the pull request incrementally with three additional >> commits since the last revision: >> >> - refine test >> - 1. optimize IdentityHashMap that when calling ::new(Map), do not call >> map.size() twice but once. >>

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 18:38:35 GMT, XenoAmess wrote: >> src/java.base/share/classes/java/util/IdentityHashMap.java line 281: >> >>> 279: * @throws NullPointerException if the specified map is null >>> 280: */ >>> 281: private IdentityHashMap(Map map, int >>> expectedSize) { >> >> W

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 18:20:27 GMT, liach wrote: >> XenoAmess has updated the pull request incrementally with three additional >> commits since the last revision: >> >> - refine test >> - 1. optimize IdentityHashMap that when calling ::new(Map), do not call >> map.size() twice but once. >>

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread liach
On Sun, 20 Feb 2022 18:08:37 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with three additional > commits since the last revision: > > - refine test > - 1. optimize IdentityHashMap that w

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 18:03:07 GMT, XenoAmess wrote: >> XenoAmess has updated the pull request incrementally with three additional >> commits since the last revision: >> >> - refine test >> - 1. optimize IdentityHashMap that when calling ::new(Map), do not call >> map.size() twice but once. >>

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 18:04:50 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with three additional > commits since the last revision: > > - refine test > - 1. optimize IdentityHashMap that w

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]

2022-02-20 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with three additional commits since the last revision: - refine test - 1. optimize IdentityHashMap that when calling ::new(Map), do not call map.size() twice but once.

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table

2022-02-20 Thread XenoAmess
On Sun, 20 Feb 2022 16:12:08 GMT, Andrew Haley wrote: > I don't think this is terribly important, but I don't like to see attempts at > hand optimization in the standard library. OK, we've decided use that Math.ceil() solution. - PR: https://git.openjdk.java.net/jdk/pull/7431

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v20]

2022-02-18 Thread XenoAmess
On Fri, 18 Feb 2022 18:53:43 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > revert unrelated changes and add it to ProblemList.txt

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v19]

2022-02-18 Thread XenoAmess
On Fri, 18 Feb 2022 18:32:31 GMT, Stuart Marks wrote: > Sigh. (I'm sighing at the author of the > Enum/ConstantDirectoryOptimalCapacity.java test, not you.) What a mess. See > https://bugs.openjdk.java.net/browse/JDK-8282120 which I just filed. The > broken test and the OptimalCapacity utiliti

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v20]

2022-02-18 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: revert unrelated changes and add it to ProblemList.txt https://bugs.openjdk.java.net/browse/JDK-8282120

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v19]

2022-02-18 Thread Stuart Marks
On Fri, 18 Feb 2022 15:29:25 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with two additional > commits since the last revision: > > - migrate to junit > - change threshold Sigh. (I'm si

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v14]

2022-02-18 Thread XenoAmess
On Thu, 17 Feb 2022 05:45:54 GMT, Stuart Marks wrote: >> XenoAmess has updated the pull request incrementally with one additional >> commit since the last revision: >> >> fix test > > OK, good progress. Yes, leaving ConcurrentHashMap to another PR is fine. > > Do the changes to Class.java an

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v19]

2022-02-18 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with two additional commits since the last revision: - migrate to junit - change threshold - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/fi

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v18]

2022-02-18 Thread XenoAmess
On Fri, 18 Feb 2022 11:20:12 GMT, XenoAmess wrote: > well seems jtreg cannot invoke Junit4 's parameterized test. Nope, it can! :) - PR: https://git.openjdk.java.net/jdk/pull/7431

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v18]

2022-02-18 Thread XenoAmess
On Thu, 17 Feb 2022 19:39:47 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > migrate to junit well seems jtreg cannot invoke Junit4

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v18]

2022-02-17 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: migrate to junit - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://g

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v17]

2022-02-17 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: migrate to junit - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://g

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v16]

2022-02-17 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: migrate to junit - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://g

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v14]

2022-02-17 Thread XenoAmess
On Thu, 17 Feb 2022 05:46:38 GMT, Stuart Marks wrote: >> XenoAmess has updated the pull request incrementally with one additional >> commit since the last revision: >> >> fix test > > test/jdk/java/util/Map/HashMapsPutAllOverAllocateTableTest.java line 2: > >> 1: /* >> 2: * Copyright (c) 20

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v15]

2022-02-17 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: fix license year in test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: h

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v14]

2022-02-17 Thread XenoAmess
On Thu, 17 Feb 2022 05:45:54 GMT, Stuart Marks wrote: > It's not clear to me that test is actually testing anything useful; it's just > testing the same computation a couple different ways. Well if I don't change it, then the test will fail. > Do the changes to Class.java and the enum optimal

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v14]

2022-02-16 Thread Stuart Marks
On Wed, 16 Feb 2022 19:11:53 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > fix test OK, good progress. Yes, leaving ConcurrentHas

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v6]

2022-02-16 Thread XenoAmess
On Tue, 15 Feb 2022 03:45:19 GMT, Stuart Marks wrote: >>> The changes to j.l.Class and the EnumConstantDirectory test don't belong >>> here -- these are _uses_ of HashMap. This bug and fix should focus on >>> HashMap itself, to ensure that the cases in question allocate a table of >>> the righ

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v14]

2022-02-16 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: fix test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.openj

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v13]

2022-02-16 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: fix test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.openj

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v12]

2022-02-16 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: fix test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.openj

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v11]

2022-02-16 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: fix test - Changes: - all: https://git.openjdk.java.net/jdk/pull/7431/files - new: https://git.openj

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v10]

2022-02-16 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with two additional commits since the last revision: - revert changes in ConcurrentHashMap - 9072610: HashMap copy constructor and putAll can over-allocate table ---

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v9]

2022-02-16 Thread XenoAmess
On Tue, 15 Feb 2022 18:23:51 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > 9072610: HashMap copy constructor and putAll can over-a

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v9]

2022-02-15 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: 9072610: HashMap copy constructor and putAll can over-allocate table - Changes: - all: https://git.ope

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v8]

2022-02-15 Thread XenoAmess
On Tue, 15 Feb 2022 16:58:49 GMT, XenoAmess wrote: >> 8281631: HashMap copy constructor and putAll can over-allocate table > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > 9072610: HashMap.putAll can cause redundant space waste

Re: RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v8]

2022-02-15 Thread XenoAmess
> 8281631: HashMap copy constructor and putAll can over-allocate table XenoAmess has updated the pull request incrementally with one additional commit since the last revision: 9072610: HashMap.putAll can cause redundant space waste - Changes: - all: https://git.openjdk.java.net