Optimize Banzai::Filter::RelativeLinkFilter
What does this MR do?
Optimize Banzai::Filter::RelativeLinkFilter
A lot of git operations were being repeated, for example, to build a url
you would ask if the path was a Tree, which would call a recursive routine
in Gitlab::Git::Tree#where
, then ask if the path was a Blob, which would
call a recursive routine at Gitlab::Git::Blob#find
, making reference to
the same git objects several times. Now we call Rugged::Tree#path
, which
allows us to determine the type of the path in one pass.
Some other minor improvement added, like saving commonly used references instead of calculating them each time.
Are there points in the code the reviewer needs to double check?
No
Why was this MR needed?
Banzai::Filter::RelativeLinkFilter is snow
What are the relevant issue numbers?
Closes #18590 (closed)
Screenshots (if relevant)
For testing I prepared a file with many relative (to the current and to the root) paths repeated many times. The requests took the following times:
BEFORE
AFTER
Does this MR meet the acceptance criteria?
-
CHANGELOG entry added -
Documentation created/updated -
Tests -
Added for this feature/bug -
All builds are passing
-
-
Conform by the style guides -
Branch has no merge conflicts with master
(if you do - rebase it please) -
Squashed related commits together
/cc @pcarranza