Skip to content

Draft: Cache objects being used in note policy checks in request

Patrick Bajao requested to merge 335566-reduce-objects-for-ability-checks into master

What does this MR do?

When we request for discussions, we also filter the notes we show if they're readable by user via policy checks.

When there are a number of notes (e.g. 100+) in discussions, it means that the policy check will run the same number of times.

The policies involved with it seems to instantiate the same objects for each note (e.g. noteable which can be an Issue, Merge Request or Epic, project).

This reduces those objects by caching it so the same object will be reused. The cache is scoped by request since it only needs to happen on the same request.

When tested locally, it reduced the response times of MergeRequests#discussions.json endpoint to ~1s from 1.6s when cached.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related to #335566 (closed)

Edited by Patrick Bajao

Merge request reports