-
Notifications
You must be signed in to change notification settings - Fork 187
Generate bytes
with Uint8List
#219
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
Comments
Can you be more specific? |
@sigmundch I updated the description to have current behavior and desired behavior. |
Just hit the same wall. |
@sigurdm Any traction on this? most of the ref: dart-lang/sdk#36900 |
Relatedly, we currently do not convert @$pb.TagNumber(15)
set optionalBytes($core.List<$core.int> v) {
$_setBytes(14, v);
} which calls protobuf.dart/protobuf/lib/src/protobuf/generated_message.dart Lines 456 to 457 in 14c9c0b
So the value is stored as protobuf.dart/protobuf/lib/src/protobuf/coded_buffer_writer.dart Lines 339 to 342 in 14c9c0b
I think the "ideal" solution would be to take That's a breaking change though and I'm not sure if we can afford it internally. So a close second could be keeping the API as-is, but storing the values as |
I just realized that this is not true, because protobuf.dart/protobuf/lib/src/protobuf/coded_buffer_writer.dart Lines 339 to 342 in 14c9c0b
We don't allocate a Another strange thing that I realized while reading the 4 lines shown above is that when we set a syntax = "proto3";
message M1 {
bytes b = 1;
} M1 m = M1();
m.b = <int>[99999];
print(m.b); // [99999]
print(m.writeToBuffer()); // [10, 1, 159] The reason why this is strange is because if I send this message to another program I would expect the local value for the message and the received message value to be the same, but if both the sender and the receiver use the Oh, and also, the JSON map and proto3 JSON serializers throw an exception when serializing this field.. So the library is also inconsistent in handling of such values. |
I understand that this could break someones code and is not backwards compatible, but I think having an |
Hi |
This is indeed a serious issue. |
Any progress? |
I'm curious about progress here too. I'm using the Avif package to get avif images in Dart. It also made me profile a little as loading half a dozen frames on screen gives a notable stutter. Now if i'm reading the flamegraph correctly then the conversion take a very large part of image processing. It seems in this specific case that converting the container formats takes more time then decoding the actual image. This is with a small caveat. I'm not entirely sure about this opinion yet. This is a stack of tech that i'm not too familiar with. If my assumption is even correct, which some testing does seem to prove it is, then having a Uint8List path is much desired. However, another spot in the same code that proves a bit more tricky to fix in the same manner: This calls void mergeFromBuffer(List<int> input,
[ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) {
final codedInput = CodedBufferReader(input);
final meta = _fieldSet._meta;
_mergeFromCodedBufferReader(meta, _fieldSet, codedInput, extensionRegistry);
codedInput.checkLastTagWas(0);
} Replacing that with Uint8List does begin to break other packages i also have installed.. |
@markg85 There shouldn't be any performance issues caused by Dart protobuf library accepting Can you show me what exactly you changed in the protobuf library that made a difference in the flame graphs? Some notes:
|
Thank you so much for that detailed (educational!) response! I was just about to grab the changes i made in the protobuf file when i noticed your edit :)
I did change the protobuf to replace the Regarding that last framegraph and the remark around mergeFromBuffer. What you say sounds logical. However in the overall time spend within a frame, more time is spend in that function than is spend in decoding the actual image. Is there perhaps a more efficient way of doing this? For clarity, the flamegraph showing this: In total the time distribution is about this: The image is of that 2/5th part. |
My guess is you have a lot of very small Otherwise I don't know how else to explain this flamegraph, |
Not that many, really. This is loading "thumbnail sized" images. Now you do have pixel ratio so thumbnail still blows up to about 588x331. And that's about 40 images. But in that same time you have the image decoding, which you can also see. The flamegraph is from not visible to fully rendered. So what you see includes decoding of those images too. |
Ref: https://groups.google.com/a/dartlang.org/forum/#!topic/misc/JpNkRRLI9_w, daegalus/dart-uuid#35
More and more packages are explicitly switching to Uint8List
Right now, with the folling proto
The generated dart code (by
Activated protoc_plugin 16.0.1.
) isWe can see that we still have
Expected generated code:
One concern might be that this is more or less a breaking change in strong mode.
The text was updated successfully, but these errors were encountered: