-
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
[vm/ffi] Optimize asTypedList() #39843
Comments
Any chance this is going to be addressed? We have had to do various workarounds in pub.dev/packages/objectbox to at least alleviate the issue but there's really no way to completely get around it AFAIK. And it really is rather slow at about 7.5 million |
Your benchmark results are consistent with the ones in the SDK: sdk/benchmarks/FfiMemory/dart/FfiMemory.dart Lines 242 to 296 in f820f7c
I can't make any statements on prioritization. Currently, we're busy working on other Until we get to this, would it be possible to use the |
We're using it to get a |
I've tried a rough, simple (and probably incorrect) dart implementation of ByteData, with its overrides implemented using byte shifts and indexing a Pointer<>, e.g. @override
int getUint32(int byteOffset, [Endian endian = Endian.big]) {
assert(endian == Endian.little);
return (_ptr[byteOffset + 3] << 24) |
(_ptr[byteOffset + 2] << 16) |
(_ptr[byteOffset + 1] << 8) |
_ptr[byteOffset];
} but it's even slower than using |
@dcharkes I'm happy to contribute this change if you can point me in the right direction, e.g. what you meant by "make this a recognized method." |
That is a fairly complicated process. It involves writing our intermediate representation graph in the compiler. Here is the same process for making Furthermore, that intermediate representation then generates machine code, which if it is wrong will lead to segfaults which are good fun debugging. Unless you're already familiar with (1) building the Dart VM, (2) Dart VM's intermediate representation, and (3) debugging segfaults with GDB/RR, I would not recommend it. |
Thanks @dcharkes, the linked MR has convinced me this is not the right time for me to get involved here :) |
I've submitted a PR (#47780) to resolve this issue. |
You made my day! I left a review in Gerrit: https://dart-review.googlesource.com/c/sdk/+/221360. Upon running the tests I saw 1 test started failing. Let me know if you need help debugging it. (The test doesn't fail on main.) cc @sstrickl who is fluent in the type testing stubs and type argument vectors. |
Glad I can help. 😃 |
@dcharkes Update Update Update |
Sorry about the delay in responding, was OOO last week. Thanks for digging further, @blaugold, that sounds right and I can make a quick fix CL if so :) |
Done in https://dart-review.googlesource.com/c/sdk/+/221467, up for review now. |
As discovered by @blaugold on GitHub, Instructions::Equals can give a false negative on the JIT if the GC flags in the object header are set differently. This CL changes Instructions::Equals to only compare the Instructions-specific portion of the object, namely the size_and_flags_ field and the content bytes. If those match, then the important parts of the object header match: the cid is always kInstructionsCid, as the Equals method assumes non-null instances, and the size in the object header is calculated using the content size from size_and_flags_. TEST=Manually ran failing tests after cherry picking CL 221360 on top. Bug: #39843 Change-Id: I25c25bbe6b1bf615d4cd923bfe871da7e929822a Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-linux-product-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221467 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com>
CL has landed, so you should be clear now. Manual running of the tests succeeded on some of the failing build configurations, so if you're still seeing failures in the other CL once rebased, I'd be interested in knowing. |
Thanks for the quick fix @sstrickl. |
_asExternalTypedData
is implemented as a runtime entry, we should make this a recognized method.The text was updated successfully, but these errors were encountered: