Skip to content

Improve the loading of packages tags

What does this MR do and why?

GitLab npm Registry provides an information about tags linked to a package.
It turned out that sometimes this query can perform quite slow: link (internal)

We already added the index that will speed up the query: !110631 (merged)

Additionally this MR changes the query to fetch Packages::Tag from the database.
It will bring another significant improvement.
The detailed database analysis is here

Another measurement we'll take is to remove last_of_each_version from here But first it is required to eliminate duplicate npm packages: &9812 (closed)

📸 Screenshots or screen recordings

Screenshot_2023-02-06_at_16.10.11

🔬 How to set up and validate locally

  1. Prepare npm package with tags. For that in rails console run the following:

    def fixture_file_upload(*args, **kwargs)
      Rack::Test::UploadedFile.new(*args, **kwargs)
    end
    
    package = FactoryBot.create(:npm_package, project: Project.first)
    10.times { FactoryBot.create(:packages_tag, package: package) }
    package.name # note down package's name, it will be used in the url later.
  2. Create request to list package's tags docs

    $ curl --header "Authorization: Bearer <PAT>" "http://gdk.test:3000/api/v4/projects/:project_id/packages/npm/-/package/:package_name/dist-tags"
  3. Validate the response. It should contain the tags of package.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #388241 (closed)

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports