-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Check if TypedDataSpecializer misses any important cases on internal apps due to UnmodifiableUint8ListView instantiation #40924
Comments
This is a known issue, because that class is considered a 3rd party implementation of We could make it a 1st party implementation of So rather than doing that, I would suggest we introduce a The /cc @lrhn Can we do this? |
In addition to this we would like to make the typed data classes be non-implementable by 3rd party users. |
This would also be a stepping stone for us to eventually add support for having compile-time constant byte arrays (e.g. |
We generally do not have any "ReadOnly" collection interfaces, and I don't think we'll start now. If we did that, we should probably have the same for If we did introduce a smaller read-only super-interface for It will still not help you if someone imports The name should not be The danger of having such an interface is that users will have to consider, for every API they write, whether to use Not sure the choice is worth the cost in user mental overhead, and I'm not sure it's worth the technical cost. Dart is an interface based language, and AOT compiling interface based languages is ... well, unprecedented. A small tweak in a corner of the libraries is not going to change that, it'll just introduce more complexity for non-guaranteed efficiency. All in all, not sold on that idea. |
If you make typed data classes unimplementable by third parties, then many things are possible (just not third party implementations). It may not change the design issues, but it does make the change more likely to have a guaranteed positive performance impact, and it makes it "more OK" to have special behavior for those particular classes - for example a read-only superinterface (which will not be assignable to Existing classes implementing typed data types will have to stop doing that. That's only a problem if uses of that code relies on those third-party typed data classes being compatible with the platform types. If, say, a I would also really want to make the unmodifiable lists be backed by actual unmodifiable buffers. If you put a bit on the buffer somehow, and check when creating a |
/subscribe. Related to Dart and core collection immutability / third party collections: Sealing or watching List objects: #27755 |
Also related |
These types now work with Dart_TypedDataAcquireData. The presence of these types no longer degrades the performance of typed data indexed loads. The presence of these types degrades the performance of typed data indexed stores much less. The performance of indexed stores is somewhat regressed if these types were not used. TEST=ci Bug: #32028 Bug: #40924 Bug: #42785 Change-Id: I05ac5c9543f6f61ac37533b9efe511254778caed Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253700 Reviewed-by: Aske Simon Christensen <askesc@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This reverts commit d1112d3. Reason for revert: b/242043014 Original change's description: > [vm] Recognize unmodifiabled typed data views. > > These types now work with Dart_TypedDataAcquireData. > > The presence of these types no longer degrades the performance of typed data indexed loads. > > The presence of these types degrades the performance of typed data indexed stores much less. The performance of indexed stores is somewhat regressed if these types were not used. > > TEST=ci > Bug: #32028 > Bug: #40924 > Bug: #42785 > Change-Id: I05ac5c9543f6f61ac37533b9efe511254778caed > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253700 > Reviewed-by: Aske Simon Christensen <askesc@google.com> > Reviewed-by: Martin Kustermann <kustermann@google.com> > Commit-Queue: Ryan Macnak <rmacnak@google.com> TBR=kustermann@google.com,rmacnak@google.com,askesc@google.com TEST=ci Change-Id: I32c1c460fc30c51bc0d42e7cfaafe72bf5630069 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: #32028 Bug: #40924 Bug: #42785 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254560 Reviewed-by: Siva Annamalai <asiva@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
These types now work with Dart_TypedDataAcquireData. The presence of these types no longer degrades the performance of typed data indexed loads. The presence of these types degrades the performance of typed data indexed stores much less. The performance of indexed stores is somewhat regressed if these types were not used. TEST=ci Bug: #32028 Bug: #40924 Bug: #42785 Change-Id: Iffad865708501acf96db418985cd5a69bd9afa55 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254501 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
Turns out
UnmodifiableUint8ListView
is used internally as an immutable wrapper around embedded data.This means
TypedDataSpecializer
would not inline any virtual accesses throughUint8List
interface - becauseUnmodifiableUint8ListView
introduces a third-party implementor which does not follow uniform_TypedData
layout.We should check if we leaving calls on any hot code paths due to this - and look into potentials ways to mitigate it.
/cc @mkustermann
The text was updated successfully, but these errors were encountered: