Skip to content
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

Improve JSON Deserialization Performance #10

Closed
robertlong opened this issue Mar 9, 2017 · 4 comments
Closed

Improve JSON Deserialization Performance #10

robertlong opened this issue Mar 9, 2017 · 4 comments

Comments

@robertlong
Copy link
Contributor

Currently JSON deserialization is a bit slow and not concurrent. It blocks the renderer and causes dropped frames. I'd like to move it to another thread or at least make it concurrent. There's also likely a lot of room for improvement in overall parsing speed.

@stevenvergenz
Copy link
Contributor

I noticed that buffer data gets copied to the buffer view objects, which get copied to the accessor objects. All the copying seems wasteful, wouldn't it make more sense to provide access to the original buffer via a function that maps the index space? So in lieu of bytes[] GLTFBuffer.Data, you might have bytes[] GLTFBuffer.GetBytes(int offset, int byteLength), and have GLTFBufferView implement the same interface. That way you don't have to copy anything until it's converted to its final type in the accessor.

@robertlong
Copy link
Contributor Author

Performance greatly improved via manual deserialization in db40b19

Previously we were using JSON.NET's JsonConvert.DeserializeObject which uses reflection to deserialize the provided object.

I've moved everything to manual deserialization which removes all reflection and really speeds things up.

Sample Model Reflection Parse Time Reflection GCAlloc Manual Parse Time Manual GCAlloc
Lantern 389.40ms 7.6MB 31.56ms 99.6KB
Corset 377.99ms 7.8MB 29.36ms 55.7KB
BoomBox 384.86ms 7.8MB 29.29ms 85KB

There's probably still a lot more room for performance improvements, but I'm feeling pretty good about our parsing performance now.

@stevenvergenz
Copy link
Contributor

Wow, that's some intense savings. Nicely done!

@donmccurdy
Copy link

donmccurdy commented Nov 24, 2018

Any idea why parsing here would be slower than JSON parsing in e.g. the browser? All three of the sample models above take ~3ms with JSON.parse() in Firefox, or 10x faster.. I suppose that's partly because the C# is processing the model into structured objects and typed values, whereas JS is looser about this? I'm testing on a different machine here of course, but it's a fairly old laptop so I'd be surprised if that's the difference.

hybridherbst referenced this issue in prefrontalcortex/UnityGLTF Dec 12, 2019
js-dignitas added a commit to js-dignitas/UnityGLTF that referenced this issue Oct 19, 2021
Merge in ARES/ares.unity_gltf from ARES-2466-magicleap to ares

Squashed commit of the following:

commit 0b1a5bd319ede365ac45e739a1106cda26239fc2
Author: Jason Schutz <jschutz@dignitastechnologies.com>
Date:   Mon Jun 21 14:19:28 2021 -0400

    Update to latest Basic Library
hybridherbst added a commit that referenced this issue Apr 8, 2022
Implement GetBufferData() in SetupBones Task.
github-actions bot pushed a commit to Rhinox-Training/UnityGLTF that referenced this issue Nov 9, 2022
Implement GetBufferData() in SetupBones Task.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants