Skip to content

Reduce allocation for Repository#build_greps method in twice

Hello, I used Stackprof with around rspec option for profiling allocated objects (You can read little bit more in this blog post: http://blog.davydovanton.com/2015/12/15/stackprof-with-minitest/). And here results (top 5 methods):

Before (master branch)

==================================
  Mode: object(1)
  Samples: 151287 (0.00% miss rate)
  GC: 0 (0.00%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
    387811 (256.3%)      108257  (71.6%)     Gitlab::Git::Repository#build_greps
     15638  (10.3%)       15638  (10.3%)     Gitlab::Git::Commit#init_from_rugged
      4026   (2.7%)        2745   (1.8%)     Gitlab::Git::Tree#initialize
      4324   (2.9%)        2322   (1.5%)     Gitlab::Git::Repository#ls_files
      3418   (2.3%)        1540   (1.0%)     RSpec::Core::Hooks#find_hook

After (with my patch)

==================================
  Mode: object(1)
  Samples: 94439 (0.00% miss rate)
  GC: 0 (0.00%)
==================================
     TOTAL    (pct)     SAMPLES    (pct)     FRAME
    193713 (205.1%)       54032  (57.2%)     Gitlab::Git::Repository#build_greps
     16344  (17.3%)       16344  (17.3%)     Gitlab::Git::Commit#init_from_rugged
      4324   (4.6%)        2322   (2.5%)     Gitlab::Git::Repository#ls_files
      2754   (2.9%)        1528   (1.6%)     Gitlab::Git::Blame#process_raw_blame
      3067   (3.2%)        1377   (1.5%)     RSpec::Core::Hooks#find_hook

Merge request reports