Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Optimized the loading of descriptors - #328

Merged
haberman merged 7 commits into
protocolbuffers:masterfrom
haberman:optdefload
Oct 30, 2020
Merged

haberman merged 7 commits into
protocolbuffers:masterfrom
haberman:optdefload

Conversation

@haberman

@haberman haberman commented Oct 30, 2020 •

Copy link
Copy Markdown
Member

This includes several optimizations:

  • Replaced MurmurHash with wyhash, for smaller and faster code.
  • Improved the algorithm for searching for an empty hash table entry.
  • Pre-sized hash tables where possible to avoid the need to grow.
  • Avoid floating-point math when calculating table size based on load.
name                                 old time/op  new time/op  delta
LoadDescriptor_Upb                    112µs ± 1%    69µs ± 5%  -38.51%  (p=0.000 n=11+12)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +16%    +174  [ = ]       0    [Unmapped]
  +0.2%      +5  [ = ]       0    upb/upb.c
     +36%      +5  [ = ]       0    _start
  -0.1%     -16  -0.1%     -16    upb/def.c
    +3.6%     +32  +3.8%     +32    create_enumdef
    +6.9%     +16  +8.3%     +16    upb_symtab_new
    -2.2%     -64  -2.2%     -64    create_msgdef
  -0.3%     -32  -0.4%     -32    bazel-out/k8-opt/bin/external/com_google_protobuf/google/protobuf/wrappers.upb.c
    -0.4%     -32  -0.4%     -32    [section .rodata]
  -0.5%     -32  -0.5%     -32    upb/decode.c
    -9.8%     -32  -9.8%     -32    [section .rodata]
  -1.2%    -107  -1.2%     -96    upb/table.c
    [NEW]    +643  [NEW]    +608    table_hash
     +68%    +128   +89%    +128    upb_strtable_init2
    +8.3%     +51  +8.5%     +48    upb_strtable_resize
    +2.2%     +48  +2.2%     +48    upb_inttable_compact2
    +2.9%     +32  +3.0%     +32    upb_inttable_insert2
    +6.4%     +16  +7.7%     +16    upb_inttable_init2
   -10.4%     -64 -11.3%     -64    upb_strtable_insert3
    [DEL]    -961  [DEL]    -912    upb_murmur_hash2
  -0.0%      -8  -0.1%    -176    TOTAL

@haberman
haberman merged commit 6ae3b66 into protocolbuffers:master Oct 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants