VYaml
VYaml copied to clipboard
Severe performance degradation with usage of `ConcurrentQueue<Scalar>` when multi-thread
https://github.com/hadashiA/VYaml/blob/81abc25d9f5d8250028cf09d8a68a59a3d2cd649/VYaml/Internal/Scalar.cs#L11-L24
I have a tool to deserialize all assets from my unity project. It's basically calling YamlSerializer.DeserializeMultipleDocumentsAsync
combined with Parallel.ForEach
.
When I upgraded to the latest VYaml (v0.26) I have observed very obvious performance lost.
The process time increased from 1min to 4min.
It seems that the recently imported ConcurrentQueue<Scalar>.TryDequeue(...)
for ScalarPool.Rent()
caused the problem.
It's spending too much time on SpinWait. I guess the usage of ConcurrentQueue
is thread safe but not multi-thread friendly. 🤔
And, this is the time cost for the same input, before the ConcurrentQueue
was introduced: