Skip to content
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

Optimized the loading of descriptors #328

Merged
merged 7 commits into from
Oct 30, 2020

Conversation

haberman
Copy link
Member

@haberman haberman commented Oct 30, 2020

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants