checkDataIntegrity - borg mount optimizations;

git-svn-id: svn://home0/checkDataIntegrity@3518 71dcc7fd-b1f2-4e5d-bb8e-274146e81173
This commit is contained in:
(no author)
2024-03-11 19:41:13 +00:00
parent 3782568df6
commit 93a166ea8a
8 changed files with 40 additions and 37 deletions

View File

@@ -1,6 +1,6 @@
package checkDataIntegrity;
record Args(String path0, String path1, int skip, int timeLimit) {
record Args(String path0, String path1, int threads, int skip, int timeLimit) {
}

View File

@@ -9,7 +9,7 @@ class BufferPool {
static byte[] get() {
byte[] buf = queue.poll();
if (buf == null) {
buf = new byte[16384];
buf = new byte[4096];
}
return buf;
}

View File

@@ -18,9 +18,46 @@ public class Main {
}
final ProgramState state = new ProgramState(System.currentTimeMillis(), new AtomicLong(), new AtomicLong(), new AtomicLong());
final WorkerPool workerPool = new WorkerPool(parsedArgs, state, parsedArgs.threads());
final WorkerPool workerPool = new WorkerPool(parsedArgs, state, 32);
walk(parsedArgs, state, workerPool);
workerPool.awaitEmpty();
workerPool.interrupt();
workerPool.join();
printStats(state);
System.exit(state.countErr().get() > 0 ? 1 : 0);
}
private static Args parseArgs(final String[] args) {
if (args.length < 4) {
System.err.println("Usage: checkDataIntegrity.java <Path0> <Path1> <threads> <skip> <timeLimit ms>");
return null;
}
final Args result = new Args(
args[0],
args[1],
Integer.parseInt(args[2]),
Integer.parseInt(args[3]),
Integer.parseInt(args[4]));
System.out.println(result);
return result;
}
private static void printStats(final ProgramState state) {
final Duration duration = Duration.ofMillis(System.currentTimeMillis() - state.start());
System.out.println("Took: " + duration.toString());
System.out.println("Files checked: " + state.count().get());
if (duration.toSeconds() > 0) {
System.out.println("Throughput: " + (state.bytes().get() / duration.toSeconds() / 1024 / 1024) + " Mib/s");
}
System.out.println("Errors: " + state.countErr().get());
}
private static void walk(final Args parsedArgs, final ProgramState state, final WorkerPool workerPool) throws IOException {
final AtomicLong walkTreeCounter = new AtomicLong();
Files.walkFileTree(Path.of(parsedArgs.path0()), new FileVisitor<>() {
@@ -57,39 +94,5 @@ public class Main {
return FileVisitResult.CONTINUE;
}
});
workerPool.awaitEmpty();
workerPool.interrupt();
workerPool.join();
printStats(state);
System.exit(state.countErr().get() > 0 ? 1 : 0);
}
private static Args parseArgs(final String[] args) {
if (args.length < 4) {
System.err.println("Usage: checkDataIntegrity.java <Path0> <Path1> <skip> <timeLimit ms>");
return null;
}
final Args result = new Args(
args[0],
args[1],
Integer.parseInt(args[2]),
Integer.parseInt(args[3]));
System.out.println(result);
return result;
}
private static void printStats(final ProgramState state) {
final Duration duration = Duration.ofMillis(System.currentTimeMillis() - state.start());
System.out.println("Took: " + duration.toString());
System.out.println("Files checked: " + state.count().get());
if (duration.toSeconds() > 0) {
System.out.println("Throughput: " + (state.bytes().get() / duration.toSeconds() / 1024 / 1024) + " Mib/s");
}
System.out.println("Errors: " + state.countErr().get());
}
}