commit | a6c8e56996c63ce7b0f83c7743a393ecb41c77c6 | [log] [tgz] |
---|---|---|
author | Ömer Sinan Ağacan <omersa@google.com> | Thu May 15 11:33:46 2025 +0200 |
committer | GitHub <noreply@github.com> | Thu May 15 10:33:46 2025 +0100 |
tree | e74ca526e93580f7e96cfa2f3c4919a355dc3402 | |
parent | 376c9ce480536ad84572e087e35f31ff931627bc [diff] |
Improve enum decoding -- alternative (#981) When decoding an enum value, we call a callback in the enum field's `FieldInfo`. The callback then indexes a map mapping enum numbers to Dart values. When these conditions hold: - The known enum numbers are all positive. (so that we can use a list and index it with the number) - The known enum numbers are more than 70% of the large known enum number. (so that the list won't have a lot of `null` entries, wasting heap space) We now generate a list instead of a map to map enum numbers to Dart values. Similar to the map, the list is runtime allocated. No new code generated per message or enum type. AOT benchmarks: - Before: `protobuf_PackedEnumDecoding(RunTimeRaw): 47585.14 us.` - After: `protobuf_PackedEnumDecoding(RunTimeRaw): 38974.566666666666 us.` - Diff: -18% Wasm benchmarks: - Before: `protobuf_PackedEnumDecoding(RunTimeRaw): 52225.0 us.` - After: `protobuf_PackedEnumDecoding(RunTimeRaw): 34283.33333333333 us.` - Diff: -34% **Alternatives considered:** - #980 uses a map always, but eliminates the `valueOf` closure. - #985 uses a list always, and does binary search in the list when the list is "shallow". - #987 is the same as #985, but instead of calling the `valueOf` closure it stores an extra field in `FieldInfo`s for whether to binary search or directly index. These are all slower than the current PR.
Protocol Buffers (protobuf) are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.
This repository is home to packages related to protobuf support for Dart.
Package | Description | Published Version |
---|---|---|
protobuf | Runtime library for protocol buffers support. | |
protoc_plugin | A protobuf protoc compiler plugin used to generate Dart code. | |
api_benchmark | Benchmarking a number of different api calls. | |
benchmarks | Benchmarks for various protobuf functions. |
For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.