Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Slow Classloading with many jars on the classpath
Slow Classloading with many jars on the classpath [message #1854510] Tue, 23 August 2022 10:41 Go to next message
Hanno Wiegard is currently offline Hanno WiegardFriend
Messages: 2
Registered: August 2022
Junior Member
We have a plugin which contains 224 jars in the Bundle-ClassPath section. With all the jars the startup of the plugin is extremely slow and when combining them into a single fat jar the startup time goes down to 10- 15% of the original startup time. When investigating this further and gathering stack traces, a majority of time is spent in

  java.lang.Thread.State: RUNNABLE
	  at java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1593)
	  at java.util.zip.ZipFile$Source.<init>(ZipFile.java:1308)
	  at java.util.zip.ZipFile$Source.get(ZipFile.java:1271)
	  at java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:733)
	  at java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:850)
	  at java.util.zip.ZipFile.<init>(ZipFile.java:248)
	  at java.util.zip.ZipFile.<init>(ZipFile.java:177)
	  at java.util.zip.ZipFile.<init>(ZipFile.java:191)
	  at org.eclipse.osgi.framework.util.SecureAction.getZipFile(SecureAction.java:342)
	  at org.eclipse.osgi.storage.bundlefile.ZipBundleFile.doOpen(ZipBundleFile.java:51)
	  at org.eclipse.osgi.storage.bundlefile.CloseableBundleFile.internalOpen(CloseableBundleFile.java:140)
	  at org.eclipse.osgi.storage.bundlefile.CloseableBundleFile.lockOpen(CloseableBundleFile.java:78)
	  at org.eclipse.osgi.storage.bundlefile.CloseableBundleFile.getEntry(CloseableBundleFile.java:274)
	  at org.eclipse.osgi.storage.bundlefile.BundleFile.getResourceURL(BundleFile.java:142)
	  at org.eclipse.osgi.internal.loader.classpath.ClasspathEntry.findResource(ClasspathEntry.java:213)
	  at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalResources(ClasspathManager.java:466)
	  at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalResources(ClasspathManager.java:452)
	  at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalResources(ModuleClassLoader.java:331)
	  at org.eclipse.osgi.internal.loader.BundleLoader.findLocalResources(BundleLoader.java:922)
	  at org.eclipse.osgi.internal.loader.BundleLoader.findResources(BundleLoader.java:781)
	  at org.eclipse.osgi.internal.loader.ModuleClassLoader.getResources(ModuleClassLoader.java:240)
	  at org.apache.logging.log4j.util.LoaderUtil.findUrlResources(LoaderUtil.java:273)
	  at org.apache.logging.log4j.util.LoaderUtil.findResources(LoaderUtil.java:254)
	  at org.apache.logging.log4j.util.PropertyFilePropertySource.loadPropertiesFile(PropertyFilePropertySource.java:41)
	  at org.apache.logging.log4j.util.PropertyFilePropertySource.<init>(PropertyFilePropertySource.java:36)
	  at org.apache.logging.log4j.util.PropertiesUtil$Environment.<init>(PropertiesUtil.java:449)
	  at org.apache.logging.log4j.util.PropertiesUtil$Environment.<init>(PropertiesUtil.java:434)
	  at org.apache.logging.log4j.util.PropertiesUtil.<init>(PropertiesUtil.java:88)
	  at org.apache.logging.log4j.util.PropertiesUtil.<init>(PropertiesUtil.java:80)
	  at org.apache.logging.log4j.util.PropertiesUtil.<clinit>(PropertiesUtil.java:56)
	  at org.apache.logging.log4j.util.Constants.<clinit>(Constants.java:30)
	  at org.apache.logging.log4j.spi.AbstractLogger.createClassForProperty(AbstractLogger.java:207)
	  at org.apache.logging.log4j.spi.AbstractLogger.<clinit>(AbstractLogger.java:95)
	  at org.apache.logging.log4j.core.AbstractLifeCycle.<clinit>(AbstractLifeCycle.java:38)


The part with the ModuleClassloader and opening ZipFiles stays all the time.

The Manifest is fairly simple:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: BundleTest
Bundle-SymbolicName: com.BundleTest; singleton:=true
Bundle-Version: 1.0.0
Bundle-ClassPath: ...,
Bundle-Activator: com.BundleTest.Plugin
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: com.ibm.icu,
 org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.core.resources,
 org.eclipse.ui.ide,
 org.eclipse.ui.intro,
 org.eclipse.ui.console,
 org.eclipse.jface.text,
 org.eclipse.debug.ui,
 org.eclipse.ui.forms,
 org.eclipse.ui.views,
 org.eclipse.search,
 org.eclipse.gef,
 org.eclipse.birt.chart.device.extension;resolution:=optional,
 org.eclipse.birt.chart.engine;resolution:=optional,
 org.eclipse.birt.chart.engine.extension;resolution:=optional,
 org.eclipse.birt.chart.ui;resolution:=optional,
 org.eclipse.birt.chart.ui.extension;resolution:=optional,
 org.eclipse.birt.core;resolution:=optional,
 org.apache.batik;resolution:=optional,
 org.eclipse.emf.ecore,
 org.eclipse.debug.core,
 org.eclipse.ui.workbench.texteditor
Eclipse-LazyStart: true


where I have omitted the classpath.

Is there any alternative to combining all the jars into a fat jar?
Re: Slow Classloading with many jars on the classpath [message #1854519 is a reply to message #1854510] Tue, 23 August 2022 15:20 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
I suspect you are thrashing the bundle file closer which is trying to limit the number of open bundle JAR files to 100 being opened at a time. Try setting the value osgi.bundlefile.limit in your config.ini file. If set to 0 (zero) the closer will be disabled altogether. That can result in running out of file handles when having large number of bundles installed. Especially if you have many that have such a large bundle class path.

But you could try setting it to a much larger number than 100. Something like 1000:


osgi.bundlefile.limit=1000

Re: Slow Classloading with many jars on the classpath [message #1854632 is a reply to message #1854519] Wed, 31 August 2022 09:38 Go to previous message
Hanno Wiegard is currently offline Hanno WiegardFriend
Messages: 2
Registered: August 2022
Junior Member
Thank you, that suggestion helped a lot!
Previous Topic:Publishing artifacts throws error
Next Topic:Issue with org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher
Goto Forum:
  


Current Time: Sat Oct 05 16:04:08 GMT 2024

Powered by FUDForum. Page generated in 0.03594 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top