Граф коммитов

66 Коммитов

Автор SHA1 Сообщение Дата
David Rodríguez e6c7a309d0 [rubygems/rubygems] Refactor selecting specs from a SpecSet
https://github.com/rubygems/rubygems/commit/bcbbff5149
2024-07-09 16:34:09 +00:00
David Rodríguez dd05191bc3 [rubygems/rubygems] Resolve all platforms directly
Instead of having to do a complete pass after resolve.

To do this, we add to the ruby group all the platform specs with the
same dependencies as the ruby specs.

https://github.com/rubygems/rubygems/commit/e50415f2a6
2024-07-09 16:34:08 +00:00
David Rodríguez 744dd5a362 [rubygems/rubygems] Fix performance regression on applications with a local cache
Even if all gems are properly installed and no resolve is needed, we
recently started always reading all packages in `vendor/cache` and
extracting specifications from them.

This commit fixes the problem by longer making considering cached specs
the default and only enable them when a resolve is actually needed.

https://github.com/rubygems/rubygems/commit/edeb2c42bf
2024-05-24 15:02:30 +00:00
David Rodriguez 7857061ecd [rubygems/rubygems] Fix regression when caching gems from secondary sources
If `cache_all_platforms` setting is enabled, the secondary source was
no longer considering cached gems.

That means that if the remote secondary source has removed its gems,
then this was now resulting in an error while before the previously
cached gem from the source would still be used.

This commit restores previous behavior.

https://github.com/rubygems/rubygems/commit/2d2cd00255
2024-05-16 09:21:32 +00:00
Mike Dalessio 98c84ef42c [rubygems/rubygems] Excluding local platform from lockfile should not affect musl vs gnu case
This case is for not locking things like `arm-darwin-23` when the
lockfile already includes `arm-darwin`, so that we don't infinitely keep
redundant versioned platforms in the lockfile when not necessary.

We detect this with `Gem::Platform#===`. For example,
`Gem::Platform.new("arm-darwin-23") === Gem::Platform.new("arm-darwin")`
but they're not `==`.

However, in the case of `-musl` vs `-gnu`, those act as the platform
"version", but `===` is not commutative for them. This is explained in
`===` docs.

We only want to exclude the local platform in situations when
`Gem::Platform#===` is actually commutative.

https://github.com/rubygems/rubygems/commit/8099c4face
2024-04-17 18:17:12 +00:00
David Rodriguez 95c9711d6e [rubygems/rubygems] Fix musl platform not being added to the lockfile
https://github.com/rubygems/rubygems/commit/235f7b4266
2024-01-31 19:07:39 +00:00
David Rodríguez b8f859f0bf Complete missing specs for platforms after resolution
If two platform specific variants have different dependencies, then
resolution may fallback to the non platform specific variant. However,
the platform specific variants that have the same dependencies as the
non specific one can still be kept.

Do a pass to complete those after resolution.
2024-01-11 13:51:52 +09:00
David Rodríguez 7f0dbfc9c8 [rubygems/rubygems] Move resetting the spec set to where it becomes necessary
https://github.com/rubygems/rubygems/commit/a8b547c6b1
2024-01-11 13:51:52 +09:00
David Rodríguez 51d2a8e983 [rubygems/rubygems] Extract a couple of helper methods
https://github.com/rubygems/rubygems/commit/880a4eae7f
2024-01-11 13:51:52 +09:00
David Rodríguez ab1936faf9 [rubygems/rubygems] Remove methods to clarify what they do
https://github.com/rubygems/rubygems/commit/1d15d8a8ff
2024-01-11 13:51:52 +09:00
David Rodríguez 76916217b6 [rubygems/rubygems] Extract `SpecSet#reset!` helper
https://github.com/rubygems/rubygems/commit/41f9b4d940
2024-01-11 13:51:52 +09:00
Hiroshi SHIBATA 82496f2b38 Merge RubyGems-3.5.2 and Bundler-2.5.2 2023-12-22 07:24:04 +09:00
David Rodriguez c05495530e [rubygems/rubygems] Fix universal lockfiles regression
If a platform specific variant would not match the current Ruby, we would still be
considering it compatible with the initial resolution and adding its
platform to the lockfile, but we would later fail to materialize it for
installation due to not really being compatible.

Fix is to only add platforms for variants that are also compatible with
current Ruby and RubyGems versions.

https://github.com/rubygems/rubygems/commit/75d1290843
2023-11-22 13:17:12 +00:00
David Rodríguez 435eb56f61 [rubygems/rubygems] Automatically lock extra ruby platforms
Since we started locking the specific platform in the lockfile, that has
created an annoying situation for users that don't develop on Linux.
They will create a lockfile on their machines, locking their local
platform, for example, darwin. But then that lockfile won't work
automatically when deploying to Heroku for example, because the lockfile
is frozen and the Linux platform is not included.

There's the chance though that resolving against two platforms (Linux +
the local platform) won't succeed while resolving for just the current
platform will. So, instead, we check other platform specific variants
available for the resolution we initially found, and lock those
platforms and specs too if they satisfy the resolution.

This is only done when generating new lockfiles from scratch, existing
lockfiles should keep working as before, and it's only done for "ruby
platforms", i.e., not Java or Windows which have their own complexities,
and so are excluded.

With this change, we expect that MacOS users can bundle locally and
deploy to Heroku without needing to do anything special.

https://github.com/rubygems/rubygems/commit/5f24f06bc5
2023-11-13 11:06:10 +09:00
David Rodríguez bd6aaa78c3 [rubygems/rubygems] Remove unused `SpecSet#merge`
https://github.com/rubygems/rubygems/commit/53e0490b55
2023-11-13 11:06:10 +09:00
David Rodríguez 9f67118d7b
[rubygems/rubygems] Simplify selecting specs with `force_ruby_platform` set
https://github.com/rubygems/rubygems/commit/5f90a43635

Co-authored-by: Martin Emde <martin.emde@gmail.com>
2023-11-08 09:04:28 +09:00
David Rodríguez 73ba4b76c2 [rubygems/rubygems] Automatically remove invalid platforms before re-resolving
https://github.com/rubygems/rubygems/commit/40989271dd
2023-10-16 13:52:56 +09:00
Samuel Giddins 83f929316e [rubygems/rubygems] Fix force_ruby_platform: when the lockfile only locks the ruby platform
https://github.com/rubygems/rubygems/commit/7c50064c3c
2023-10-15 04:46:32 +00:00
David Rodríguez f3d69bed62
[rubygems/rubygems] Fix resolver hangs when dealing with an incomplete lockfile
While working on locking multiple platforms by default, I got an
infinite resolution loop in one of our resolver specs.

The culprit ended up being that when dealing with lockfile specs with
incomplete dependencies (spec appears in lockfile, but its dependencies
don't), those specs were not being properly expired and that tripped up
resolution.

The issue for some reason only manifests when dealing with multiple
lockfile platforms, that's why it only manifested when working on
locking multiple platforms by default.

https://github.com/rubygems/rubygems/commit/4ca72913bb
2023-04-06 13:07:16 +09:00
David Rodríguez c257380965
Revert "Refactor incomplete specs handling"
This reverts commit 69580f8b72f41c58cae57d1ada4db909922b3891.
2023-04-06 13:07:16 +09:00
David Rodríguez 192a3a6bfb
[rubygems/rubygems] Revert "Reuse `SpecSet#materialize` logic"
This reverts commit https://github.com/rubygems/rubygems/commit/a20585b4512d.

https://github.com/rubygems/rubygems/commit/aa9102659e
2023-04-06 13:07:16 +09:00
David Rodríguez a757e21bc0 Reuse `SpecSet#materialize` logic 2023-03-23 17:18:49 +09:00
David Rodríguez ebebc90ec2 Refactor incomplete specs handling
Recent bugs fixed made me realize we were relying on state too much
here. We only need to keep incomplete specs to be able to expire them
and retry resolution without them locked. If we use a separate class, we
can do that more transparently and handle them just like we handle
"missing specs".
2023-03-23 17:18:49 +09:00
David Rodríguez 8e6bbc032c Don't remove RUBY platform when healing a lockfile with missing specs 2023-03-23 17:18:49 +09:00
David Rodríguez 4e7c39f98c Don't remove RUBY platform when healing a lockfile with missing specs 2023-03-23 17:18:49 +09:00
David Rodríguez 8371c0eac4 [rubygems/rubygems] Fix incorrect error message when multiple platforms are locked
https://github.com/rubygems/rubygems/commit/24d2bf9cb2
2023-03-17 18:50:55 +09:00
Ellen Marie Dash d2d521b274 [rubygems/rubygems] Regenerate lockfile if spec list is invalid/empty.
https://github.com/rubygems/rubygems/commit/d2c56315e2
2023-03-02 00:50:58 +00:00
Daniel Colson 62b3bcba5e [rubygems/rubygems] Auto-heal on corrupted lockfile with missing deps
Following up on https://github.com/rubygems/rubygems/pull/6355, which
turned a crash into a nicer error message, this commit auto-heals the
corrupt lockfile instead.

In this particular case (a corrupt Gemfile.lock with missing
dependencies) the LazySpecification will not have accurate dependency
information, we have to materialize the SpecSet to determine there are
missing dependencies. We've already got a way to handle this, via
`SpecSet#incomplete_specs`, but it wasn't quite working for this case
because we'd get to `@incomplete_specs += lookup[name]` and
`lookup[name]` would be empty for the dependency.

With this commit we catch it a bit earlier, marking the parent spec
containing the missing dependency as incomplete.

https://github.com/rubygems/rubygems/commit/486ecb8f20
2023-03-01 02:50:40 +00:00
Hiroshi SHIBATA f6620037ba Merge RubyGems-3.4.0 and Bundler-2.4.0 2022-12-24 16:57:07 +09:00
Hiroshi SHIBATA 0a9d51ee9d Migrate our resolver engine to PubGrub
https://github.com/rubygems/rubygems/pull/5960

  Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2022-11-12 07:40:31 +09:00
David Rodríguez a4860e043e [rubygems/rubygems] Remove unnecessary spec sorting
Specs in a SpecSet with the same name are only sorted by platform
priority when they are read. No need to sort everything eagerly.

https://github.com/rubygems/rubygems/commit/aeafff52df
2022-09-12 22:13:28 +09:00
Hiroshi SHIBATA 3eca1e438d Merge 16c3535413 2022-09-05 14:37:12 +09:00
Hiroshi SHIBATA f69244cee8 Merge rubygems/bundler HEAD
Pick from 6b3a5a9ab0
2022-08-23 10:45:57 +09:00
David Rodríguez 466a760e18 [rubygems/rubygems] Fix yanked gems being unintentionally update when other gems are unlocked
This is a regression from a change intended to raise errors when user
puts a gem under an incorrect source in the Gemfile by mistake. To fix
the issue, we revert the change that caused it and implement it in a
different way that restores the resolver independency from real
specifications. Now it deals only with names and versions and does not
try to materialize anything into real specifications before resolving.

https://github.com/rubygems/rubygems/commit/d2bf1b86eb
2022-08-06 15:41:46 +09:00
David Rodríguez 5a9db23734 [rubygems/rubygems] Automatically remove "ruby" from lockfile if incomplete
https://github.com/rubygems/rubygems/commit/69d0b4e10b
2022-08-05 16:36:42 +09:00
David Rodríguez f70b26af47 [rubygems/rubygems] Array is already uniq, no need to deduplicate it
https://github.com/rubygems/rubygems/commit/3212ae14b7
2022-08-02 21:57:52 +09:00
David Rodríguez f4f681463f [rubygems/rubygems] Don't discard candidates matching ruby metadata
Do dependency filtering and materialization in one step. Before,
dependency filtering would not consider ruby metadata so it would
discard variants that end up not being materializable in the end.

https://github.com/rubygems/rubygems/commit/0c0d40d417

Co-authored-by: Ian Ker-Seymer <ian.kerseymer@shopify.com>
2022-08-02 16:10:18 +09:00
David Rodríguez ed9bbfd759 [rubygems/rubygems] Fix incorrect force_ruby_platform propagation
It was just working by chance.

(cherry picked from commit https://github.com/rubygems/rubygems/commit/16b2d6bfe893)

https://github.com/rubygems/rubygems/commit/8f922d980f
2022-08-02 16:10:14 +09:00
David Rodríguez 7cc5a657ee [rubygems/rubygems] Remove unnecessary special case for Bundler
https://github.com/rubygems/rubygems/commit/2777e79b8e
2022-08-02 16:10:13 +09:00
David Rodríguez 6ec8f684aa [rubygems/rubygems] Move some logic to `LazySpecification#__materialize__`
https://github.com/rubygems/rubygems/commit/5e100df7c9
2022-08-02 16:10:13 +09:00
Hiroshi SHIBATA 9e6d07f346 Merge rubygems/bundler HEAD
Merge from 2af2520b4a
2022-07-26 14:38:17 +09:00
Hiroshi SHIBATA 437a5ae9d6 Merge RubyGems and Bundler master 2022-07-13 14:11:55 +09:00
Josh Nichols aeab405878 [rubygems/rubygems] Improve performance of Bundler::SpecSet#for by using hash lookup of handled deps
I was looking at (yet another) flamegraph in speedscope, and used the
'left hand heavy' and was shocked to realize that 0.5s of the 1.7s
is spent in DepProxy#name. This method _only_ delegates the name to an
underlying spec, so it's not complex at all.

It seems to be of how often this line ends up calling it:

     next if handled.any?{|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"

The `handled` array is built up as dependencies are handled, so this get
slower as more dependencies are installed.

This change changes how `handled` is track. Instead of just an array, I've
tried using a Hash, with the key being a dep's name, and the value being
a list of deps with that name. This means it's constant time to find
the dependencies with the same name.

I saw a drop from 1.7s to 1.0s against master, and from 0.95s to 0.24s
when used with https://github.com/rubygems/rubygems/pull/5533

https://github.com/rubygems/rubygems/commit/844dac30d4
2022-06-20 02:34:41 +09:00
Hiroshi SHIBATA aeea88174d
Merge RubyGems and Bundler HEAD
125415593e
2022-05-20 17:32:19 +09:00
David Rodríguez 641c3830df [rubygems/rubygems] Use `Array#concat` in `SpecSet#for` to save memory
On `rails/rails` repository Gemfile, running the following script

```
# script.rb
require "bundler/setup"
```

#### Before

```
➜  rails git:(main) ✗ BUNDLER_VERSION=2.4.0.dev ruby-memory-profiler --pretty --no-detailed --allocated-strings=0 --retained-strings=0 script.rb
Total allocated: 24.37 MB (207937 objects)
Total retained:  2.98 MB (34152 objects)
```

#### After

```
➜  rails git:(main) ✗ BUNDLER_VERSION=2.4.0.dev ruby-memory-profiler --pretty --no-detailed --allocated-strings=0 --retained-strings=0 script.rb
Total allocated: 22.27 MB (206856 objects)
Total retained:  2.98 MB (34152 objects)
```

https://github.com/rubygems/rubygems/commit/2ea2523afd

Co-authored-by: Josh Nichols <josh.nichols@gusto.com>
2022-05-16 17:24:14 +09:00
David Rodríguez c380aac19d [rubygems/rubygems] Improve `bundler/setup` performance again
On a different patch, it was noticed Ngam Pham that we are calling
`LazySpecification#hash` many times, and simply memoizing that led to a
very considerable performance improvement in his app.

I noticed though that we shouldn't be calling `LazySpecification#hash`
that many times, and I located the culprit at `SpecSet#for` where we
were deduplicating the partial aggregated result on every iteration. It
is enough to do it just once at the end.

This leads on a 12% speedup on Rails repository Gemfile vs the previous
8% I was getting from memoizing `LazySpecification#hash`. Also, after
this patch memoizing `LazySpecification#hash` has no effect in
performance anymore.

https://github.com/rubygems/rubygems/commit/68d00a9edd

Co-authored-by: Ngan Pham <ngan@users.noreply.github.com>
2022-05-16 17:24:14 +09:00
Frederik Dudzik f45af5f0a4
Support gemification of tsort
Co-authored-by: Frederik Dudzik <frederik.dudzik@shopify.com>
Co-authored-by: Jacques Chester <jacques.chester@shopify.com>
2021-10-29 17:32:52 +09:00
David Rodríguez f6803d2411 [rubygems/rubygems] Fix `bundle check` showing duplicated gems
If the lockfile contains multiple platforms, `bundle check` would show
duplicated missing gems.

https://github.com/rubygems/rubygems/commit/6ac5931783
2021-08-31 19:06:14 +09:00
David Rodríguez 23c27d2c7b [rubygems/rubygems] Don't sort materialized specs when not necessary
This should fix a weird flaky spec failure, given that the code
producing the error will be no longer run.

https://github.com/rubygems/rubygems/commit/a171965409
2021-08-31 19:06:14 +09:00
David Rodríguez d37c2441cc [rubygems/rubygems] We can now avoid source materialization work
No need to fill up missing names from sources anymore since they should
now be properly set up correctly from the beginning.

https://github.com/rubygems/rubygems/commit/706fd28681
2021-08-31 19:06:14 +09:00