alibaba / alibaba/fastjson2

[FEATURE] ThreadLocal handling with Virtual Threads (JDK21)

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

Description

### 请描述您的需求或者改进建议
The project heavily relies on `ThreadLocal` objects, which can cause explosive memory growth with `Virtual Threads`. In theory, `ThreadLocals` have relatively no effect with Virtual Threads since its encouraged to create many and short lived threads, which would wipe the Thread Local objects. Also, there can exist millions of virtual threads, where `ThreadLocal` also can become a problem.

### 请描述你建议的实现方案
Utilise a different mechanism of recycling such objects. Currently Jackson has created a virtual thread friendly recycler.

Contributor guide

Open the contributing guide

Research direction

Start by locating the project's ThreadLocal-based recyclers and reviewing how they behave under JDK 21 virtual threads. Compare the approach with Jackson's virtual-thread-friendly recycler, then define and validate a replacement that avoids excessive memory growth while preserving recycling behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.