PoC: Caching keep_around_commits by SHAs
What does this MR do?
Tested this locally by publishing 6 draft notes. From 36 calls for ref_service#ref_exists
, it's down to 6.
The idea here is that we will only cache the part where N+1 is occurring. In the context of DraftNotesController#publish
, it happens in DiffNote#keep_around_commits
as it's being executed per draft note being published.
This utilizes the RequestCache
mechanism and the cache key are the SHAs to be kept. We use the SHAs as the cache key because in a single publish request, it's possible that all draft notes being published all have the same SHAs.
The calls were reduced because in the tests that was done, all draft notes were created on single version of diff so all SHAs based on their position are the same. If draft notes being published are from different versions, the improvement does not apply because the shas
will be different.
Related to #226924 (closed)