Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runaway thread creation if used in BigStitcher-Spark #2

Closed
kgabor opened this issue Jan 4, 2023 · 3 comments · Fixed by #3
Closed

Runaway thread creation if used in BigStitcher-Spark #2

kgabor opened this issue Jan 4, 2023 · 3 comments · Fixed by #3
Assignees
Labels
bug Something isn't working

Comments

@kgabor
Copy link
Collaborator

kgabor commented Jan 4, 2023

If the zarr reader is used in BigStitcher-Spark AffineFusion, it creates new reader thread for each job chunk and fails to destroy them.

jupyter@7262e9376515:~/fusion_test_2022-12-01$ java -cp $(cat cp.txt) -Dspark.master=local 
net.preibisch.bigstitcher.spark.AffineFusion -x /home/jupyter/exaSPIM_609281_2022-11-03_proc_2022-11-22/affine_ip_alignment.xml -o /home/jupyter/test-spark1201 
--bdv 0,0 --storage N5 --xmlout=/home/jupyter/fusion_test_2022-12-01/dataset.xml
01:28:47.138 [Executor task launch worker for task 7] ERROR org.apache.spark.util.SparkUncaughtExceptionHandler - Uncaught exception in thread Thread[Executor task launch worker for task 7,5,main]
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:719)
        at net.imglib2.cache.queue.FetcherThreads.<init>(FetcherThreads.java:92)
        at net.imglib2.cache.queue.FetcherThreads.<init>(FetcherThreads.java:70)
        at bdv.util.volatiles.SharedQueue.<init>(SharedQueue.java:49)
        at bdv.util.volatiles.VolatileViews.wrapCachedCellImg(VolatileViews.java:178)
        at bdv.util.volatiles.VolatileViews.wrapAsVolatileViewData(VolatileViews.java:124)
        at bdv.util.volatiles.VolatileViews.wrapAsVolatile(VolatileViews.java:86)
        at bdv.util.volatiles.VolatileViews.wrapAsVolatile(VolatileViews.java:70)
        at bdv.img.omezarr.MultiscaleImage.init(MultiscaleImage.java:151)
        at bdv.img.omezarr.MultiscaleImage.getType(MultiscaleImage.java:246)
        at bdv.img.omezarr.ZarrImageLoader$SetupImgLoader.<init>(ZarrImageLoader.java:128)
        at bdv.img.omezarr.ZarrImageLoader.createSetupImgLoader(ZarrImageLoader.java:88)
        at bdv.img.omezarr.ZarrImageLoader.openZarr(ZarrImageLoader.java:62)
        at bdv.img.omezarr.ZarrImageLoader.getSetupImgLoader(ZarrImageLoader.java:345)
        at bdv.img.omezarr.ZarrImageLoader.getSetupImgLoader(ZarrImageLoader.java:37)
        at net.preibisch.bigstitcher.spark.util.ViewUtil.getTransformedBoundingBox(ViewUtil.java:32)
        at net.preibisch.bigstitcher.spark.AffineFusion.lambda$call$6156960b$1(AffineFusion.java:342)
        at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreach$1.apply(JavaRDDLike.scala:351)
        at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreach$1.apply(JavaRDDLike.scala:351)
        at scala.collection.Iterator$class.foreach(Iterator.scala:891)
        at org.apache.spark.InterruptibleIterator.foreach(InterruptibleIterator.scala:28)
        at org.apache.spark.rdd.RDD$$anonfun$foreach$1$$anonfun$apply$27.apply(RDD.scala:972)
        at org.apache.spark.rdd.RDD$$anonfun$foreach$1$$anonfun$apply$27.apply(RDD.scala:972)
        at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2101)
        at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2101)
        at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
        at org.apache.spark.scheduler.Task.run(Task.scala:123)
        at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:408)
        at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)
        at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:414)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)

Debug hint by @tpietzsch:setNumFetcherThreads(0) that is used by BigStitcher-Spark is not respected rather default thread creation is performed.

@kgabor kgabor added the bug Something isn't working label Jan 4, 2023
@kgabor kgabor linked a pull request Mar 9, 2023 that will close this issue
@kgabor kgabor self-assigned this Mar 10, 2023
@kgabor
Copy link
Collaborator Author

kgabor commented Mar 25, 2023

It seems that this bug is still around, this is a phase correlation run on 64 CPU with the development branch that supposed to respect setNumFetcherThreads
hs_err_pid717.log
.

@tpietzsch
Copy link
Member

Could you try to hardcode private int requestedNumFetcherThreads = 0; and see whether that fixes the problem?
(I suspect maybe openZarr() is called before setNumFetcherThreads(). If so, we should find a way to avoid that.)

@kgabor
Copy link
Collaborator Author

kgabor commented Apr 26, 2023

Could you try to hardcode private int requestedNumFetcherThreads = 0; and see whether that fixes the problem? (I suspect maybe openZarr() is called before setNumFetcherThreads(). If so, we should find a way to avoid that.)

The culprit was a missing isOpen=true in openZarr().

@kgabor kgabor closed this as completed in #3 Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants