-
Notifications
You must be signed in to change notification settings - Fork 63
set serialization #90
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lavalamp The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I'm pretty sure I can still cut down on the allocations a ton. Still WIP.
|
This is still doing way more allocations than it should. Now:
|
It'd be easier to get the allocations down further if we changed the format a bit. Right now encoding things to strings (and back) means an allocation for each key. Fixing is possible but probably needs some surgery to jsoniter. It's a bit weird, but we could do that by leveraging JSON arrays instead of objects. Instead of objects that are lists of (key, subobject) pairs, we could do a list of lists-- ({key type: key}, subobject) pairs.
@apelisse @jennybuckley what do you think? |
OK I have reasonable names and tests now. Does anyone want to look before I squash? |
In the main repo, doing nothing but switching in the path element serialization functions here, we get
|
When we created the initial API, we did disregard these kind of APIs because they force you to have an WRT benchmarks, I'm somewhat surprised by these results. The first 3 benchmarks, which are supposed to be the closest to real-life scenarios are now showing more allocations. The 2-3% difference in CPU time are probably irrelevant. And on the other hand, FieldToSet is dropping almost 50% again (same as last PR)... I don't know what to think. |
I think I read all of it, so feel free to squash. |
132762f
to
208bc23
Compare
To make it weirder, when I hook up everything (using a RawExtension), the opposite happens-- 10-15% improvements except for fieldtoset which gets worse... maybe I compared the wrong things. Anyway, this is squashed and ready to merge. We can improve it more later, it should be in the right shape at least. |
Pushed missing boilerplate and another optimization.
|
And
|
case peValueSepBytes[0]: | ||
iter := readPool.BorrowIterator(b) | ||
defer readPool.ReturnIterator(iter) | ||
v, err := value.ReadJSONIter(iter) |
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.
Could you call FromJSONFast
directly?
} | ||
return PathElement{Value: &v}, nil | ||
case peKeySepBytes[0]: | ||
iter := readPool.BorrowIterator(b) |
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.
Same as above
|
||
// DeserializePathElement parses a serialized path element | ||
func DeserializePathElement(s string) (PathElement, error) { | ||
b := []byte(s) |
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 believe this is copying the full buffer, is it worth optimizing?
/lgtm |
This is not ready to merge yet. I need to clean up / integrate and optimize the code I copied.
This should actually be a drop-in replacement for the current JSON serialization in the main repo...
Initial benchmark follows, I expect to significantly beat this shortly: