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

Huge performance problem deserializing java.nio.file.Path with existing Windows Samba/CIFS mounts #3163

Open
Gaibhne opened this issue May 24, 2021 · 0 comments
Labels
performance Issue related to performance problems or enhancements

Comments

@Gaibhne
Copy link

Gaibhne commented May 24, 2021

Describe the bug
Deserializing a Path element uses File.listRoots(), which is very costly when the current user has any network mounts.

This bug is amplified by a large factor when the current user has failing network mounts (the cost of simply deserializing a Path object with a failing network mount is an insane ~10 seconds per failing mount), but I would expect (without having the setup to measure it) that there is still a considerable cost due to how NioPathDeserializer is set up.

Note that this happens when deserializing any Path elements, they don't need to be on the/a network share. Even deserializing 'C:' will suffer this bug.

Version information
Noticed it in 2.11.1, still present in latest as of reporting, 2.12.3.

To Reproduce
Due to the nature of this bug, it is only reproducible on a Windows system, and only when the user has network mounts - I'm not sure how one would go about adding one that later fails without a second system in the network to use.

  1. Code sample:

TestCase.java:

public class TestCase {
    public Path error;
}

Random App class:

public class App {
    public static void main(String[] args) {
        ObjectMapper mapper = new ObjectMapper(new YAMLFactor());
        TestCase test = mapper.readValue("erro: c:\\", TestCase.class);
    }
}
  1. Short snippet is enough to demonstrate the problem
  2. A Windows network mount needs to be set up, ideally a failing one (as in one where the mapped resource is unavailable)

Expected behavior
Code execution should be near instant.

Additional context
The problem exists in the JDK itself (tested up to 16), NioPathDeserializer line 30 (in my version; the line in question is for (File file : File.listRoots()) {) triggers the problem. I'm not sure the call is needed at that point, if I am reading the code correctly, in the case of attempting to resolve something like C: on a Windows system will always work, and on a non-Windows system will always result in an error, even without the check and special conditional branch for areWindowsFilePathsSupported.

@Gaibhne Gaibhne added the to-evaluate Issue that has been received but not yet evaluated label May 24, 2021
@cowtowncoder cowtowncoder added 2.13 performance Issue related to performance problems or enhancements and removed to-evaluate Issue that has been received but not yet evaluated labels May 26, 2021
@cowtowncoder cowtowncoder added 2.14 and removed 2.13 labels Jul 15, 2021
@cowtowncoder cowtowncoder removed the 2.14 label Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issue related to performance problems or enhancements
Projects
None yet
Development

No branches or pull requests

2 participants