From duke at openjdk.org Mon Aug 22 07:51:02 2022 From: duke at openjdk.org (Ivan Ponomarev) Date: Mon, 22 Aug 2022 07:51:02 GMT Subject: RFR: CODETOOLS-7903176: Move LJV inside JOL [v2] In-Reply-To: References: Message-ID: > This moves https://github.com/atp-mipt/ljv project inside JOL in order for LJV to get access to internal JOL's APIs. > > See blogposts about LJV [in Russian](https://habr.com/ru/post/599045/) / [in English](https://dzone.com/articles/what-can-we-learn-from-java-data-structures-visual). Ivan Ponomarev has updated the pull request incrementally with one additional commit since the last revision: update copyright notice, lint ------------- Changes: - all: https://git.openjdk.org/jol/pull/24/files - new: https://git.openjdk.org/jol/pull/24/files/62672627..5001f98d Webrevs: - full: https://webrevs.openjdk.org/?repo=jol&pr=24&range=01 - incr: https://webrevs.openjdk.org/?repo=jol&pr=24&range=00-01 Stats: 53 lines in 48 files changed: 4 ins; 0 del; 49 mod Patch: https://git.openjdk.org/jol/pull/24.diff Fetch: git fetch https://git.openjdk.org/jol pull/24/head:pull/24 PR: https://git.openjdk.org/jol/pull/24 From duke at openjdk.org Mon Aug 22 07:51:03 2022 From: duke at openjdk.org (Ivan Ponomarev) Date: Mon, 22 Aug 2022 07:51:03 GMT Subject: RFR: CODETOOLS-7903176: Move LJV inside JOL In-Reply-To: <9xlrNd1y7irAwO8F4NMjwUgyCeQWs3Ekwn11aMYm-bg=.bc0bc6dc-309c-4f58-b21e-8909e68bf444@github.com> References: <9xlrNd1y7irAwO8F4NMjwUgyCeQWs3Ekwn11aMYm-bg=.bc0bc6dc-309c-4f58-b21e-8909e68bf444@github.com> Message-ID: On Tue, 3 May 2022 09:13:38 GMT, Aleksey Shipilev wrote: >> This moves https://github.com/atp-mipt/ljv project inside JOL in order for LJV to get access to internal JOL's APIs. >> >> See blogposts about LJV [in Russian](https://habr.com/ru/post/599045/) / [in English](https://dzone.com/articles/what-can-we-learn-from-java-data-structures-visual). > > Thanks for contribution! > > Before continuing with code review, there are some high-level things involved in this. I see there are multiple contributors for the incoming changesets. I believe all of them should have signed OCA on file, or their changesets should not be present in this PR (I see some were adding "slides" that are not present in this PR). Right, @robilad? > > You can use `/contributor add @` to mark them as contributors, I'd expect OpenJDK bots would then block the PR until OCAs are present. Hi @shipilev ! It seems that we managed to sort out everything with the OCA The code is linted and IMO ready for review ------------- PR: https://git.openjdk.org/jol/pull/24 From shade at openjdk.org Mon Aug 22 07:57:44 2022 From: shade at openjdk.org (Aleksey Shipilev) Date: Mon, 22 Aug 2022 07:57:44 GMT Subject: RFR: CODETOOLS-7903176: Move LJV inside JOL In-Reply-To: References: <9xlrNd1y7irAwO8F4NMjwUgyCeQWs3Ekwn11aMYm-bg=.bc0bc6dc-309c-4f58-b21e-8909e68bf444@github.com> Message-ID: On Mon, 22 Aug 2022 07:45:58 GMT, Ivan Ponomarev wrote: > It seems that we managed to sort out everything with the OCA Nice, I checked the OCA signatories list, and all PR contributors seems to be accounted for. In this PR, I see the commits from two more people (@[OrangeFlag](https://github.com/atp-mipt/jol/commits?author=OrangeFlag) and @[gogagum](https://github.com/atp-mipt/jol/commits?author=gogagum) -- and who are not in PR contributor list. I see they have OCA on file, so that is not a problem for this PR, but maybe you want to credit them as well? > The code is linted and IMO ready for review I'll start reviewing it then! Thanks. ------------- PR: https://git.openjdk.org/jol/pull/24 From shade at openjdk.org Mon Aug 22 09:41:57 2022 From: shade at openjdk.org (Aleksey Shipilev) Date: Mon, 22 Aug 2022 09:41:57 GMT Subject: RFR: CODETOOLS-7903176: Move LJV inside JOL [v2] In-Reply-To: References: Message-ID: On Mon, 22 Aug 2022 07:51:02 GMT, Ivan Ponomarev wrote: >> This moves https://github.com/atp-mipt/ljv project inside JOL in order for LJV to get access to internal JOL's APIs. >> >> See blogposts about LJV [in Russian](https://habr.com/ru/post/599045/) / [in English](https://dzone.com/articles/what-can-we-learn-from-java-data-structures-visual). > > Ivan Ponomarev has updated the pull request incrementally with one additional commit since the last revision: > > update copyright notice, lint Another round of review follows. .github/workflows/ljv.yml line 1: > 1: name: build My previous question still stands: can we merge it into current workflow? It would also test things with different Java versions then. jol-core/src/main/java/org/openjdk/jol/layouters/FieldAllocationType.java line 2: > 1: /* > 2: * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. File is not modified, we should not modify the copyright header either. jol-core/src/main/java/org/openjdk/jol/ljv/GraphvizVisualization.java line 37: > 35: private final LJV ljv; > 36: private final IdentityHashMap alreadyDrawnObjectsIds = new IdentityHashMap<>(); > 37: private boolean alreadyDrawnNull = false; Default value, so: Suggestion: private boolean alreadyDrawnNull; jol-core/src/main/java/org/openjdk/jol/ljv/GraphvizVisualization.java line 55: > 53: public void diagramBegin() { > 54: out.setLength(0); // Clearing String Builder before starting new DOT > 55: out.append("digraph Java {\n") Here and later, `\n` should actually be `System.lineSeparator()` to provide platform-independent line breaks. This would probably make golden test output platform-dependent, though? We can rehash this after the integration. jol-core/src/main/java/org/openjdk/jol/ljv/Introspection.java line 32: > 30: import java.util.List; > 31: > 32: public interface Introspection { Now that LJV is in JOL, can we "just" use its internals to introspect stuff, without doing LJV-specific walk? What's the plan here? jol-core/src/main/java/org/openjdk/jol/ljv/Introspection.java line 52: > 50: boolean canTreatObjAsPrimitive(Object obj); > 51: > 52: boolean catTreatObjAsArrayOfPrimitives(Object obj); Suggestion: boolean canTreatObjAsArrayOfPrimitives(Object obj); jol-core/src/main/java/org/openjdk/jol/ljv/IntrospectionWithReflectionAPI.java line 54: > 52: } > 53: > 54: // ?? ??????????????, ??????? ??????? ?? ???? ?????? ??? ??? ??? ???. Russian comment :) jol-core/src/main/java/org/openjdk/jol/ljv/LJV.java line 44: > 42: //- You should have received a copy of the GNU General Public License along > 43: //- with this program; if not, write to the Free Software Foundation, Inc., > 44: //- 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. Wait a second, what's this? Does this file borrow some external code? jol-core/src/main/java/org/openjdk/jol/ljv/Quote.java line 53: > 51: sb.append(c); > 52: else > 53: sb.append("\\\\0u").append(Integer.toHexString(c)); Braces, please. jol-core/src/main/java/org/openjdk/jol/ljv/pom.xml line 1: > 1: Weird to see this `pom.xml` in sources. Do you mean to merge parts of it into `jol-core/pom.xml`? jol-core/src/main/java/org/openjdk/jol/ljv/provider/ArrayElementAttributeProvider.java line 27: > 25: package org.openjdk.jol.ljv.provider; > 26: > 27: //@FunctionalInterface Leftover comment. jol-core/src/main/java/org/openjdk/jol/ljv/provider/NodeType.java line 33: > 31: NULL_REFERENCE, //we draw it as a separate node, we do not deduplicate nulls > 32: //'null' value can be either PRIMITIVE, NULL or IGNORE > 33: IGNORE //do not show Rewrite these comments as proper Javadoc? jol-core/src/main/java/org/openjdk/jol/ljv/provider/ObjectAttributesProvider.java line 31: > 29: */ > 30: > 31: //@FunctionalInterface Leftover comment. jol-core/src/main/java/org/openjdk/jol/util/IOUtils.java line 2: > 1: /* > 2: * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. Here a later, a whole bunch of files got their copyright years updated for no reason. jol-core/src/test/java/org/openjdk/jol/ljv/ArrayItem.java line 1: > 1: package org.openjdk.jol.ljv; Here and later, files are missing copyright headers. jol-core/src/test/java/org/openjdk/jol/ljv/HashCodeCollision.java line 9: > 7: * @author Ilya Selivanov > 8: */ > 9: public class HashCodeCollision { This file has a mix of identifier styles: `alphabet_list`, for example, should be `alphabetList`. ------------- Changes requested by shade (Committer). PR: https://git.openjdk.org/jol/pull/24 From shade at openjdk.org Mon Aug 22 09:41:57 2022 From: shade at openjdk.org (Aleksey Shipilev) Date: Mon, 22 Aug 2022 09:41:57 GMT Subject: RFR: CODETOOLS-7903176: Move LJV inside JOL [v2] In-Reply-To: References: Message-ID: On Mon, 22 Aug 2022 08:39:59 GMT, Aleksey Shipilev wrote: >> Ivan Ponomarev has updated the pull request incrementally with one additional commit since the last revision: >> >> update copyright notice, lint > > jol-core/src/test/java/org/openjdk/jol/ljv/HashCodeCollision.java line 9: > >> 7: * @author Ilya Selivanov >> 8: */ >> 9: public class HashCodeCollision { > > This file has a mix of identifier styles: `alphabet_list`, for example, should be `alphabetList`. There is also seem to be an easier way to generated hashcode collisions on Strings: just take any string, and add `Aa` and `BB` to it to produce different strings with the same hashcode: jshell> "seedAa".hashCode() $9 ==> -906232207 jshell> "seedBB".hashCode() $10 ==> -906232207 Repeat if you need more strings like these. ------------- PR: https://git.openjdk.org/jol/pull/24 From duke at openjdk.org Sat Aug 27 18:26:05 2022 From: duke at openjdk.org (Vladimir Plizga) Date: Sat, 27 Aug 2022 18:26:05 GMT Subject: RFR: CODETOOLS-7903262: JOL: GraphStatsWalker counts array elements incorrectly Message-ID: #### Observed behavior Current `GraphStatsWalker` implementation does not count size and quantity of objects directly contained in arrays. #### Desired behavior The `totalSize()` and `totalCount()` methods of a `GraphStats` instance should return the same values as the ones of `GraphLayout` instance built for the same object. #### Additional info There is a [simple unit test](https://gist.github.com/Toparvion/adec9052ad23e85e54d72b5bfb5a1aa3) that can be used to reproduce current behavior without checking out the fix branch. ------------- Commit messages: - Rename test method for GraphStatsWalker - Count sizes of arrays' object elements in GraphStatsWalker Changes: https://git.openjdk.org/jol/pull/33/files Webrev: https://webrevs.openjdk.org/?repo=jol&pr=33&range=00 Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903262 Stats: 19 lines in 2 files changed: 19 ins; 0 del; 0 mod Patch: https://git.openjdk.org/jol/pull/33.diff Fetch: git fetch https://git.openjdk.org/jol pull/33/head:pull/33 PR: https://git.openjdk.org/jol/pull/33 From shade at openjdk.org Sat Aug 27 18:26:07 2022 From: shade at openjdk.org (Aleksey Shipilev) Date: Sat, 27 Aug 2022 18:26:07 GMT Subject: RFR: CODETOOLS-7903262: JOL: GraphStatsWalker counts array elements incorrectly In-Reply-To: References: Message-ID: On Thu, 25 Aug 2022 04:32:58 GMT, Vladimir Plizga wrote: > #### Observed behavior > Current `GraphStatsWalker` implementation does not count size and quantity of objects directly contained in arrays. > > #### Desired behavior > The `totalSize()` and `totalCount()` methods of a `GraphStats` instance should return the same values as the ones of `GraphLayout` instance built for the same object. > > #### Additional info > There is a [simple unit test](https://gist.github.com/Toparvion/adec9052ad23e85e54d72b5bfb5a1aa3) that can be used to reproduce current behavior without checking out the fix branch. Oh, good find! I have a minor naming comment. Looks good. Bots would allow you to integrate once OCA is cleared. Please also go to https://github.com/Toparvion/jol/actions -- and push the button that allows testing workflows to run. > Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request. I would say yes, you can say `/signed` now. jol-core/src/test/java/org/openjdk/jol/info/GraphStatsTest.java line 97: > 95: > 96: @Test > 97: public void layoutAndStatsAccordance() { Suggestion: public void layoutAndStatsMatch() { ------------- PR: https://git.openjdk.org/jol/pull/33Marked as reviewed by shade (Committer). From duke at openjdk.org Sat Aug 27 18:26:07 2022 From: duke at openjdk.org (Vladimir Plizga) Date: Sat, 27 Aug 2022 18:26:07 GMT Subject: RFR: CODETOOLS-7903262: JOL: GraphStatsWalker counts array elements incorrectly In-Reply-To: References: Message-ID: <9FzNAYerYIdIrKFzZoG3zC1FZr0-Zq5qIx5J1lZbQOo=.80991b0b-edaa-43fb-b760-748ca95b7f84@github.com> On Thu, 25 Aug 2022 07:00:28 GMT, Aleksey Shipilev wrote: >> #### Observed behavior >> Current `GraphStatsWalker` implementation does not count size and quantity of objects directly contained in arrays. >> >> #### Desired behavior >> The `totalSize()` and `totalCount()` methods of a `GraphStats` instance should return the same values as the ones of `GraphLayout` instance built for the same object. >> >> #### Additional info >> There is a [simple unit test](https://gist.github.com/Toparvion/adec9052ad23e85e54d72b5bfb5a1aa3) that can be used to reproduce current behavior without checking out the fix branch. > > Please also go to https://github.com/Toparvion/jol/actions -- and push the button that allows testing workflows to run. @shipilev , thanks for suggestions! I've enabled the workflows (all have run successfully) and signed the OCA, now the document is under review. Should I wait for it to finish or can post the `/signed` comment right now? ------------- PR: https://git.openjdk.org/jol/pull/33 From duke at openjdk.org Mon Aug 29 05:51:32 2022 From: duke at openjdk.org (Vladimir Plizga) Date: Mon, 29 Aug 2022 05:51:32 GMT Subject: Integrated: CODETOOLS-7903262: JOL: GraphStatsWalker counts array elements incorrectly In-Reply-To: References: Message-ID: On Thu, 25 Aug 2022 04:32:58 GMT, Vladimir Plizga wrote: > #### Observed behavior > Current `GraphStatsWalker` implementation does not count size and quantity of objects directly contained in arrays. > > #### Desired behavior > The `totalSize()` and `totalCount()` methods of a `GraphStats` instance should return the same values as the ones of `GraphLayout` instance built for the same object. > > #### Additional info > There is a [simple unit test](https://gist.github.com/Toparvion/adec9052ad23e85e54d72b5bfb5a1aa3) that can be used to reproduce current behavior without checking out the fix branch. This pull request has now been integrated. Changeset: 76c554a0 Author: Vladimir Plizga Committer: Aleksey Shipilev URL: https://git.openjdk.org/jol/commit/76c554a0f8fac92e00e4a887808201eb48c5c905 Stats: 19 lines in 2 files changed: 19 ins; 0 del; 0 mod 7903262: JOL: GraphStatsWalker counts array elements incorrectly Reviewed-by: shade ------------- PR: https://git.openjdk.org/jol/pull/33