hiqdev / asset-packagist

Asset Packagist
https://asset-packagist.org
BSD 3-Clause "New" or "Revised" License
247 stars 24 forks source link

Split `provider-includes` to decrease amount of data to be downloaded #37

Closed hiqsol closed 4 years ago

hiqsol commented 7 years ago

This is a simple but effective optimization.

See links below, hope it is self-explanatory enough:

https://getcomposer.org/doc/05-repositories.md#provider-includes-and-providers-url

https://asset-packagist.org/packages.json

https://packagist.org/packages.json

edgardmessias commented 7 years ago

We need save the packages and releases into database.

From database, we can split packages by last release date and generate packages.

I created a pull request (fxpio/composer-asset-plugin#297) to add the release date in fxpio/composer-asset-plugin

hiqsol commented 7 years ago

I think packages' release dates are not important in this concern. What is important that's keeping older items in provider includes list unchanged and change only the latest item.

Basically my idea is:

I think that's all what is necessary. But I'm not sure how everything works in composer so I'd like to hear other opinions.

edgardmessias commented 7 years ago

My opinion, save the packages and releases into database, to create better search and package pages.

Data can not be duplicated on providers, because of caching.

Flow:

The idea is to update the provider in blocks, not every package update

edgardmessias commented 7 years ago

@hiqsol, after finishing improving the search, I will start working on this item.

hiqsol commented 7 years ago

Data can not be duplicated on providers, because of caching.

Are you absolutely sure about it?

Because then the whole idea of splitting providers is lost I'm afraid. If all the providers got rewritten all the time then they cannot be cached on composer side.

edgardmessias commented 7 years ago

Yes, you can see in the "COMPOSER_HOME".

Example: <composer_home>/repo/https---packagist.org contains only one cache for each package. If the package exists in multiple provider, only one is used.

See the ComposerRepository work

hiqsol commented 7 years ago

only one is used

That's ok as soon as the latest one is used.

What do you think of what I said earlier: splitting is useless if we rewrite providers all the time.

edgardmessias commented 7 years ago

Older packages are not rewrite providers, only the updated.

There are many bower and NPM packages that are not updated

edgardmessias commented 7 years ago

To reduce the rewrite, it would be interesting to use crontab, every 5 minutes for example, and no more per package update

edgardmessias commented 7 years ago

https://wpackagist.org/ rewrite every hour

hiqsol commented 7 years ago

What if we just don't rewrite old providers?

edgardmessias commented 7 years ago

The problem is when an old package is updated, it needs to be removed from the old provider and placed in the new

hiqsol commented 7 years ago

And what if not?

edgardmessias commented 7 years ago

May cause cache problem

hiqsol commented 7 years ago

On user's composer side? What makes you sure about it causes problems? Do you have any links where I can read more about providers?

edgardmessias commented 7 years ago

See the loadProviderListings method in ComposerRepository.

I learned a little better how the composer works:

If the package is in multiple providers, only the last package of the last provider is evaluated.

But the composer will download the package information for each time you find the provider.

Example:

hiqsol commented 7 years ago

Thank you for the research! Need time to dive in myself.

edgardmessias commented 7 years ago

The more you divide the provider, the greater the chance of the client to use the cache.

Maybe we can divide the last months by weeks, and the oldest by month and year.

When a package updates, it will change the most recent provider and the old it was

Example: week-1, week-2, week-3, week-4, week-5, week-this, if update package in week-2, only week-2 and week-this is updated

edgardmessias commented 6 years ago

@hiqsol, Any answers?

github-actions[bot] commented 4 years ago

Stale issue message