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

Adding class path with wildcard calls resetEnvironment repeatedly, can be very slow #5701

Closed
jpallas opened this issue Jul 19, 2017 · 4 comments
Assignees

Comments

@jpallas
Copy link
Contributor

jpallas commented Jul 19, 2017

If I use the %classpath add jar /path/to/dir/* wildcard mechanism, the default behavior (in BaseEvaluator.addJarToClassPath, called indirectly by MagicCommand.classpathAddJar) will end up calling resetEnvironment once for each jar file.

Now, the Scala interpreter is famously slow to start up, which even the most ardent fans will admit. The consequence in my case was that adding 209 jar files (from the Spark jars directory) blocked my Scala notebook for over ten minutes. I didn't do actual profiling, but every time I ran jstack I saw resetEnvironment in the stack, so I'm fairly confident about the cause.

@scottdraves
Copy link
Contributor

Hi Joe a fix has been merged to master, though I didn't have a good test for it.
Could you confirm it works for you?

@jpallas
Copy link
Contributor Author

jpallas commented Jul 24, 2017

Yes, that works. I can import the spark lib jars and run a simple session in about 35 seconds on my laptop. For the record, here's what my trivial Spark test notebook looks like.

%classpath add jar /usr/local/Cellar/apache-spark/2.2.0/libexec/jars/*
import org.apache.spark.sql.SparkSession
val spark = SparkSession.builder.appName("Beaker").master("local").getOrCreate()
import spark.implicits._
val ds = spark.createDataset(Seq(("this", "that"), ("one thing", "another")))
import scala.collection.JavaConverters._
ds.collect.toMap.asJava
spark.stop()

@jpallas jpallas closed this as completed Jul 24, 2017
michalgce added a commit that referenced this issue Jul 25, 2017
…ssage_after_succesfully_added_classpath

* origin/master: (24 commits)
  allow whitespace only cells, do not bother chelling for null code
  #5713 fix multiple clingOutputContainerLayoutManager instances (#5730)
  #5701 Optimize way of adding multiple jars to classpath. (#5729)
  #5657 plot tooltip should fade in out (#5705)
  fix #5711 by adding a readme
  further separate dev/user docs
  #5726 Separate install instructions into user and developer (#5727)
  bump version to 0.1.1
  #5715 Showing version of kernel in banner message. (#5719)
  instructions are for developers not users
  #5476 recipe in repo for conda forge (#5716)
  #5680 Renamed example jar resource. (#5717)
  #5699 pressing escape should close column search menu (#5709)
  #5698 column search should be case insensitive (#5708)
  remove the jar from our repo, add instructions to download it
  jarek/5702: remove tablesaw (#5712)
  #5703: add default imports (#5707)
  #5682 fix CyclingOutputContainerLayoutManager causes page to jump around (#5710)
  #5694 prevent user from dragging legend out of the plot (#5704)
  add tests for beakerx.widgets package (#5692)
  ...

# Conflicts:
#	kernel/base/src/main/java/com/twosigma/beakerx/evaluator/BaseEvaluator.java
#	kernel/base/src/main/java/com/twosigma/beakerx/evaluator/Evaluator.java
#	kernel/base/src/main/java/com/twosigma/beakerx/kernel/Kernel.java
#	kernel/base/src/main/java/com/twosigma/beakerx/kernel/KernelFunctionality.java
#	kernel/base/src/main/java/com/twosigma/beakerx/kernel/commands/MagicCommand.java
#	kernel/base/src/test/java/com/twosigma/beakerx/KernelTest.java
#	kernel/base/src/test/java/com/twosigma/beakerx/jupyter/handler/ExecuteRequestHandlerMagicCommandTest.java
@jpallas
Copy link
Contributor Author

jpallas commented Jul 26, 2017

This seems to have gotten broken by 9d7150b. MagicCommand.addJars is calling kernel.addJarToClassPath instead of kernel.addJarsToClassPath.

@scottdraves
Copy link
Contributor

my fault, should be good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants