Re: RFR: 8282178: Replace simple iterations of Map.entrySet with Map.forEach calls

2022-03-24 Thread liach
On Wed, 23 Feb 2022 22:33:42 GMT, liach  wrote:

> Replaces simple `for (Map.Entry entry : map.entrySet())` with 
> `map.forEach((k, v) ->)` calls. This change is better for thread-safety and 
> reduces allocation for some map implementations.
> 
> A more in-depth description of benefits is available at 
> https://mail.openjdk.java.net/pipermail/core-libs-dev/2022-February/086201.html
>  and at the JBS issue itself.
> 
> A [jmh 
> comparison](https://jmh.morethan.io/?sources=https://gist.githubusercontent.com/liach/0c0f79f0c0b9b78f474d65cda2c5f7b5/raw/4f2a160c51164aefdfac6ab5a19bdbc8c65f5fcf/base-results.json,https://gist.githubusercontent.com/liach/0c0f79f0c0b9b78f474d65cda2c5f7b5/raw/4f2a160c51164aefdfac6ab5a19bdbc8c65f5fcf/head-results.json)
>  on the performance of the existing `HashMapBench` shows that the performance 
> of `putAll` for `HashMap` has not significantly changed.

In a short summary, on mailing list, stuart says this doesn't benefit 
concurrent maps; Remi proposed to deprecate the synchronized collections for 
the peculiarities of iteration; kevin said that this change improves code 
clarity.

Hence, I still believe changing to foreach calls in putAll can potentially 
benefit adding from maps that have expensive iterators and entry wrappers.

-

PR: https://git.openjdk.java.net/jdk/pull/7601


Re: RFR: 8282178: Replace simple iterations of Map.entrySet with Map.forEach calls

2022-02-23 Thread liach
On Wed, 23 Feb 2022 23:50:49 GMT, PROgrm_JARvis  wrote:

>> Replaces simple `for (Map.Entry entry : map.entrySet())` with 
>> `map.forEach((k, v) ->)` calls. This change is better for thread-safety and 
>> reduces allocation for some map implementations.
>> 
>> A more in-depth description of benefits is available at 
>> https://mail.openjdk.java.net/pipermail/core-libs-dev/2022-February/086201.html
>>  and at the JBS issue itself.
>> 
>> A [jmh 
>> comparison](https://jmh.morethan.io/?sources=https://gist.githubusercontent.com/liach/0c0f79f0c0b9b78f474d65cda2c5f7b5/raw/4f2a160c51164aefdfac6ab5a19bdbc8c65f5fcf/base-results.json,https://gist.githubusercontent.com/liach/0c0f79f0c0b9b78f474d65cda2c5f7b5/raw/4f2a160c51164aefdfac6ab5a19bdbc8c65f5fcf/head-results.json)
>>  on the performance of the existing `HashMapBench` shows that the 
>> performance of `putAll` for `HashMap` has not significantly changed.
>
> src/java.base/share/classes/java/util/AbstractMap.java line 881:
> 
>> 879:  * used before indy and lambda expressions are ready in initPhase1.
>> 880:  * Regular code can safely use {@code map::put} instead.
>> 881:  */
> 
> Looks like `@param ` and `@param ` are missing although Javadoc-comment 
> is used.

This javadoc-style comment is designed like the javadoc for `jdk.internal.` 
packages or package-private elements in `java.` packages, which only talks 
about cautions and rationale for this class. It is not rendered in the 
generated API documentations and not a public API.

-

PR: https://git.openjdk.java.net/jdk/pull/7601


Re: RFR: 8282178: Replace simple iterations of Map.entrySet with Map.forEach calls

2022-02-23 Thread PROgrm_JARvis
On Wed, 23 Feb 2022 22:33:42 GMT, liach  wrote:

> Replaces simple `for (Map.Entry entry : map.entrySet())` with 
> `map.forEach((k, v) ->)` calls. This change is better for thread-safety and 
> reduces allocation for some map implementations.
> 
> A more in-depth description of benefits is available at 
> https://mail.openjdk.java.net/pipermail/core-libs-dev/2022-February/086201.html
>  and at the JBS issue itself.
> 
> A [jmh 
> comparison](https://jmh.morethan.io/?sources=https://gist.githubusercontent.com/liach/0c0f79f0c0b9b78f474d65cda2c5f7b5/raw/4f2a160c51164aefdfac6ab5a19bdbc8c65f5fcf/base-results.json,https://gist.githubusercontent.com/liach/0c0f79f0c0b9b78f474d65cda2c5f7b5/raw/4f2a160c51164aefdfac6ab5a19bdbc8c65f5fcf/head-results.json)
>  on the performance of the existing `HashMapBench` shows that the performance 
> of `putAll` for `HashMap` has not significantly changed.

Changes requested by jarviscr...@github.com (no known OpenJDK username).

src/java.base/share/classes/java/util/AbstractMap.java line 881:

> 879:  * used before indy and lambda expressions are ready in initPhase1.
> 880:  * Regular code can safely use {@code map::put} instead.
> 881:  */

Looks like `@param ` and `@param ` are missing although Javadoc-comment 
is used.

-

PR: https://git.openjdk.java.net/jdk/pull/7601


RFR: 8282178: Replace simple iterations of Map.entrySet with Map.forEach calls

2022-02-23 Thread liach
Replaces simple `for (Map.Entry entry : map.entrySet())` with 
`map.forEach((k, v) ->)` calls. This change is better for thread-safety and 
reduces allocation for some map implementations.

A more in-depth description of benefits is available at 
https://mail.openjdk.java.net/pipermail/core-libs-dev/2022-February/086201.html 
and at the JBS issue itself.

A [jmh 
comparison](https://jmh.morethan.io/?sources=https://gist.githubusercontent.com/liach/0c0f79f0c0b9b78f474d65cda2c5f7b5/raw/4f2a160c51164aefdfac6ab5a19bdbc8c65f5fcf/base-results.json,https://gist.githubusercontent.com/liach/0c0f79f0c0b9b78f474d65cda2c5f7b5/raw/4f2a160c51164aefdfac6ab5a19bdbc8c65f5fcf/head-results.json)
 on the performance of the existing `HashMapBench` shows that the performance 
of `putAll` for `HashMap` has not significantly changed.

-

Commit messages:
 - Merge branch 'master' of https://git.openjdk.java.net/jdk into map-foreach
 - Fix initialization issues
 - 8282178: Replace simple iterations of Map.entrySet with Map.forEach calls

Changes: https://git.openjdk.java.net/jdk/pull/7601/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7601&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8282178
  Stats: 47 lines in 7 files changed: 26 ins; 6 del; 15 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7601.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7601/head:pull/7601

PR: https://git.openjdk.java.net/jdk/pull/7601