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

Memory improvements related to PathTree and Manifests #42492

Merged
merged 2 commits into from
Aug 14, 2024

Conversation

gsmet
Copy link
Member

@gsmet gsmet commented Aug 12, 2024

@quarkus-bot quarkus-bot bot added the area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins label Aug 12, 2024
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();

protected OpenArchivePathTree(FileSystem fs) {
super(fs.getPath("/"), pathFilter, ArchivePathTree.this);
protected OpenArchivePathTree(Path archive, FileSystem fs) {
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't look like archive needs to be passed in here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually it needs to be passed but you're right, I wasn't setting things properly.

Copy link
Member

Choose a reason for hiding this comment

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

Why does it need to be passed in?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because of the hashCode/equals. We need something stable that is not leaking for them. The path of the archive makes perfect sense for that.

Copy link
Member

Choose a reason for hiding this comment

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

I mean archive from the outer class would be enough for that

Copy link
Member Author

Choose a reason for hiding this comment

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

I need it for SharedOpenArchivePathTree which extends this class.

@gsmet gsmet force-pushed the various-memory-improvements branch from c222639 to 683be07 Compare August 13, 2024 08:13

@Override
public Collection<Path> getRoots() {
return List.of(getRootPath());
Copy link
Member

Choose a reason for hiding this comment

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

In the current implementation, it would be getContainerPath()

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sure? Because in the case of an archive, we have:

  • containerPath: the path to the archive itself (for instance the directory or the path to the jar) - this doesn't exist in the previous implementation
  • rootPath: the path to the root of the archive. In the case of a directory, it's the same (the directory itself), in the case of an archive it's a ZipPath to the / of the archive

For me getRoots() returned actionable roots so they should use getRootPath().

Copy link
Member

Choose a reason for hiding this comment

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

For me getRoots() returned actionable roots so they should use getRootPath().

For a directory-backed PathTree - yes. For an ArchivePathTree it's the archive file. But I see your point if it's meant to replace the DirectoryPathTree.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I checked the callers and apparently it's used to get the path of the archive. I made the change and added a note to the javadoc.
Will push shortly.

Copy link
Member Author

Choose a reason for hiding this comment

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

There was actually one caller going through the roots as reported in: #42571 .

Reverted back to using getRootPath() in #42588 .

Some manifests are quite large, for instance the one for commons-codec
is 21 KB. Given most of the information in the Manifest are of no
interest to us, let's trim the Manifest to only the information we need.

Also we still have the problem of us keeping the jars open multiple
times in test and dev mode so it amplifies this issue.

In some cases, I ended up with 1700+ jars opened so the Manifests add up
quite quickly.
@gsmet gsmet force-pushed the various-memory-improvements branch from 683be07 to 488cfbc Compare August 14, 2024 07:25
@gsmet gsmet marked this pull request as ready for review August 14, 2024 07:32
A Path can actually contain references to the filesystem: this is the
case of the ZipPath.
We want to make sure we don't keep ZipFileSystem around when a path tree
is closed so we also need to nullify the path.

Finally, we make sure only DirectoryPathTree is marked as Serializable
as we only serialize the workspace directories.
@gsmet gsmet force-pushed the various-memory-improvements branch from 488cfbc to 6780c2c Compare August 14, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants