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

[gui] cache clear/removal can be in parallel #2436

Open
2 of 3 tasks
eybisi opened this issue Mar 7, 2025 · 1 comment
Open
2 of 3 tasks

[gui] cache clear/removal can be in parallel #2436

eybisi opened this issue Mar 7, 2025 · 1 comment
Labels
bug GUI Issues in jadx-gui module

Comments

@eybisi
Copy link
Contributor

eybisi commented Mar 7, 2025

Issue details

Current implementation waits file deletion to continue. Same thing goes for cache clearing. Instead, after collecting files and directories, they can be deleted in parallel like following:

			Files.walkFileTree(dir, Collections.emptySet(), Integer.MAX_VALUE, new SimpleFileVisitor<>() {
				@Override
				public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
					files.add(file);
					return FileVisitResult.CONTINUE;
				}
				@Override
				public FileVisitResult postVisitDirectory(Path directory, IOException exc) {
					directories.add(directory);
					return FileVisitResult.CONTINUE;
				}
			});
			files.parallelStream().forEach(path -> {
				try {
					Files.delete(path);
				} catch (IOException e) {
					throw new JadxRuntimeException("Failed to delete directory " + path.toAbsolutePath(), e);
				}
			});
			for (Path directory : directories) {
				try {
					Files.delete(directory);
				} catch (IOException e) {
					throw new JadxRuntimeException("Failed to delete directory " + directory.toAbsolutePath(), e);
				}
			}

For my sample apk (on windows) current implementation takes around 10 seconds to delete. (decompiled all classes). By doing it parallel it takes around 1 second. Are there any drawbacks to delete files in parallel ?

Jadx version

dev

Java version

21.0.5

OS

  • Windows
  • Linux
  • macOS
@eybisi eybisi added bug GUI Issues in jadx-gui module labels Mar 7, 2025
@skylot
Copy link
Owner

skylot commented Mar 7, 2025

@eybisi looks great!

Are there any drawbacks to delete files in parallel ?

It is fine. The only possible drawback is that file system can change after files collection but before deletion start. This is not a big issue, and current implementation also have same drawback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug GUI Issues in jadx-gui module
Projects
None yet
Development

No branches or pull requests

2 participants