-
Notifications
You must be signed in to change notification settings - Fork 15
Optimize BSON for rechecks & mismatches. #165
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
Optimize BSON for rechecks & mismatches. #165
Conversation
tdq45gj
left a comment
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.
LGTM. I've left some minor comments.
| bsonLen := 4 + // header | ||
| 1 + 4 + 1 + len(bson.ObjectID{}) + // Task | ||
| 1 + 6 + 1 + len(detail) + // Detail | ||
| 1 // NUL | ||
|
|
||
| buf := make(bson.Raw, 4, bsonLen) |
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 wonder how much faster it is compared to using DocumentBuilder.
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.
DocumentBuilder doesn’t have a way to preallocate a buffer, unfortunately. Every field it adds does a reallocation.
|
|
||
| connStr := os.Getenv("MVTEST_META") | ||
| if connStr == "" { | ||
| t.Skipf("No MVTEST_META found; skipping.") |
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.
Is it possible to use the source or destination URI instead of skipping?
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.
Anything that sets a src or dst in env has probably also set a meta. IMO not worth accommodating something that hasn’t.
Co-authored-by: Jian Guan <61915096+tdq45gj@users.noreply.github.com>
This optimizes a few BSON marshal/unmarshal operations:
This also includes a new UnmarshalCursor function that works like mongo.Cursor.All but for structs that implement UnmarshalFromBSON (and forbid bson.Unmarshal).
It also fixes 2 intermittently-failing tests: