Commit 198f2a0b authored by Stan Hu's avatar Stan Hu

Use Nokogiri as the ActiveSupport XML backend

This significantly improves performance and reduces memory consumption
when parsing XML files. On a test with 124 JUnit files from a CE build,
there was about a 4x reduction in processing time.

parent 6494467a
title: Use Nokogiri as the ActiveSupport XML backend
merge_request: 23136
type: performance
......@@ -158,6 +158,9 @@ module Gitlab
config.action_view.sanitized_allowed_protocols = %w(smb)
# Nokogiri is significantly faster and uses less memory than REXML
ActiveSupport::XmlMini.backend = 'Nokogiri'
# This middleware needs to precede ActiveRecord::QueryCache and other middlewares that
# connect to the database.
config.middleware.insert_after Rails::Rack::Logger, ::Gitlab::Middleware::BasicHealthCheck
......@@ -14,7 +14,7 @@ module Gitlab
test_case = create_test_case(test_case)
rescue REXML::ParseException
rescue Nokogiri::XML::SyntaxError
raise JunitParserError, "XML parsing failed"
raise JunitParserError, "JUnit parsing failed"
......@@ -9,3 +9,4 @@ require 'active_support/all'
ActiveSupport::Dependencies.autoload_paths << 'lib'
ActiveSupport::Dependencies.autoload_paths << 'ee/lib'
ActiveSupport::XmlMini.backend = 'Nokogiri'
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment