Package causes large performance spike on assembly reload
tomkail opened this issue · 3 comments
Hi! We've been doing some profiling to improve our editor reload speeds and we spotted that this package is causing a fairly large spike (~1s!) when assemblies are reloaded.
A main cause seems to be the use of string comparison in FindCustomConverters/FindUnityConverters. The code type.Namespace?.StartsWith("Newtonsoft.Json")
runs around 100k times in our project. We had hoped to at least prevent searching for custom converters (which we don't have) by disabling them in the settings file but the filtering step occurs after searching for the assets, which means that doesn't help.
I've not used it myself, but I hear Unity's TypeCache class might be a good solution for this problem.

M1 Macbook Pro 2021
Converter package version 1.5.1
Really interesting find!
Will take a look at this. Thanks for the hint on TypeCache
Usage of TypeCache has been added in v1.6.0.
Do note that the TypeCache was first introduced in Unity 2019.2. This package falls back to the slower implementation on older Unity versions.
You can now also completely opt-out of this Assembly scanning code via the settings file:
Package is available at:
- OpenUPM: https://openupm.com/packages/jillejr.newtonsoft.json-for-unity.converters/?subPage=versions
- Cloudsmith: https://cloudsmith.io/~jillejr/repos/newtonsoft-json-for-unity/packages/detail/npm/jillejr.newtonsoft.json-for-unity.converters/1.6.0/
Enjoy :)