-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Needless META-INF/resources and web-fragment.xml mounts #10164
Comments
Most jar files are not going to have either Could we use something like At the very very least, can't we unmount the jars that have nothing that we use so we can free the memory used to load them? @janbartel when we scan a jar for annotations, do we use these mounted resources or does ASM do it's own thing? |
When we scan a try (Stream<Path> classStream = Files.walk(path)) |
Those Paths are probably from a ZipFS, so probably mounted. Hmmm but we don't end up with all those classes mounted on the resource factory? So something different is happening. Either way, we need to see if we can be more efficient here |
NB If we want to get rid of the |
Actually, each jar file is only mounted once, but there is one mount object created for each If we don't need to keep the resources around after the jars have been scanned, we should change the scope of the |
I still think we should investigate if we can get resources from the classloader. Even 1 mount means that the jar is expanded into memory. |
ZipFs works via the |
So that's good.... But still I don't understand why there are entries for resources that do not exist? |
That's an inefficiency of the current implementation: multiple
|
@lorban the Mount logic in HEAD seems sane. I added the a testcase to prove this out in PR #10170 (a testcase that passes btw) Copy/Pasted here ... /**
* When mounting multiple points within the same JAR, only
* 1 mount should be created, but have reference counts
* tracked separately.
*/
@Test
public void testMountByJarName()
{
Path jarPath = MavenPaths.findTestResourceFile("jar-file-resource.jar");
URI uriRoot = URI.create("jar:" + jarPath.toUri().toASCIIString() + "!/"); // root
URI uriRez = URI.create("jar:" + jarPath.toUri().toASCIIString() + "!/rez/"); // dir
URI uriDeep = URI.create("jar:" + jarPath.toUri().toASCIIString() + "!/rez/deep/"); // dir
URI uriZzz = URI.create("jar:" + jarPath.toUri().toASCIIString() + "!/rez/deep/zzz"); // file
try (ResourceFactory.Closeable resourceFactory = ResourceFactory.closeable())
{
Resource resRoot = resourceFactory.newResource(uriRoot);
Resource resRez = resourceFactory.newResource(uriRez);
Resource resDeep = resourceFactory.newResource(uriDeep);
Resource resZzz = resourceFactory.newResource(uriZzz);
assertThat(FileSystemPool.INSTANCE.mounts().size(), is(1));
int mountCount = FileSystemPool.INSTANCE.getReferenceCount(uriRoot);
assertThat(mountCount, is(4));
}
} |
Looks like the dump is showing the tracked mounts of the ResourceFactory, not the tracked mounts of the FileSystemPool. The naming in the dump should be cleaned up. The excess entries is a different effort, I'll work on that too. |
Maybe only dump "references" that exist? |
Also pushed a new PR to fix the usages of |
Ensure JPMS and TLDs can coexist happily Better method naming per reviews Reworking MetaInfConfiguration with newer Java techniques in mind
Work in branch https://github.com/jetty/jetty.project/compare/fix/12.0.x/metainf-overhaul will be presented as a PR for 12.0.4 |
Closing as completed already. |
Jetty version(s)
12
Enhancement Description
If you deploy the ee10-demo-async-rest
and dump the server, you see that the ResourceFactory for the context contains a
META-INF/resources
andMETA-INF/web-fragment.xml
entries for every jar file, even though they do not exist.Either we should not mount these resources if they do not exist.... or if we are caching non-existence, we should exclude them from a dump.
The text was updated successfully, but these errors were encountered: