GitHub user chaokunyang added a comment to the discussion: Java: maximum
performance with minimum overhead
@mchernyakov `com.google.common.primitives.ImmutableIntArray` implemented JDK
`writeReplace` method, which will write fullclass name of it, it took almost 40
bytes.
```java
public ReplaceResolveSerializer(Fory fory, Class type) {
super(fory, type);
refResolver = fory.getRefResolver();
classResolver = fory.getClassResolver();
// `setSerializer` before `newJDKMethodInfoCache` since it query classinfo
from `classResolver`,
// which create serializer in turn.
// ReplaceResolveSerializer is used as data serializer for
ImmutableList/Map,
// which serializer is already set.
classResolver.setSerializerIfAbsent(type, this);
if (type != ReplaceStub.class) {
jdkMethodInfoWriteCache = newJDKMethodInfoCache(type, fory);
classClassInfoHolderMap.put(type, jdkMethodInfoWriteCache);
// FIXME new classinfo may miss serializer update in async compilation
mode.
writeClassInfo = classResolver.newClassInfo(type, this,
ClassResolver.NO_CLASS_ID);
} else {
jdkMethodInfoWriteCache = null;
writeClassInfo = null;
}
}
private void writeObject(MemoryBuffer buffer, Object value, MethodInfoCache
jdkMethodInfoCache) {
classResolver.writeClassInternal(buffer, writeClassInfo);
jdkMethodInfoCache.objectSerializer.write(buffer, value);
}
```
Currently fory always write full classname, even such class is registered. This
can be optimized.
```
writeClassInfo = classResolver.newClassInfo(type, this,
ClassResolver.NO_CLASS_ID);
```
We should check whether class id for current type is
`ClassResolver.REPLACE_STUB_ID/NO_CLASS_ID`. if not, we should reuse registered
classinfo.
But I must say I have no plan for size compression currently. Currently I'm
mainly working on fory rust/python. If you pursue better compression, you need
to contribute fory by yourself.
GitHub link:
https://github.com/apache/fory/discussions/2786#discussioncomment-14741802
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]