fperez-RatedPower commented on issue #2302:
URL: https://github.com/apache/fory/issues/2302#issuecomment-2948445345
Hi @chaokunyang, many thanks for your answer! I tried your suggestion, using
the same code I shared in the post, but reusing the same instance.
The problem persists; we still observe the performance degradation. With the
previous code, we were trying to isolate the Fury instances, thinking that we
would achieve better performance (in parallel) if nothing was shared between
the Fury instances.
This is the code I used:
```
public static void main(String[] args) {
FuryParentDTO parentDTO = buildDTO();
SerializeFury serializeFury = new SerializeFury();
byte[] serialized = serializeFury.serialize(parentDTO);
System.out.println("starting warm up");
// Warm up
for(int i = 0; i < 10; i++) {
serializeFury.deserialize(serialized);
}
System.out.println("finished warm up");
int timesToDeserialize = 20_000;
long serialStartTime = System.nanoTime();
for(int i = 0; i < timesToDeserialize; i++) {
serializeFury.deserialize(serialized);
}
long serialTime = System.nanoTime() - serialStartTime;
int threads = 10;
int unitsPerThread = timesToDeserialize / threads;
long parallelStartTime = System.nanoTime();
try(ExecutorService executorService =
Executors.newFixedThreadPool(threads)) {
List<Future<FuryParentDTO>> futures = new ArrayList<>();
for(int i = 0; i < threads; i++) {
Callable<FuryParentDTO> callable = () -> {
for(int j = 0; j < unitsPerThread - 1;
j++) {
serializeFury.deserialize(serialized);
}
return
serializeFury.deserialize(serialized);
};
Future<FuryParentDTO> future =
executorService.submit(callable);
futures.add(future);
}
for(Future<FuryParentDTO> future : futures) {
future.get();
}
} catch(Exception e) {
throw new RuntimeException(e);
}
long parallelTime = System.nanoTime() - parallelStartTime;
System.out.println("Serial deserialize time: " + serialTime /
1e9 + "seconds");
System.out.println("Parallel deserialize time: " + parallelTime
/ 1e9 + " seconds");
System.out.println("Parallel time / serial time: " + 1.0 *
parallelTime / serialTime);
}
```
--
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]