Skip to content
Snippets Groups Projects

db: Optimize authzFilter code path

Merged Administrator requested to merge core/authz-filter-optimization into master

Created by: tsenart

Summary

This PR optimizes the authzFilter code paths.

Benchmark

name             old time/op    new time/op    delta
_authzFilter-16    56.2ms ± 2%     1.0ms ± 1%  -98.14%  (p=0.000 n=15+15)

name             old alloc/op   new alloc/op   delta
_authzFilter-16    55.3MB ± 0%     0.5MB ± 0%  -99.03%  (p=0.000 n=15+14)

name             old allocs/op  new allocs/op  delta
_authzFilter-16     65.8k ± 0%      0.0k ± 0%  -99.94%  (p=0.000 n=15+15)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Created by: tsenart

    cc @sourcegraph/core-services

  • Created by: codecov[bot]

    Codecov Report

    Merging #4790 into master will increase coverage by 0.06%. The diff coverage is 95.51%.

    @@            Coverage Diff             @@
    ##           master    #4790      +/-   ##
    ==========================================
    + Coverage   48.07%   48.14%   +0.06%     
    ==========================================
      Files         726      726              
      Lines       44263    44226      -37     
      Branches     1761     1761              
    ==========================================
    + Hits        21281    21294      +13     
    + Misses      21001    20959      -42     
    + Partials     1981     1973       -8
    Impacted Files Coverage Δ
    cmd/frontend/db/repos_perm.go 85.1% <100%> (+3.92%) :arrow_up:
    ...rontend/internal/authz/bitbucketserver/provider.go 82.9% <100%> (+1.39%) :arrow_up:
    cmd/frontend/authz/perms.go 100% <100%> (ø)
    ...d/frontend/internal/authz/bitbucketserver/store.go 79.64% <100%> (-0.25%) :arrow_down:
    ...cmd/frontend/internal/authz/gitlab/gitlab_oauth.go 65.88% <90.47%> (-0.47%) :arrow_down:
    .../cmd/frontend/internal/authz/gitlab/gitlab_sudo.go 72.72% <90.9%> (+1.62%) :arrow_up:
    ...prise/cmd/frontend/internal/authz/github/github.go 66.97% <92.3%> (+0.15%) :arrow_up:
    ... and 1 more
  • Created by: tsenart

    @keegancsmith: This PR was a draft. It's now ready for review.

  • Created by: tsenart

    Actuallt, hold off from review please. There's still something I need to do.

  • Created by: tsenart

    Got another small boost with the last commit :)

    name             old time/op    new time/op    delta
    _authzFilter-16    2.38ms ± 4%    1.94ms ± 4%  -18.52%  (p=0.000 n=15+13)
    
    name             old alloc/op   new alloc/op   delta
    _authzFilter-16    3.23MB ± 0%    2.98MB ± 0%   -7.61%  (p=0.000 n=15+10)
    
    name             old allocs/op  new allocs/op  delta
    _authzFilter-16      97.0 ± 0%      96.0 ± 0%   -1.03%  (p=0.000 n=15+15)
  • Created by: tsenart

    And another.

    name             old time/op    new time/op    delta
    _authzFilter-16    1.99ms ± 4%    1.88ms ± 6%  -5.67%  (p=0.000 n=14+15)
    
    name             old alloc/op   new alloc/op   delta
    _authzFilter-16    2.98MB ± 0%    2.98MB ± 0%    ~     (p=0.680 n=15+14)
    
    name             old allocs/op  new allocs/op  delta
    _authzFilter-16      96.0 ± 0%      96.0 ± 0%    ~     (all equal)
  • Created by: tsenart

    And at last, the previous commit brings it further down.

    name             old time/op    new time/op    delta
    _authzFilter-16    1.88ms ± 6%    1.26ms ± 9%  -33.02%  (p=0.000 n=15+15)
    
    name             old alloc/op   new alloc/op   delta
    _authzFilter-16    2.98MB ± 0%    0.86MB ± 2%  -71.24%  (p=0.000 n=14+15)
    
    name             old allocs/op  new allocs/op  delta
    _authzFilter-16      96.0 ± 0%      51.0 ± 0%  -46.88%  (p=0.000 n=15+15)
  • Created by: tsenart

    Some more improvements

    name             old time/op    new time/op    delta
    _authzFilter-16    1.21ms ± 8%    1.05ms ± 1%  -13.09%  (p=0.000 n=15+15)
    
    name             old alloc/op   new alloc/op   delta
    _authzFilter-16     884kB ± 1%     537kB ± 0%  -39.29%  (p=0.000 n=15+14)
    
    name             old allocs/op  new allocs/op  delta
    _authzFilter-16      51.0 ± 0%      39.0 ± 0%  -23.53%  (p=0.000 n=15+15)
  • Created by: tsenart

    @beyang: I'm merging this now because I'm confident in the changes. But I'd still love to hop on a call next week to go over any remaining questions or uncertainties you may have.

Please register or sign in to reply
Loading