-
Notifications
You must be signed in to change notification settings - Fork 434
Some performance improvements #202
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
Conversation
The ci fails because something on the master branch is brocken for the |
juniper/src/value.rs
Outdated
|
||
|
||
/// Get a iterator over all field value pairs | ||
pub fn iter(&self) -> impl Iterator<Item = &(String, Value)> { |
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.
Hmmm, looks like this uses impl trait, which didn't stabilize until 1.26. Supporting impl trait would mean we would have to bump our min rust version.
Regarding versions, I'd like to stick to the Also, we'd really need some solid benchmarks comparing the two implementations. This might be a good oppurtunity to set up a nice criterion based benchmark suite. |
Either way, as a first step, it might be a cool idea to export a wrapper type from a submodule so we can easily change the implementation without a lot of hassle. |
(I'm back from vacation, so here are some answers.)
It should be possible to do this without
I've developed this change as part of optimizing wundergraph. For this I used the following benchmark. See the wundergraph repo (wundergraph-bench) for commits without and with this change. The relevant graphql query is this one: query tracks_media_all {
Tracks {
id
name
media_type_id {
name
}
}
} Benchmark results without this change: Benchmark results with this change:
My benchmark is unfortunately something that involves a quite complex interplay of several components so it seems not to be appropriated to be used as benchmark for juniper alone.
This is not something that could be improved in the indexmap crate.
|
* Replace the IndexMap in the serialized object with a plain `Vec<(String, Value)>` because linear search is faster for few elements * Some general tweaks to skip some allocations
cc7fbd9
to
3b3d041
Compare
cb0f08b
to
af40b11
Compare
Codecov Report
@@ Coverage Diff @@
## master #202 +/- ##
==========================================
+ Coverage 89.76% 89.93% +0.17%
==========================================
Files 96 96
Lines 18753 19579 +826
==========================================
+ Hits 16834 17609 +775
- Misses 1919 1970 +51
Continue to review full report at Codecov.
|
What is the status of this PR? I believe the |
The usage of |
Ah, didn't see this was updated, thanks for the reminder! I'm merging this as-is as I think the change is good and straightforward. I'm slightly concerned about:
In any case, I don't think those are blockers for landing this. |
Replace the IndexMap in the serialized object with a plain
Vec<(String, Value)>
because linear search is faster for fewelements
Some general tweaks to skip some allocations
Addresses #199