-
Notifications
You must be signed in to change notification settings - Fork 5
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
Evaluate generating models as regular dart classes and not extension types #136
Comments
Hmmm I've actually been thinking the reverse, that extension types might be a win for performance in other places too. This is mostly due to
and that it's faster to iterate over the
Worth noting though that in both cases it's faster still to use the data directly without storing it anywhere in between
--the equivalent for computing hash codes would be that we have a mode for building a An entirely different avenue for exploration is the overlap between models, it may be that we can arrange that duplicate pieces are only built and hashed once: something like, we build one host-side model with hashes and pull parts out of it to answer queries. If we do that we can easily just compute the hash first before going back to also grab the data if needed. I could be wrong about any/all this, good thing it's measurable :) |
I am not suggesting using SDK maps. I am suggesting using real Dart classes with fields, and separate logic to serialize/deserialize them to whatever format. Essentially, what the current macro implementation does. |
Yes, it's not directly comparable. Real classes might be worth trying. But neither extension types nor real classes can be as fast as computing the hash code without allocating anything, or re-using hash codes calculated earlier. So it might not be the first thing to try, depending on how much work they all are :) |
So would the idea be to basically have a write-only map implementation that we use to back the model when doing query invalidation? And it doesn't actually write to a map, just accumulates a hash? |
Fwiw I noticed this is using |
Something like that, yes. We could also generate an alternative version of all the model that stores nothing, and have a copy+paste of all the processing code that imports that instead :) Or we could structure the model creation code in a pluggable way as discussed previously w.r.t. ways to create the data with only properties that have been queried for.
Yes, it's a "best case" benchmark, not necessarily realistic :) |
Note that
I believe this benchmark is also an extreme worst case, with many entries, but still 🤣 . |
With the new query invalidation approach, the vast majority of objects are actually never sent over the wire. Yet, we are paying a large cost during creation to make them "free" to serialize and deserialize. All accesses to all fields are also relatively slow compared to just accessing regular fields on dart objects.
I suspect that we actually should abandon the extension types and just generate real classes, so that we can generate hash codes much more cheaply. We can still use the binary JSON format though.
A side benefit of this is it would likely make it easier for us to control a centralized implementation of the query and filtering logic. We can make these types implementable via lazy getters, and only read the fields that were asked for in the query during serialization.
cc @davidmorgan
The text was updated successfully, but these errors were encountered: