ruby-grape / ruby-grape/grape

Wrapping simple query in Grape method causing big slowdown (3s+)

Open
#1,890 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

Hi, we're struggling to work through an issue where a Rails controller and a Grape API endpoint both run the same underlying ActiveRecord query - literally the same code, and do nothing else, but the controller version runs in average 116ms and the Grape version in average 3.5s.

Here are the two in Skylight, which is great, but doesn't give us the granularity we need to investigate further:

Navbar: https://oss.skylight.io/app/applications/GZDPChmcfm1Q/1561487700/6h/endpoints/Srch::Search%20%5BGET%5D%20srch%2Ftags

Suggested: https://oss.skylight.io/app/applications/GZDPChmcfm1Q/1561487520/6h/endpoints/TagController%23suggested?responseType=json

The code is documented and linked to here: https://github.com/publiclab/plots2/issues/5951

We'd love some advice on how to further investigate, or potentially what else makes these two requests different?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked plots2 issue and compare the two profiled entry points: Srch::Search [GET] srch/tags and TagController#suggested?responseType=json. Use the Skylight traces to isolate where the Grape request diverges from the Rails controller request; done means identifying a reproducible cause and documenting an actionable fix or investigation result.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.