Closed eryanwcp closed 1 month ago
@eryanwcp Do you create too much Fury instance? As the document cleared:
Could you use ThreadPoolFury
instead? Seems you created too much threads, and every thread will create a new Fury instance
@chaokunyang Only One Fury instance.
Spring Boot 3.3+dragonwell17
SerializationUtils.deserialize(bytes) Occasionally, CPU 100% occurs and persists
private final ThreadSafeFury fury;
should be private final static ThreadSafeFury fury;
instead.
`private final WeakHashMap<LoaderBinding, Object> allFury = new WeakHashMap();
public ThreadLocalFury(Function<ClassLoader, Fury> furyFactory) {
this.bindingThreadLocal = ThreadLocal.withInitial(() -> {
LoaderBinding binding = new LoaderBinding(furyFactory);
binding.setBindingCallback(this.factoryCallback);
binding.setClassLoader(Thread.currentThread().getContextClassLoader());
this.allFury.put(binding, (Object)null);
return binding;
});
Fury fury = ((LoaderBinding)this.bindingThreadLocal.get()).get();
ClassResolver._addGraalvmClassRegistry(fury.getConfig().getConfigHash(), fury.getClassResolver());
}`
It seems that allFury. put() has caused a concurrency conflict
Could you provide more details? ThreadLocalFury is created only once, I don't see concurrency conflict
This is threadLocal, and each thread will create one. When multiple threads are created simultaneously, they will be put into allFury at the same time
I see, thanks. This is indeed a bug, would you like to create a pr?
sorry,I am not familiar with using PR. using Collections.synchronizedMap(new WeakHashMap()) or ConcurrentHashMap can solve this problem. sorry
@qinzhikui thanks for your suggestion, I fixed it in https://github.com/apache/fury/pull/1889
Search before asking
Version
0.7.0
code
出现大量线程CPU100%,异常:
at java.util.WeakHashMap.put(java.base@17.0.12/WeakHashMap.java:459) at org.apache.fury.ThreadLocalFury.lambda$new$2(ThreadLocalFury.java:60) at org.apache.fury.ThreadLocalFury$$Lambda$1294/0x00007f9fb0bcd7e8.get(Unknown Source) at java.lang.ThreadLocal$SuppliedThreadLocal.initialValue(java.base@17.0.12/ThreadLocal.java:305) at java.lang.ThreadLocal.setInitialValue(java.base@17.0.12/ThreadLocal.java:195) at java.lang.ThreadLocal.get(java.base@17.0.12/ThreadLocal.java:172) at org.apache.fury.ThreadLocalFury.deserialize(ThreadLocalFury.java:130) at com.eryansky.j2cache.util.FurySerializer.deserialize(FurySerializer.java:40)
Anything Else?
No response
Are you willing to submit a PR?