JSON Performance Improvements
Following on from #211671 (closed)
There are various improvements we can make to our JSON handling. These are the currently planned steps:
Old goals
1. ~~[ ] Swap the `Gitlab::Json` wrapper to use `multi_json` so it mirrors a lot of usage from gems we use~~
2. ~~[ ] Add performance metrics hooks into `JSON`, or possibly `multi_json`~~
3. ~~[ ] Deprecate old way of parsing JSON~~
4. ~~[ ] Add `oj` and allow other gems which use `multi_json` to use it to improve performance~~
5. ~~[ ] Measure performance difference `oj` makes, document somewhere to prevent it being removed again~~
6. ~~[ ] Utilise `oj` application-wide to improve all JSON handling~~
7. ~~[ ] Investigate conditionally using other gems in specific areas (I recall @nick.thomas looking at YAJL for something specific?)~~
Current goals
-
Add oj
support toGitlab::Json
-
Expand oj
support inGitlab::Json
to include.generate
and.pretty_generate
-
Swap our JSON logger to use Gitlab::Json
-
Swap Grape to use Gitlab::Json
-
Enable oj
inmulti_json
initializer to support external gems -
Update the Gitlab::Json
cop to cover.to_json
calls -
Update Rails to use Gitlab::Json
to performrender :json
processing on endpoints -
Add helpers to provide a short-form way of calling Gitlab::Json
in views -
Autocorrect all the existing usage of .to_json
-
Update cop to use helpers in HAML files -
Autocorrect all HAML files and reintroduce the cop -
Update development guidelines with new requirements -
Update development guidelines further with new helpers and method guidelines -
Investigate serializers and presenters to see if they are utilising Gitlab::Json
already
I'll be linking the MRs to this issue.
Relevant feature flags
:json_wrapper_legacy_mode, default_enabled: true
:oj_json, default_enabled: true
:grape_gitlab_json, default_enabled: true
:active_support_gitlab_json, default_enabled: false
If this work is causing issues, first try disabling :oj_json
.
Edited by Robert May