Skip to content

TEZ-4479: Eagerly Init/Load FileSystem In Tez Task Containers - #274

Open
shameersss1 wants to merge 1 commit into
apache:masterfrom
shameersss1:TEZ-4479
Open

TEZ-4479: Eagerly Init/Load FileSystem In Tez Task Containers#274
shameersss1 wants to merge 1 commit into
apache:masterfrom
shameersss1:TEZ-4479

Conversation

@shameersss1

Copy link
Copy Markdown
Contributor

Initing/Loading FileSystem such as S3 can take ~10s - ~20s when called for the first time and the time taken for subsequent calls are negligable. If we can load the FileSystem much before it is used can help us to save some time. It can be especially useful in case of pre-warm Tez containers where the Tez task containers comes up when the Application Master (AM) is launched and not on-demand which is the default behavior. It can be also useful in cases where the Mapper tasks spends considerable time consuming the upstream shuffle data and then heads to process some FileSystem operations, in all such cases we have few FileSystem load up time.

@tez-yetus

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec25m 4sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚@author0m 0sThe patch does not contain any @author tags.
-1 ❌test4tests0m 0sThe patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ master Compile Tests _
+0 🆗mvndep6m 35sMaven dependency ordering for branch
+1 💚mvninstall10m 49smaster passed
+1 💚compile0m 59smaster passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04
+1 💚compile0m 53smaster passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
+1 💚checkstyle0m 56smaster passed
+1 💚javadoc1m 8smaster passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04
+1 💚javadoc0m 56smaster passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
+0 🆗spotbugs0m 43sUsed deprecated FindBugs config; considering switching to SpotBugs.
+1 💚findbugs2m 10smaster passed
_ Patch Compile Tests _
+0 🆗mvndep0m 9sMaven dependency ordering for patch
+1 💚mvninstall0m 37sthe patch passed
+1 💚compile0m 40sthe patch passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04
+1 💚javac0m 40sthe patch passed
+1 💚compile0m 35sthe patch passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
+1 💚javac0m 35sthe patch passed
+1 💚checkstyle0m 20sthe patch passed
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 37sthe patch passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04
+1 💚javadoc0m 36sthe patch passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
-1 ❌findbugs0m 41stez-runtime-internals generated 1 new + 0 unchanged - 0 fixed = 1 total (was 0)
_ Other Tests _
+1 💚unit2m 12stez-api in the patch passed.
+1 💚unit0m 35stez-runtime-internals in the patch passed.
+1 💚asflicense0m 21sThe patch does not generate ASF License warnings.
59m 1s
ReasonTests
FindBugsmodule:tez-runtime-internals
Incorrect lazy initialization of static field org.apache.tez.runtime.task.TezChild.eagerInitFsPool in org.apache.tez.runtime.task.TezChild.eagerInitFileSystemPaths(Configuration) At TezChild.java:field org.apache.tez.runtime.task.TezChild.eagerInitFsPool in org.apache.tez.runtime.task.TezChild.eagerInitFileSystemPaths(Configuration) At TezChild.java:[lines 512-513]
SubsystemReport/Notes
DockerClientAPI=1.42 ServerAPI=1.42 base: https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-274/1/artifact/out/Dockerfile
GITHUB PR#274
JIRA IssueTEZ-4479
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs checkstyle compile
unameLinux 582a4107fe97 4.15.0-200-generic #211-Ubuntu SMP Thu Nov 24 18:16:04 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitypersonality/tez.sh
git revisionmaster / 6bd6f9c
Default JavaPrivate Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
Multi-JDK versions/usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
findbugshttps://ci-hadoop.apache.org/job/tez-multibranch/job/PR-274/1/artifact/out/new-findbugs-tez-runtime-internals.html
Test Resultshttps://ci-hadoop.apache.org/job/tez-multibranch/job/PR-274/1/testReport/
Max. process+thread count385 (vs. ulimit of 5500)
modulesC: tez-api tez-runtime-internals U: .
Console outputhttps://ci-hadoop.apache.org/job/tez-multibranch/job/PR-274/1/console
versionsgit=2.34.1 maven=3.6.3 findbugs=3.0.1
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

@shameersss1

Copy link
Copy Markdown
ContributorAuthor

@abstractdog Could you please review the changes?

* String value. Comma seperated list of FileSystem paths which needs to be eagerly initialized.
* For example s3://bucket/,file://,hdfs://localhost:8020/
*/
@ConfigurationScope(Scope.AM)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Scope is VERTEX as we're doing this in TezChild
  2. constant name should contain TEZ_ prefix

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.

ack.

public void run() {
try {
new Path(path).getFileSystem(conf);
LOG.info("Eagerly initiated FileSystem at path {}", path);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it would be nice to measure the time spent with initialization and print it to logs too

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.

ack.

if (eagerInitFsPool == null && !eagerInitPaths.isEmpty()) {
eagerInitFsPool = Executors.newCachedThreadPool(new ThreadFactoryBuilder()
.setDaemon(true)
.setPriority(Thread.MAX_PRIORITY)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

in the code, I can see we tend not to set priority in thread pools...I guess we can remove this to simplify this code further

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.

ack.

@Override
public void run() {
try {
new Path(path).getFileSystem(conf);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't this filesystem be closed? does it hold any resources when it's open?

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.

Wouldn't this be gc'ed eventually? I can see any instances in the code were we are not explicitly closing the filesystem object. For example : https://github.com/apache/tez/blob/master/tez-plugins/tez-protobuf-history-plugin/src/main/java/org/apache/tez/dag/history/logging/proto/DatePartitionedLogger.java#L136

@tez-yetus

Copy link
Copy Markdown

💔 -1 overall

VoteSubsystemRuntimeComment
+0 🆗reexec22m 58sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+1 💚@author0m 0sThe patch does not contain any @author tags.
-1 ❌test4tests0m 0sThe patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ master Compile Tests _
+0 🆗mvndep6m 15sMaven dependency ordering for branch
+1 💚mvninstall10m 15smaster passed
+1 💚compile1m 4smaster passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04
+1 💚compile1m 1smaster passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
+1 💚checkstyle1m 5smaster passed
+1 💚javadoc1m 12smaster passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04
+1 💚javadoc1m 5smaster passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
+0 🆗spotbugs0m 43sUsed deprecated FindBugs config; considering switching to SpotBugs.
+1 💚findbugs2m 4smaster passed
_ Patch Compile Tests _
+0 🆗mvndep0m 10sMaven dependency ordering for patch
+1 💚mvninstall0m 37sthe patch passed
+1 💚compile0m 38sthe patch passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04
+1 💚javac0m 38sthe patch passed
+1 💚compile0m 34sthe patch passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
+1 💚javac0m 34sthe patch passed
+1 💚checkstyle0m 21sthe patch passed
+1 💚whitespace0m 0sThe patch has no whitespace issues.
+1 💚javadoc0m 36sthe patch passed with JDK Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04
+1 💚javadoc0m 37sthe patch passed with JDK Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
-1 ❌findbugs0m 40stez-runtime-internals generated 2 new + 0 unchanged - 0 fixed = 2 total (was 0)
_ Other Tests _
+1 💚unit2m 11stez-api in the patch passed.
+1 💚unit0m 37stez-runtime-internals in the patch passed.
+1 💚asflicense0m 21sThe patch does not generate ASF License warnings.
56m 31s
ReasonTests
FindBugsmodule:tez-runtime-internals
Incorrect lazy initialization of static field org.apache.tez.runtime.task.TezChild.eagerInitFsPool in org.apache.tez.runtime.task.TezChild.eagerInitFileSystemPaths(Configuration) At TezChild.java:field org.apache.tez.runtime.task.TezChild.eagerInitFsPool in org.apache.tez.runtime.task.TezChild.eagerInitFileSystemPaths(Configuration) At TezChild.java:[lines 512-513]
Dead store to fs in org.apache.tez.runtime.task.TezChild$3.run() At TezChild.java:org.apache.tez.runtime.task.TezChild$3.run() At TezChild.java:[line 524]
SubsystemReport/Notes
DockerClientAPI=1.42 ServerAPI=1.42 base: https://ci-hadoop.apache.org/job/tez-multibranch/job/PR-274/2/artifact/out/Dockerfile
GITHUB PR#274
JIRA IssueTEZ-4479
Optional Testsdupname asflicense javac javadoc unit spotbugs findbugs checkstyle compile
unameLinux a0619e798ce7 4.15.0-206-generic #217-Ubuntu SMP Fri Feb 3 19:10:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitypersonality/tez.sh
git revisionmaster / 25a9536
Default JavaPrivate Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
Multi-JDK versions/usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.18+10-post-Ubuntu-0ubuntu122.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_362-8u362-ga-0ubuntu1~22.04-b09
findbugshttps://ci-hadoop.apache.org/job/tez-multibranch/job/PR-274/2/artifact/out/new-findbugs-tez-runtime-internals.html
Test Resultshttps://ci-hadoop.apache.org/job/tez-multibranch/job/PR-274/2/testReport/
Max. process+thread count388 (vs. ulimit of 5500)
modulesC: tez-api tez-runtime-internals U: .
Console outputhttps://ci-hadoop.apache.org/job/tez-multibranch/job/PR-274/2/console
versionsgit=2.34.1 maven=3.6.3 findbugs=3.0.1
Powered byApache Yetus 0.12.0 https://yetus.apache.org

This message was automatically generated.

hadoopShim);
}

private static void eagerInitFileSystemPaths(Configuration conf) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It will be good to measure the time spent on FS init (even for cloudstores) and share the details, before trying out this patch.

Reason: This get inited in TezChild, but for running container, it closes the FileSystem explicitly via "FileSystem.closeAllForUGI(childUGI);". Refer "public ContainerExecutionResult run()" method.

Even if this gets early inited, it will not have major impact in container reuse scenario. It will be good to measure and find out the timing spent in FS init.

.build());
}
for (String path : eagerInitPaths) {
eagerInitFsPool.execute(new Runnable() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

before rushing to create lots of fs instances in parallel, look at HADOOP-17313 and why we actually added semaphores to stop apps like tez creating too many at the same time. this code may cause overload problems, or the fs semaphore will hold you back for safety.

best to look at why its taking so long; if s3a bucket existence checks aren't involved, then it'll be whatever auth mechanism is plugged in. same for abfs

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.

5 participants

@shameersss1@tez-yetus@steveloughran@abstractdog@rbalamohan