-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add merge() method to ApproxMostFrequentStreamSummary as an optimization over mergeSerialized() #12236
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Feb 1, 2025
This pull request was exported from Phabricator. Differential Revision: D68995835 |
✅ Deploy Preview for meta-velox canceled.
|
deepyeet
pushed a commit
to deepyeet/velox
that referenced
this pull request
Feb 3, 2025
…ion over mergeSerialized() (facebookincubator#12236) Summary: # Context This diff adds a merge() method which behaves equivalent to mergeSerialized(). The reason this is added is because this avoids the extra round trip serialization + deserialization that's required when calling mergeSerialized(). # Rationale The rationale here is that, the serialize function simply calls values()[i] and priorities()[i], and `memcpy`'s the integers. Then when we deserialize, we also simply take the values as-is and re-insert them into the target data structure. So obviously; rather than ser + deser to perform the exact same operation, we can just copy directly. There are a couple of considerations: 1. **StringView** - Because we do not serialize, velox::StringView is still pointing at whatever `other` ApproxMostFrequentStreamSummary is pointing to, which means *the lifetime of the string must be kept alive across both structures, even if the `other` one disappears*. This ... feels okay, but requires consideration from the user of this class. 2. **StringView equality** - seems like previous behavior is correct (insert will lookup index in priority queue and use operator== on StringView which should compare contents). So technically if all `StringView` point to equal strings, then this won't be problem. Differential Revision: D68995835
deepyeet
force-pushed
the
export-D68995835
branch
from
February 3, 2025 18:06
9cd25c0
to
39458ef
Compare
This pull request was exported from Phabricator. Differential Revision: D68995835 |
Yuhta
approved these changes
Feb 3, 2025
…ion over mergeSerialized() (facebookincubator#12236) Summary: # Context This diff adds a merge() method which behaves equivalent to mergeSerialized(). The reason this is added is because this avoids the extra round trip serialization + deserialization that's required when calling mergeSerialized(). # Rationale The rationale here is that, the serialize function simply calls values()[i] and priorities()[i], and `memcpy`'s the integers. Then when we deserialize, we also simply take the values as-is and re-insert them into the target data structure. So obviously; rather than ser + deser to perform the exact same operation, we can just copy directly. There are a couple of considerations: 1. **StringView** - Because we do not serialize, velox::StringView is still pointing at whatever `other` ApproxMostFrequentStreamSummary is pointing to, which means *the lifetime of the string must be kept alive across both structures, even if the `other` one disappears*. This ... feels okay, but requires consideration from the user of this class. 2. **StringView equality** - seems like previous behavior is correct (insert will lookup index in priority queue and use operator== on StringView which should compare contents). So technically if all `StringView` point to equal strings, then this won't be problem. Reviewed By: Yuhta Differential Revision: D68995835
deepyeet
force-pushed
the
export-D68995835
branch
from
February 3, 2025 19:50
39458ef
to
f2280fc
Compare
This pull request was exported from Phabricator. Differential Revision: D68995835 |
This pull request has been merged in f0a96f1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Context
This diff adds a merge() method which behaves equivalent to mergeSerialized().
The reason this is added is because this avoids the extra round trip serialization + deserialization that's required when calling mergeSerialized().
Rationale
The rationale here is that, the serialize function simply calls values()[i] and priorities()[i], and
memcpy
's the integers.Then when we deserialize, we also simply take the values as-is and re-insert them into the target data structure.
So obviously; rather than ser + deser to perform the exact same operation, we can just copy directly.
There are a couple of considerations:
other
ApproxMostFrequentStreamSummary is pointing to, which means the lifetime of the string must be kept alive across both structures, even if theother
one disappears. This ... feels okay, but requires consideration from the user of this class.StringView
point to equal strings, then this won't be problem.Differential Revision: D68995835