Skip to content

TEZ-4275: Use Google Guava Intern Facility - #95

Merged
jteagles merged 5 commits into
apache:masterfrom
belugabehr:TEZ-4275
Jun 30, 2021
Merged

TEZ-4275: Use Google Guava Intern Facility#95
jteagles merged 5 commits into
apache:masterfrom
belugabehr:TEZ-4275

Conversation

@belugabehr

Copy link
Copy Markdown
Contributor

No description provided.

@belugabehrbelugabehr reopened this Feb 8, 2021
Comment on lines +869 to +873

// Hint to the JVM to clean up anything no longer needed; be ready for the next DAG
System.gc();
System.runFinalization();

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it is helpful to role this change into this ticket or not. However, the clearCache stuff is pretty useless. All it does is make the map entries available for garbage collection,... which they already are by design.

However, this here will hint to the JDK to actually clean up that stuff. Hinting to the JDK at this points seems like a reasonable thing to do between DAGs, but I'm not sure if it's worthwhile.

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

OK @jteagles@abstractdog this PR is failing on some pre-existing find bugs error. Kind of funny actually:

Null passed for non-null parameter of com.google.common.base.Strings.isNullOrEmpty(String)

The method has isNull in the name of it, of course it can accept a null value. :D

Please consider these changes as they should lower memory requirements, provide faster concurrent access, and simplify the code a bit. In particular, please consider my thoughts here:

#95 (comment)

@abstractdog

Copy link
Copy Markdown
Contributor

OK @jteagles@abstractdog this PR is failing on some pre-existing find bugs error. Kind of funny actually:

Null passed for non-null parameter of com.google.common.base.Strings.isNullOrEmpty(String)

The method has isNull in the name of it, of course it can accept a null value. :D

Please consider these changes as they should lower memory requirements, provide faster concurrent access, and simplify the code a bit. In particular, please consider my thoughts here:

#95 (comment)

yeah, absolutely, we've also found similar isNull* madness in https://issues.apache.org/jira/browse/TEZ-4215, I believe we should merge that @jteagles, and @belugabehr you can handle this in a similar way...if findbugs warning simply doesn't makes sense, let's try to ignore it

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

@abstractdog@jteagles Any thoughts on this?

@jteagles

Copy link
Copy Markdown
Contributor

@belugabehr can you compare speed and memory consumption with current implementation? I have a test that can be used to measure.
https://issues.apache.org/jira/browse/TEZ-1526
https://issues.apache.org/jira/secure/attachment/12857710/TEZ-1526.memory.test.patch
mvn clean test -Dtest=TestTezIds#testIdGetInstancePerformance -pl tez-common -am

Then compare

  • tez-common/target/surefire-reports/org.apache.tez.dag.records.TestTezIds.txt
  • tez-common/target/surefire-reports/org.apache.tez.dag.records.TestTezIds-output.txt

@belugabehr

Copy link
Copy Markdown
ContributorAuthor
== TEZ-4275 ==
TEZ-1526: heap used memory: 100000:26299128
TEZ-1526: heap used memory: 200000:12867000
TEZ-1526: heap used memory: 300000:46693400
TEZ-1526: heap used memory: 400000:76540520
TEZ-1526: heap used memory: 500000:106386920
TEZ-1526: heap used memory: 600000:40765776
TEZ-1526: heap used memory: 700000:70625496
...
TEZ-1526: heap used memory: 9300000:115818312
TEZ-1526: heap used memory: 9400000:143028440
TEZ-1526: heap used memory: 9500000:177041136
TEZ-1526: heap used memory: 9600000:204251344
TEZ-1526: heap used memory: 9700000:231461552
TEZ-1526: heap used memory: 9800000:265474312
TEZ-1526: heap used memory: 9900000:292684504
TEZ-1526: heap used memory: 10000000:326697216
== master ==
TEZ-1526: heap used memory: 100000:29985368
TEZ-1526: heap used memory: 200000:20945736
TEZ-1526: heap used memory: 300000:54775896
TEZ-1526: heap used memory: 400000:84626224
TEZ-1526: heap used memory: 500000:15007832
TEZ-1526: heap used memory: 600000:48851936
TEZ-1526: heap used memory: 700000:78714376
...
TEZ-1526: heap used memory: 9300000:171467736
TEZ-1526: heap used memory: 9400000:198175528
TEZ-1526: heap used memory: 9500000:224883320
TEZ-1526: heap used memory: 9600000:258268056
TEZ-1526: heap used memory: 9700000:284975880
TEZ-1526: heap used memory: 9800000:318360616
TEZ-1526: heap used memory: 9900000:345068408
TEZ-1526: heap used memory: 10000000:44603528
== TEZ-4275 ==
-------------------------------------------------------------------------------
Test set: org.apache.tez.dag.records.TestTezIds
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.648 s - in org.apache.tez.dag.records.TestTezIds
== master ==
-------------------------------------------------------------------------------
Test set: org.apache.tez.dag.records.TestTezIds
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.937 s - in org.apache.tez.dag.records.TestTezIds

@belugabehr

belugabehr commented Mar 3, 2021

Copy link
Copy Markdown
ContributorAuthor

Results match my expectations. If nothing else, Guava uses a Map with the cached value (as key) and a dummy singleton value. Current implementation uses a Map with the cached value (as key) and a new value. That'll save some memory.

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

Also, I suspect Guava version is better in multi-threaded environment since it locks on "regions" of the map instead of locking on the entire map (master). I ran a few quick and dirty sanity checks by wrapping the proposed unit test in a thread and launching 4 of them...

master: 3.7s - 4.2s
TEZ-4275: 3.4s - 3.6s

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

16 Threads yielded a similar 10% improvement in throughput

@belugabehr

Copy link
Copy Markdown
ContributorAuthor
[2021-02-10T18:17:40.551Z] Reason | Tests
[2021-02-10T18:17:40.551Z] FindBugs | module:tez-dag [2021-02-10T18:17:40.551Z] | org.apache.tez.dag.app.DAGAppMaster.handle(DAGAppMasterEvent) forces garbage collection; extremely dubious except in benchmarking code At DAGAppMaster.java:dubious except in benchmarking code At DAGAppMaster.java:[line 872] 

Hello, what do you think about this PR as it currently stands?

@jteagles

Copy link
Copy Markdown
Contributor

If the GC isn't strictly needed can it be taken out?

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

@jteagles Yes. It can be.

There may be some value though to hinting that now (between DAGs) is a good time to cleanup, and I was mimicking the previous code that was attempting to cleanup these caches. Just let me know, I don't have a feeling (or data) on it one way or another.

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

@jteagles What would your preference be here?

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

@jteagles@abstractdog OK. I took out the GC hint and it builds without the warning.

Thanks!

@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec17m 55sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚test4tests0m 0sThe patch appears to include 1 new or modified test files.
_ master Compile Tests _
+0 🆗mvndep4m 25sMaven dependency ordering for branch
+1 💚mvninstall9m 10smaster passed
+1 💚compile3m 20smaster passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚compile2m 59smaster passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+1 💚checkstyle2m 51smaster passed
+1 💚javadoc2m 56smaster passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚javadoc2m 40smaster passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+0 🆗spotbugs0m 43sUsed deprecated FindBugs config; considering switching to SpotBugs.
+0 🆗findbugs0m 41stez-tools/analyzers/job-analyzer in master has 4 extant findbugs warnings.
_ Patch Compile Tests _
+0 🆗mvndep0m 9sMaven dependency ordering for patch
+1 💚mvninstall2m 9sthe patch passed
+1 💚compile1m 57sthe patch passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚javac1m 57sthe patch passed
+1 💚compile1m 38sthe patch passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+1 💚javac1m 38sthe patch passed
+1 💚checkstyle0m 9stez-common: The patch generated 0 new + 25 unchanged - 1 fixed = 25 total (was 26)
+1 💚checkstyle0m 9sThe patch passed checkstyle in tez-runtime-internals
+1 💚checkstyle0m 14stez-runtime-library: The patch generated 0 new + 30 unchanged - 1 fixed = 30 total (was 31)
+1 💚checkstyle0m 25sThe patch passed checkstyle in tez-dag
+1 💚checkstyle0m 9sThe patch passed checkstyle in tez-history-parser
+1 💚checkstyle0m 9stez-tools/analyzers/job-analyzer: The patch generated 0 new + 18 unchanged - 2 fixed = 18 total (was 20)
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc1m 32sthe patch passed with JDK Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04
+1 💚javadoc1m 23sthe patch passed with JDK Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
+1 💚findbugs4m 32sthe patch passed
_ Other Tests _
+1 💚unit0m 29stez-common in the patch passed.
+1 💚unit0m 31stez-runtime-internals in the patch passed.
+1 💚unit4m 56stez-runtime-library in the patch passed.
+1 💚unit4m 8stez-dag in the patch passed.
+1 💚unit2m 11stez-history-parser in the patch passed.
+1 💚unit2m 24sjob-analyzer in the patch passed.
+1 💚asflicense0m 50sThe patch does not generate ASF License warnings.
83m 58s
SubsystemReport/Notes
DockerClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-95/6/artifact/out/Dockerfile
GITHUB PR#95
JIRA IssueTEZ-4275
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs checkstyle compile
unameLinux dcbb343a39ac 4.15.0-128-generic #131-Ubuntu SMP Wed Dec 9 06:57:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitypersonality/tez.sh
git revisionmaster / 0184781
Default JavaPrivate Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
Multi-JDK versions/usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.11+9-Ubuntu-0ubuntu2.20.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_292-8u292-b10-0ubuntu1~20.04-b10
Test Resultshttps://ci-hadoop.apache.org/job/tez-multibranch/job/PR-95/6/testReport/
Max. process+thread count789 (vs. ulimit of 5500)
modulesC: tez-common tez-runtime-internals tez-runtime-library tez-dag tez-plugins/tez-history-parser tez-tools/analyzers/job-analyzer U: .
Console outputhttps://ci-hadoop.apache.org/job/tez-multibranch/job/PR-95/6/console
versionsgit=2.25.1 maven=3.6.3 findbugs=3.0.1
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

@abstractdog Just a gentle reminder about this PR.

@pgaref Do you know anyone that can assist here?

@abstractdog

Copy link
Copy Markdown
Contributor

hi @belugabehr! I just ran through the history, memory/speed improvement is promising, also you removed every questioned part, so this looks good to me
it's a +1 from my side

@belugabehr

Copy link
Copy Markdown
ContributorAuthor

@abstractdog Can you please assist with a merge? Thanks!

@jteagles

Copy link
Copy Markdown
Contributor

+1. Got distracted away from this PR. I'll do the merge shortly.

@jteagles
jteagles merged commit 984d09c into apache:masterJun 30, 2021
@belugabehr

Copy link
Copy Markdown
ContributorAuthor

No worries! Thanks @jteagles

asfgit pushed a commit that referenced this pull request Jun 30, 2021
* TEZ-4275: Use Google Guava Intern Facility
* Also add hint for running finalization
* Use Guava String Intern implementation
* Fix checkstyle, white-space issues
* Remove GC hint
Co-authored-by: David Mollitor <david.mollitor@cloudera.com>
(cherry picked from commit 984d09c)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@belugabehr@abstractdog@jteagles@hadoop-yetus