summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/i18n
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-12-11 23:31:39 -0800
committerKamil TrzciƄski <ayufan@ayufan.eu>2019-09-09 15:16:16 +0200
commit7a142a6fdea797ce56fec6b50840600a1d132f64 (patch)
treeac097ef6c5fd80fb6e59b7188d612365955c43b2 /spec/lib/gitlab/i18n
parentcf180734cbabd100641153ca92c086a7da259e9a (diff)
downloadgitlab-ce-kamil-improve-import-export.tar.gz
Improve performance and memory usage of project exportkamil-improve-import-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.
Diffstat (limited to 'spec/lib/gitlab/i18n')
0 files changed, 0 insertions, 0 deletions