duongkame commented on PR #5853:
URL: https://github.com/apache/ozone/pull/5853#issuecomment-1874770020
> > ... have you done some benchmarks to see if this can improve the
performance?
>
> @duongkame , have you got a chance to run some benchmarks?
I didn't run benchmarks on any ozone scenarios. However, I did a simple
benchmark scenario each creating 100M managed objects with a percentage of
leaks. The new solution consistently beats the old one by a 33% gap.
New solution result:
```
Finish benchmarking. Total time (ms): 38008
Total objects: 100001000
Total leaks found: 1000
```
Old solution (finalizer result.
```
Finish benchmarking. Total time (ms): 56527
Total objects: 100001000
Total leaks found: 1000
```
Benchmarking code:
```
public class ManagedObjectBenchmarking {
public static void main(String[] args) throws Exception {
NativeLibraryLoader.getInstance().loadLibrary("/tmp");
long start = System.currentTimeMillis();
int rounds = 100;
for (int i = 0; i < rounds; i++) {
create(1_000_000, true);
create(10, false);
System.gc();
}
long duration = System.currentTimeMillis() - start;
Thread.sleep(1000);
System.out.println("Finish benchmarking. Total time (ms): " + duration);
System.out.println("Total objects: " +
ManagedRocksObjectMetrics.INSTANCE.totalManagedObjects());
System.out.println("Total leaks found: " +
ManagedRocksObjectMetrics.INSTANCE.totalLeakObjects());
}
private static void create(int n, boolean close) {
for (int i = 0; i < n; i++) {
ManagedWriteBatch object = new ManagedWriteBatch();
if (close) {
object.close();
}
}
}
}
```
Theoretically, this improvement unblocks GC and optimizes leak detection by
only processing unclosed resources (closed ones are not enqueued).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]