Git Product home page Git Product logo

Comments (6)

davidmorgan avatar davidmorgan commented on May 18, 2024 1

I have now asked, will update if there's anything useful :) thanks.

from built_value.dart.

dave26199 avatar dave26199 commented on May 18, 2024

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.

knaeckeKami avatar knaeckeKami commented on May 18, 2024

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.

dave26199 avatar dave26199 commented on May 18, 2024

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.

knaeckeKami avatar knaeckeKami commented on May 18, 2024

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.

knaeckeKami avatar knaeckeKami commented on May 18, 2024

fixed by #1199

from built_value.dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.