-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
poor performance when compiling with IL2CPP #5
Comments
Hmm.. How "deep" is the object in question? It looks it's doing a lot of nested calls. This might just be one of those situations where abstraction hurts you, since 100K of JSON is actually a fair amount of data, especially if it's highly structured (rather than, say, a big array of values). I haven't done anything with IL2CPP thus far. Any of my iOS work was in the Pre-IL2CPP days. Let me do some tests when I have the chance (probably not today, sorry), but I'll get back to you when I do. Please feel free to post to the Unity forums and/or try a couple of other JSON packages. If any of the other managed implementations (most of what you'll find for C# JSON), see if you can find a way to wrap a C++/C implementation as a plugin, which will hopefully not get touched by IL2CPP, being that it's not IL :) |
The object is not too deep. It contains around 10-20 keys / lists with some structure and a big string value (which accounts for most of the 100K). I will try some of the approaches you suggest. |
Hm. If the majority of the data is a single string, that kind of throws out my theory. As long as it recognizes it as a string, the parser should just skip over that entire chunk of data. Are you sure there aren't any unescaped quotes. Do you think you could pastebin or otherwise send me the source data for testing? I haven't had a chance to try it yet but I think I can do so today. |
Hey there, I can confirm that IL2CPP performance is pretty terrible. I noticed that calls to Array.IndexOf seemed to be at the top of the list, and they're coming from the fact that I use an array to list the whitespace characters which are passed over by the parser. Switching this to a series of if statements seems to improve performance greatly. I used to do a string.Replace on all the whitespace, but some users didn't like the fact that that would remove whitespace from your data. It also might end up being slow. I didn't make any scientific comparison, but I hope this fix does the job for you. Otherwise, I'm not sure that I can do much in C#. I've already tried to optimize the parser as much as I can, so without a better algorithm (is there one?), we'll just have to wait until Unity improves their IL2CPP implementation or we come up with a native plugin to do the parsing. I've actually been thinking about adding support for Binary JSON, which is sort of unrelated, but is a big enough refactor that I'm considering also doing that C/C++ plugin thing. I'll let you know how it goes, but don't expect progress anytime soon. I'm going to close this issue, but please feel free to re-open it if you need more help. |
Oh yeah, I came across this tool, which was really useful for testing "big JSON" http://beta.json-generator.com/LJoZd1T This is the big JSON I was testing with: |
By the way, 5.1.1p4 makes a note about performance improvements to IL2CPP boxing/unboxing. You might want to check it out. Furthermore, I would submit a bug to Unity with your project folder to show them what's going wrong. It may be some weird edge case that it's bringing up which will help them improve their IL2CPP toolchain for everyone. |
I am using JSONObject with Unity to build an iOS app. I need to parse a large JSON object (around 100KB).
It works perfectly when using the Mono Backend but when I switch to IL2CPP to support arm64, the app gets stuck parsing the JSON object. This is a profile of the app when it has started parsing the object:
I can see most of the time is spent in allocations and string comparisons.
Any suggestion on how to fix this?
The text was updated successfully, but these errors were encountered: