POC: Parallel exposure rendering
What does this MR do and why?
This MR will render selected Grape Entities in multiple threads. An exposure looks something like:
class Project < Grape::Entity
expose :name
expose :another_attribute
expose :more_attributes
end
Normally they are processed one at a time:
some_project.name
some_project.another_attribute
some_project.more_attributes
But now we can process all three attributes at the same time.
Only entities that include a method called parallel_nesting_exposure?
that returns true
will be run in parallel. There's a concern to make this process neat:
class Project < Grape::Entity
include ::API::Concerns::Entities::ParallelNestingExposure
expose :name
expose :another_attribute
expose :more_attributes
end
In particular, the /api/v4/projects
endpoint is very slow because of the amount of data that has to be rendered. We've previously established that the view rendering is the problem and not the database queries. By processing exposures in parallel it's hoped we can speed up view rendering.
Related to &8164 (comment 1182446836)
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.