You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "shixuan-git (via GitHub)" <gi...@apache.org> on 2026/08/24 12:23:31 UTC
[I] 【Java】 高QPS 情况下,反序列化org.apache.fory.serializer.StringSerializer#newBytesStringZeroCopy、HashMap.put → putVal → newNode/resize扩容 造成 CPU内存高耗 [fory]
shixuan-git opened a new issue, #3975:
URL: https://github.com/apache/fory/issues/3975
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/fory/issues) and found no similar issues.
### Version
<img width="766" height="397" alt="Image" src="https://github.com/user-attachments/assets/8ca349f0-e70f-4769-8ae1-826da5029582" />
<img width="1409" height="439" alt="Image" src="https://github.com/user-attachments/assets/5c699b82-141a-4950-b5d9-73da7c3531ba" />
### Component(s)
Java
### Minimal reproduce step
// 创建一个全局的 Fury 实例(线程安全)
private static final ThreadSafeFory fury = Fory.builder()
.withLanguage(Language.JAVA)
.requireClassRegistration(false)
.withMetaShare(true)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.withDeserializeNonexistentClass(true)
// 异步编译减少阻塞时长
.withAsyncCompilation(true)
.registerGuavaTypes(true)
.buildThreadSafeFory();
public static <T> T deserialize(byte[] bytes, Class<T> clazz) {
try {
return (T) fury.execute(f -> {
f.getSerializationContext().setMetaContext(new MetaContext());
return f.deserialize(bytes);
});
} catch (Exception e) {
log.error("FuryUtil deserialize error", e);
return null;
}
}
### What did you expect to see?
Java
OpenJDK 21.0.1+12-LTS(Eclipse Temurin)
GC
ZGC + ZGenerational(分代 ZGC)
堆
-Xms9600m -Xmx9600m(固定 9.6G,实际含 ZGC 元数据约 10G)
直接内存
-XX:MaxDirectMemorySize=2G(实测 DirectBuffer 约 311M)
Metaspace
初始 256m / 上限 512m(实测 206M,稳定,无类加载器泄漏)
### What did you see instead?
// 创建一个全局的 Fury 实例(线程安全)
private static final ThreadSafeFory fury = Fory.builder()
.withLanguage(Language.JAVA)
.requireClassRegistration(false)
.withMetaShare(true)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.withDeserializeNonexistentClass(true)
// 异步编译减少阻塞时长
.withAsyncCompilation(true)
.registerGuavaTypes(true)
.buildThreadSafeFory();
public static <T> T deserialize(byte[] bytes, Class<T> clazz) {
try {
return (T) fury.execute(f -> {
f.getSerializationContext().setMetaContext(new MetaContext());
return f.deserialize(bytes);
});
} catch (Exception e) {
log.error("FuryUtil deserialize error", e);
return null;
}
}
### Anything Else?
_No response_
### Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
--
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: commits-unsubscribe@fory.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [I] 【Java】 Deserialization cpu overhead on org.apache.fory.serializer.StringSerializer#newBytesStringZeroCopy、HashMap.put → putVal → newNode/resize on high QPS workload [fory]
Posted by "shixuan-git (via GitHub)" <gi...@apache.org>.
shixuan-git commented on issue #3975:
URL: https://github.com/apache/fory/issues/3975#issuecomment-5395515769
Thanks👍
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [I] 【Java】 Deserialization cpu overhead on org.apache.fory.serializer.StringSerializer#newBytesStringZeroCopy、HashMap.put → putVal → newNode/resize on high QPS workload [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang closed issue #3975: 【Java】 Deserialization cpu overhead on org.apache.fory.serializer.StringSerializer#newBytesStringZeroCopy、HashMap.put → putVal → newNode/resize on high QPS workload
URL: https://github.com/apache/fory/issues/3975
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [I] 【Java】 Deserialization cpu overhead on org.apache.fory.serializer.StringSerializer#newBytesStringZeroCopy、HashMap.put → putVal → newNode/resize on high QPS workload [fory]
Posted by "shixuan-git (via GitHub)" <gi...@apache.org>.
shixuan-git commented on issue #3975:
URL: https://github.com/apache/fory/issues/3975#issuecomment-5395576508
Map 的 resize 消耗是否可以在序列化时记录原始 map 的容量,反序列化时创建足够容量的集合避免扩容 @chaokunyang
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [I] 【Java】 Deserialization cpu overhead on org.apache.fory.serializer.StringSerializer#newBytesStringZeroCopy、HashMap.put → putVal → newNode/resize on high QPS workload [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on issue #3975:
URL: https://github.com/apache/fory/issues/3975#issuecomment-5395459448
And cost for StringSerializer#newBytesStringZeroCopy, `HashMap.put → putVal → newNode/resize` are necessary to rebuild the Object, those calls could not be eliminated. You can use List instead of HashMap, if you really want to avoid this cost
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [I] 【Java】 Deserialization cpu overhead on org.apache.fory.serializer.StringSerializer#newBytesStringZeroCopy、HashMap.put → putVal → newNode/resize on high QPS workload [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on issue #3975:
URL: https://github.com/apache/fory/issues/3975#issuecomment-5395440447
Please remove `f.getSerializationContext().setMetaContext(new MetaContext())`, this is unnecessary
--
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: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org