Skip to content

Flatbuffers marshalling performance #68

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

Closed
vaind opened this issue Oct 31, 2019 · 10 comments
Closed

Flatbuffers marshalling performance #68

vaind opened this issue Oct 31, 2019 · 10 comments
Labels
enhancement New feature or request performance Performance improvement

Comments

@vaind
Copy link
Contributor

vaind commented Oct 31, 2019

The way we currently marshal and unmarshal flatbuffers into objects isn't optimal. We should get rid of the intermediary propVals map<string, dynamic>. Ideally creating objects (or flatbuffers in the other direction) directly in the generated code.

@vaind vaind added the enhancement New feature or request label Oct 31, 2019
@greenrobot
Copy link
Member

Yes, this should use code generation for both ways.

Once this is done and reviewed, please give me the final review.

@Buggaboo
Copy link
Contributor

Can we borrow anything from google's flatc?

@vaind
Copy link
Contributor Author

vaind commented Oct 31, 2019

I think we're already calling the right methods from flatbuffers. Just not being 100 % efficient for the whole roundtrip.

@greenrobot
Copy link
Member

We should have a minimal CRUD perf app before doing that?

@Buggaboo
Copy link
Contributor

Buggaboo commented Oct 31, 2019

What is the bottleneck here precisely? Runtime property selection using the Map? Can we use the offsets to get/put the data from a stream of bytes? I have a feeling we might need ByteData. N vs. NlogN?

@greenrobot
Copy link
Member

Look at how Go does it, e.g. the generated code here:

Go does the FlatBuffers handling directly, while Java FlatBuffers handling is to slow and defers that to JNI. I hope compiled Dart is closer to Go performance, so it's at least worth a try.

@Buggaboo
Copy link
Contributor

Buggaboo commented Nov 1, 2019

It could be even faster with caching probably e.g. maintain last_write and last_read timestamps in atomic transactions.

@greenrobot
Copy link
Member

ObjectBox already benefits from OS cached memory mapping (see FAQ for some details). We did not bother about object-level caches so far, as ObjectBox gets like 1 million objects per second from the DB on regular notebooks.

@Buggaboo
Copy link
Contributor

Buggaboo commented Nov 1, 2019

I'm looking into benchmark harness.

How does one stress test the library? N number of writes to a random (sub)set of fields, and reads? Then print the CPU processor type, number of cores, and memory?

@vaind vaind added the performance Performance improvement label Nov 18, 2019
@vaind
Copy link
Contributor Author

vaind commented Jan 6, 2021

This (future) change in vm/ffi will allow us to avoid copying the data from FlatBuffers builder to OBX_bytes_wrapper (or other c-backed memory) dart-lang/sdk#44589 👀

@vaind vaind mentioned this issue Jan 13, 2021
5 tasks
@vaind vaind closed this as completed Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Performance improvement
Projects
None yet
Development

No branches or pull requests

3 participants