Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: google/protobuf.dart
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: google/protobuf.dart
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: improve_enum_decoding_2
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 4 commits
  • 12 files changed
  • 1 contributor

Commits on May 8, 2025

  1. Improve enum decoding -- alternative

    This is an alternative to #980 that doesn't make a big difference in
    terms of performance of AOT compiled benchmarks, but makes a big
    difference when compiling to Wasm, comapred to #980.
    
    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.
    
    Note: similar to the map, the list is runtime allocated. No new code
    generated per message or enum type.
    
    Wasm benchmarks:
    
    - Before: `protobuf_PackedEnumDecoding(RunTimeRaw): 48200.0 us`
    - PR #980: `protobuf_PackedEnumDecoding(RunTimeRaw): 42120.0 us`
        - Diff: -12.6%
    - After: `protobuf_PackedEnumDecoding(RunTimeRaw): 35733.3 us`
        - Diff against PR #980: -15%
        - Diff against master: -25%
    
    AOT benchmarks:
    
    - Before: `protobuf_PackedEnumDecoding(RunTimeRaw): 49180.0 us`
    - PR #980: `protobuf_PackedEnumDecoding(RunTimeRaw): 45726.82 us`
        - Diff: -7%
    - This PR: `protobuf_PackedEnumDecoding(RunTimeRaw): 42929.7 us`
        - Diff against PR #980: -6%
        - Diff agianst master: -12%
    osa1 committed May 8, 2025
    Configuration menu
    Copy the full SHA
    4878307 View commit details
    Browse the repository at this point in the history

Commits on May 9, 2025

  1. Configuration menu
    Copy the full SHA
    1f2064d View commit details
    Browse the repository at this point in the history
  2. Add sparse enum decoding benchmarks

    With upcoming change we'll improve decoding performance of enums, but
    there will be a difference between "sparse" and "dense" enum decoding
    performance even though they'll both be faster.
    
    To be able to measure the difference add a "sparse" enum type and a
    benchmark for decoding it.
    
    "Sparse" means the enum has large gaps between known enum values, or
    negative enum values.
    
    When decoding this kind of enums, the mapping from the wire `varint` to
    the Dart value for the enum needs to be done by binary search, map
    lookup, or similar.
    
    For "dense" enums, we can have a list of enum values and index the list
    directly with the `varint` value, after a range check.
    
    These changes will be done in the follow-up PR(s).
    osa1 committed May 9, 2025
    Configuration menu
    Copy the full SHA
    11cd8fd View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    947dee6 View commit details
    Browse the repository at this point in the history
Loading