-
Notifications
You must be signed in to change notification settings - Fork 27
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
perf: take Tree::new items by reference #32
perf: take Tree::new items by reference #32
Conversation
The idea of a As the I think benchmarks would be interesting to find out whether this is a bottleneck or not. |
My usecase is quite extreme the json reply is ~13MB so even just copying that many references felt quite slow. How would I go about benchmarking this? |
540e84b
to
9fe712f
Compare
I hope something like this is not necessary, and I prefer improving the performance rather than using something like this. (More detailed answer in the related issue). So I would close this for now. Or do you have other thoughts here? |
I agree that improving the performance of TreeItem seems like a good idea. But I'm not sure why you don't like this approach of passing the items by reference. Even if the performance overhead is minimal when you are dealing with large json objects, you basically have deeply recursive datastructres that require a full traversal of the vec to copy it even if the indiviual copies are super fast you still end up with O(n) operations vs O(1) if you pass a reference. For smaller json objects it's basically unnoticable but for larger json objects the performance gain is huge. In my case my fps went x15-20 simply making Tree take a reference (for json ~11MB), so I would be interested in hearing why you'd prefer to not use them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking about a release in between the current v0.19.0 and the upcoming TreeData
trait changes (#34). The TreeData
allows for a lot more flexibility and is also taken by reference. It improves performance by a different approach and includes an example for JSON, which is way more performant then due to not generating items that aren't rendered.
To reduce the friction a release in between might be helpful and given that the TreeData
takes a reference it might be a good idea to include this.
Conflicts: .github/workflows/rust.yml src/lib.rs
Hi, I haven't had time to continue working on my side projects until now but these changes are great! |
Currently you are forced to copy the items into the tree. With this change you can avoid this overhead. It works for my use case but if I missed something please let me know.