Commit Graph

14 Commits

Author SHA1 Message Date
GitLab Bot 0d8e625e4c Add latest changes from gitlab-org/gitlab@master 2020-05-25 15:07:58 +00:00
GitLab Bot 04baa85554 Add latest changes from gitlab-org/gitlab@master 2020-04-03 09:09:31 +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
Kamil Trzciński 0eeadb2dd2 Normalize import_export structure
This brings a significant refactor to how
we handle `import_export.yml`, merge it with EE
and how we handle that for reader and saver.

This is meant to simplify the code, and remove
a ton of conditions to handle different models
of the structure.

This is also meant to prepare the structure
to extend it much easier, like adding `preload:`
or additional object types when needed.

This does not change the behavior of import/export,
rather unifies and simplifies the current implementation.
2019-09-06 14:21:17 +02:00
Kamil Trzciński 8d1e97fc3b Optimise import performance
- Fix `O(n)` complexity of `append_or_update_attribute`,
  we append objects to an array and re-save project
- Remove the usage of `keys.include?` as it performs `O(n)`
  search, instead use `.has_key?`
- Remove the usage of `.keys.first` as it performs a copy
  of all keys, instead use `.first.first`
2019-07-24 16:24:28 +02:00
gfyoung 7ec8af5017 Enable even more frozen string for lib/gitlab
Enables frozen string for the following:

* lib/gitlab/hook_data/**/*.rb
* lib/gitlab/i18n/**/*.rb
* lib/gitlab/import/**/*.rb
* lib/gitlab/import_export/**/*.rb
* lib/gitlab/kubernetes/**/*.rb
* lib/gitlab/legacy_github_import/**/*.rb
* lib/gitlab/manifest_import/**/*.rb
* lib/gitlab/metrics/**/*.rb
* lib/gitlab/middleware/**/*.rb

Partially addresses gitlab-org/gitlab-ce#47424.
2018-11-16 17:41:14 -08:00
Francisco Javier López 761d890a68
Blacklisting attributes in the project import process 2018-05-14 09:28:33 +02:00
Robert Speicher 142b9ec4a0 Fix two additional violations caused by previous changes 2017-08-15 15:53:16 -04:00
Robert Speicher 4edfad9678 Enable Layout/TrailingWhitespace cop and auto-correct offenses 2017-08-15 13:44:37 -04:00
James Lopez a5f04ad488 fixed CI commits on export 2016-05-18 17:48:15 +02:00
James Lopez 5dad9f1fcb new line missing 2016-05-09 16:19:07 +00:00
James Lopez 7ff2a51eb2 more refactoring to import export reader 2016-05-09 17:58:43 +02:00
James Lopez 9c639041fe bit more refactoring of import export reader, fixed rubocop warning 2016-05-09 12:15:50 +02:00
James Lopez 8ac53eb5d0 started refactoring import export reader - WIP 2016-05-06 17:55:06 +02:00