Skip to content

model: avoid another extra creation of Model object

Do not create model object while sorting entry before creating model
object.

This is another case of "let us create object X to prepare the creation
of object X", slowing things down.

In practice, we will likely skip this code-path after the next
changeset, however this seems useful to get this performance footgun
out the way.

We tested this change on simple information of the Mercurial loader,
with a noop-loader stockage:

    swh loader run mercurial https://foss.heptapod.net/mercurial/mercurial-devel directory=/data/repos/mercurial-devel

= Median time of 3 run =
before  12 minutes 59 seconds
after:  11 minute  56 seconds

On a profile of the same run, the `to_model` call of the from_disk's `Directory` class took the following percentage:
before: 24%
after:  17%

Test Plan

ran tox, timing and profile


Migrated from D8527 (view on Phabricator)

Merge request reports