alibaba / alibaba/fastjson2

关于fastjson2 反序列化的性能问题

Open
#1,609 5 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

fastjson2 version 2.0.20
最近在进行国家接口列表压测,逻辑是直接从redis中取数据
序列化/反序列话器为
public byte[] serialize(T t) throws SerializationException {
if (t == null) {
return new byte[0];
}
return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
}

@Override
public T deserialize(byte[] bytes) throws SerializationException {
if (bytes == null || bytes.length <= 0) {
return null;
}
String str = new String(bytes, DEFAULT_CHARSET);
//return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType);
**//QPS 400+**
return JSON.parseObject(str, clazz);
**//QPS 1000+**
}

发现如果使用上述FastJson2JsonRedisSerializer 会使性能大打折扣,当然我知道这可能是我用法不对造成的,但这种差距实在太大了

有没有大佬传授一下意见

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported Redis serialization and deserialization comparison with fastjson2 version 2.0.20, focusing on the two JSON.parseObject calls shown in the issue. Compare QPS under the same load and capture the input type, payload, JVM, and benchmark conditions; done means the performance difference is explained or a confirmed fastjson2 issue is isolated.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.