Skip to content

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

Closed
@eybisi

Description

@eybisi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUIIssues in jadx-gui modulebug

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions