Skip to content

Upgrade grape-path-helpers to 1.7.0

Heinrich Lee Yu requested to merge upgrade-grape-path-helpers into master

What does this MR do?

This brings in the performance improvement in https://gitlab.com/gitlab-org/grape-path-helpers/-/merge_requests/38

Testing locally

Without this patch:

[1] pry(main)> class Helpers
[1] pry(main)*   include GrapePathHelpers::NamedRouteMatcher
[1] pry(main)* end
=> Helpers
[2] pry(main)> helpers = Helpers.new
=> #<Helpers:0x00007f88b6cf3a78>
[3] pry(main)> puts Benchmark.measure { helpers.api_v4_projects_path(id: 5) }
  2.373852   0.032682   2.406534 (  2.406481)
=> nil
[4] pry(main)> puts Benchmark.measure { 10_000.times { helpers.api_v4_projects_path(id: 5) } }
  3.920357   0.004969   3.925326 (  3.925379)
=> nil
[5] pry(main)> puts Benchmark.measure { 10_000.times { helpers.api_v4_projects_path(id: 5) } }
  3.906761   0.016464   3.923225 (  3.923381)
=> nil
[6] pry(main)> puts Benchmark.measure { 10_000.times { helpers.api_v4_projects_path(id: 5) } }
  3.897988   0.004267   3.902255 (  3.902425)
=> nil

With this patch:

[1] pry(main)> class Helpers
[1] pry(main)*   include GrapePathHelpers::NamedRouteMatcher
[1] pry(main)* end
=> Helpers
[2] pry(main)> helpers = Helpers.new
=> #<Helpers:0x00007fc600f42a68>
[3] pry(main)> puts Benchmark.measure { helpers.api_v4_projects_path(id: 5) }
  2.374689   0.044254   2.418943 (  2.411916)
=> nil
[4] pry(main)> puts Benchmark.measure { 10_000.times { helpers.api_v4_projects_path(id: 5) } }
  0.144653   0.012070   0.156723 (  0.156732)
=> nil
[5] pry(main)> puts Benchmark.measure { 10_000.times { helpers.api_v4_projects_path(id: 5) } }
  0.143720   0.000000   0.143720 (  0.143721)
=> nil
[6] pry(main)> puts Benchmark.measure { 10_000.times { helpers(.api_v4_projects_path(id: 5) } }
  0.142390   0.000000   0.142390 (  0.142401)
=> nil

(First call is slow because that loads the routes and memoizes them)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Heinrich Lee Yu

Merge request reports