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

Fix file descriptor leak through worker classpath #173

Merged
merged 1 commit into from Aug 26, 2020
Merged

Fix file descriptor leak through worker classpath #173

merged 1 commit into from Aug 26, 2020

Conversation

oehme
Copy link
Contributor

@oehme oehme commented Aug 25, 2020

Workers created through the worker API live as long as the Gradle daemon.
Therefor, they should not have any JARs on their classpath that are part
of the project being built. Otherwise, the worker keeps these JARs open,
leading to a file descriptor leak and an unability to clean the project
on Windows. Also, on every change to the dependencies, a new worker would
be created, greatly increasing memory pressure on the system. Finally,
the workers of different subprojects would be incompatible due to their
different classpaths, increasing the number of spwawned workers even more.

This fix changes the worker such that only JMH is put on the worker classpath.
The project's own dependencies are passed to the worker as arguments.
Some trickery was necessary, because JMH insists on looking for project-specific
files on its own classpath. This should probably be reported as a bug to JMH.
It should either look on the Thread's context classloader (which we could change)
or make these locations externally configurable on the Runner class.

Fixes #170, #163

Workers created through the worker API live as long as the Gradle daemon.
Therefor, they should not have any JARs on their classpath that are part
of the project being built. Otherwise, the worker keeps these JARs open,
leading to a file descriptor leak and an unability to clean the project
on Windows. Also, on every change to the dependencies, a new worker would
be created, greatly increasing memory pressure on the system. Finally,
the workers of different subprojects would be incompatible due to their
different classpaths, increasing the number of spwawned workers even more.

This fix changes the worker such that only JMH is put on the worker classpath.
The project's own dependencies are passed to the worker as arguments.
Some trickery was necessary, because JMH insists on looking for project-specific
files on its own classpath. This should probably be reported as a bug to JMH.
It should either look on the Thread's context classloader (which we could change)
or make these locations externally configurable on the Runner class.
@melix melix merged commit 3fbe2da into melix:master Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot modify benchmark classes between jmh runs without killing daemon or using --no-daemon
2 participants