Comments (6)
I have now asked, will update if there's anything useful :) thanks.
from built_value.dart.
Thanks!
I'm not sure if the various compilers/runtimes (VM jit, aot, ddc, dart2js) will produce equivalent code for the proposed implementation; hashing is performance critical so any change could matter.
I can see three ways forward:
Benchmark on the various compilers/runyimes to check;
Or, ask the owners of the various compilers/runtimes to check :) I'm on the Dart team so I could do that, I guess it's not super high priority for everyone but they will probably find the question entertaining so we may get a clear answer fairly quickly :)
Or, we could change the generated code just for e.g. 18+ fields. I'm not worried about any small performance difference for such an unusual case.
What do you think? Thanks :)
from built_value.dart.
When preparing #1199, I actually checked for differences in performance on my machine (ARM64) in AOT time (using dart compile exe
).
I ran the hashcode benchmark in the benchmark/ package and added a second benchmark with a built_value class with 50 fields. These were my results, I ran the benchmarks 3 times:
current, nested hash:
hashCode many fields: 215442951/s
hashCode many fields: 214758182/s
hashCode many fields: 216637782/s
proposed change, flat:
hashCode many fields: 215169446/s
hashCode many fields: 216915034/s
hashCode many fields: 216642475/s
So at least for ARM64/AOT, there seem to be no significant difference.
I did not check any other targets though, and did not inspect the generated code, so it's possible that there regressions on other platforms and it's possible that there are differences that are too small to be detected in this benchmark.
Obviously, I would get excited if we got insights from the Dart team on that matter :)
But I would also not mind modifying #1199 to only change the generated code for classes with more than X fields.
from built_value.dart.
How urgent is it from your side? I could land and release a new version with the generation change for large classes this week, probably.
I think I will anyway ask the Dart team thr more general question of what would be the best generated hashing code.
Thanks.
from built_value.dart.
Not very urgent for me.
It's affecting one user of one of the packages that I maintain (ferry https://pub.dev/packages/ferry).
Ferry generates built_value classes from a graphql schema/queries.
They found a workaround though, so I guess they don't need an immediate fix either.
If we get a response from the Dart team within a few weeks that's totally fine by me.
from built_value.dart.
fixed by #1199
from built_value.dart.
Related Issues (20)
- `JsonObject` factory accepts null, but will throw when null is passed HOT 1
- `enum_source_class.dart` contains faulty mixin code in dart 3 HOT 7
- `JsonObject` and sub classes could have a const constructor
- Auto add builder factories for nested built_collection classes HOT 2
- Question: Possible to serialize & deserialize a field of type Map<String, dynamic> ? HOT 14
- Getting enum by wire name HOT 2
- Classes not being generated with new Dart 3 classes modifiers HOT 2
- Support analyzer v6 HOT 1
- Int32 serializers HOT 1
- Allow record serialization (or bypass the error when generating) HOT 10
- Bug: The key of a List is included as an element of said list. HOT 3
- High Memory Usage of built_value_generator to due memoization + keeping all SerializerSourceClass objects in memory HOT 6
- Allow `$` in enum class names similar to other built_value classes
- BuiltJsonSerializers throws an Error on deserialization exception but it should? HOT 4
- Nested builder factories not added automatically in serializers.g.dart HOT 2
- Record list serialization unexpectedly converted to a map by StandardJsonPlugin. HOT 5
- Classes not being generated with class-modifiers HOT 3
- [Bug] Code Generation Attempt Unintendedly Triggered HOT 3
- optimize building generated files HOT 6
- Allow inherrited BuiltValueHooks HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from built_value.dart.