Commit Graph

7 Commits

Author SHA1 Message Date
GitLab Bot 4220cf46a3 Add latest changes from gitlab-org/gitlab@master 2022-03-22 12:07:28 +00:00
GitLab Bot 04baa85554 Add latest changes from gitlab-org/gitlab@master 2020-04-03 09:09:31 +00:00
GitLab Bot 45b4df3e57 Add latest changes from gitlab-org/gitlab@master 2020-03-30 09:07:58 +00:00
GitLab Bot c36152ff8c Add latest changes from gitlab-org/gitlab@master 2020-03-13 15:09:21 +00:00
GitLab Bot 185f428fa5 Add latest changes from gitlab-org/gitlab@master 2019-10-07 12:06:18 +00:00
GitLab Bot 927cfbfe63 Add latest changes from gitlab-org/gitlab@master 2019-10-03 12:06:00 +00:00
Kamil Trzciński 0e56c1e7cb Improve performance and memory usage of project export
ActiveModel::Serialization is simple in that it recursively calls
`as_json` on each object to serialize everything. However, for a model
like a Project, this can generate a query for every single association,
which can add up to tens of thousands of queries and lead to memory
bloat.

To improve this, we can do several things:

1. We use `tree:` and `preload:` to automatically generate
   a list of all preloads that could be used to serialize
   objects in bulk.

2. We observe that a single project has many issues, merge requests,
   etc. Instead of serializing everything at once, which could lead to
   database timeouts and high memory usage, we take each top-level
   association and serialize the data in batches.

For example, we serialize the first 100 issues and preload all of
their associated events, notes, etc. before moving onto the next
batch. When we're done, we serialize merge requests in the same way.
We repeat this pattern for the remaining associations specified in
import_export.yml.
2019-09-09 15:40:49 +00:00