Skip to content
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

Assign empty labels to array elements for better efficiency #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

UnkindPartition
Copy link

Right now this package assigns consecutive integer numbers (serialized as strings) for array labels. This is wasteful in both space and time.

This PR addresses the issue as far as possible within the BSON spec.

In my example, this reduced the serialziation time from 1.5s to 1s and the file size from 45Mb to 32Mb.

@VictorDenisov
Copy link
Member

Hi @feuerbach can possibly see a reason for using consequtive integers array labels?

@VictorDenisov
Copy link
Member

It looks like bson spec explicitly suggests to use consequtive ascending order of labels: http://bsonspec.org/spec.html (look for notes). Can we optimize it somehow without dropping consequtive labels?

@UnkindPartition
Copy link
Author

I see. Well, you could replace (T.pack $! show i) with a call to a more efficient serialization function that goes from Int to Text directly — there must exist some packages for that.

Also, a comment in the code citing/linking to that part of the spec would be helpful. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants