Skip to content

Optimize Nokogiri search for post-processing pipeline [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Vasilii Iakliushin requested to merge 271242_optimize_linkable_attributes into master

What does this MR do?

Problem

doc.search(...) operation has a bad performance for complex html documents with many elements.

Solution

Avoid unnecessary doc.search calls.

  1. Combine multiple search operations
  2. Share calculated result between several filters

Screenshots (strongly suggested)

I tested the performance locally with provided worst case.

Before After
1.48367 0.38897
0.61317 0.48994
0.56842 0.37986
0.58618 0.36526
0.64647 0.44602
0.63078 0.47386
0.62561 0.35649
0.63586 0.43862
0.6167 0.43969
0.63569 0.40646
AVG AVG
0.704 0.418

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Vasilii Iakliushin

Merge request reports