Commit b29de78e authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Improve memory consumption of issuable APIs

Disables method replacement when batch loading because we don't need
or use all the methods in Struct and this leads to a lot of memory
allocations.

Changelog: performance
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61561
parent f4e8401b
---
title: Improve memory consumption of issuable APIs
merge_request: 61561
author:
type: performance
...@@ -24,7 +24,7 @@ module API ...@@ -24,7 +24,7 @@ module API
# entity according to the current top-level entity options, such # entity according to the current top-level entity options, such
# as the current_user. # as the current_user.
def lazy_issuable_metadata def lazy_issuable_metadata
BatchLoader.for(object).batch(key: [current_user, :issuable_metadata]) do |models, loader, args| BatchLoader.for(object).batch(key: [current_user, :issuable_metadata], replace_methods: false) do |models, loader, args|
current_user = args[:key].first current_user = args[:key].first
issuable_metadata = Gitlab::IssuableMetadata.new(current_user, models) issuable_metadata = Gitlab::IssuableMetadata.new(current_user, models)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment