-
-
Notifications
You must be signed in to change notification settings - Fork 673
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
avoid prepare_doc allocation #1610
Conversation
avoid prepare_doc allocation, ~10% more thoughput best case
Codecov Report
@@ Coverage Diff @@
## main #1610 +/- ##
==========================================
- Coverage 93.78% 93.77% -0.02%
==========================================
Files 252 252
Lines 46380 46389 +9
==========================================
+ Hits 43499 43502 +3
- Misses 2881 2887 +6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
This is nice! Did you find this via allocation profiling? If so, which tool did you use? |
@adamreichold I used perf |
@@ -191,6 +191,34 @@ impl Document { | |||
pub fn get_first(&self, field: Field) -> Option<&Value> { | |||
self.get_all(field).next() | |||
} | |||
|
|||
/// Serializes stored field values. | |||
pub fn serialize_stored<W: Write>(&self, schema: &Schema, writer: &mut W) -> io::Result<()> { |
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.
can we make this a function in store/writer.rs?
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 think the abstraction is better like this, so the store doesn't need to know about Document
internals like FieldValues and de/serialization is in the same file
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.
Ah yes you are right!
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.
Nice!
I have one blocking comment.
@PSeitz Awesome. I love everything that removes allocation without makign the code too complex! I think we still have some in the tokenizer (T_T) and the document forces some too. |
avoid prepare_doc allocation, ~10% more thoughput best case