Age | Commit message (Collapse) | Author |
|
Set has been an autoloaded standard library since Ruby 3.2.
The standard library Set is less efficient than it could be, as it
uses Hash for storage, which stores unnecessary values for each key.
Implementation details:
* Core Set uses a modified version of `st_table`, named `set_table`.
than `s/st_/set_/`, the main difference is that the stored records
do not have values, making them 1/3 smaller. `st_table_entry` stores
`hash`, `key`, and `record` (value), while `set_table_entry` only
stores `hash` and `key`. This results in large sets using ~33% less
memory compared to stdlib Set. For small sets, core Set uses 12% more
memory (160 byte object slot and 64 malloc bytes, while stdlib set
uses 40 for Set and 160 for Hash). More memory is used because
the set_table is embedded and 72 bytes in the object slot are
currently wasted. Hopefully we can make this more efficient and have
it stored in an 80 byte object slot in the future.
* All methods are implemented as cfuncs, except the pretty_print
methods, which were moved to `lib/pp.rb` (which is where the
pretty_print methods for other core classes are defined). As is
typical for core classes, internal calls call C functions and
not Ruby methods. For example, to check if something is a Set,
`rb_obj_is_kind_of` is used, instead of calling `is_a?(Set)` on the
related object.
* Almost all methods use the same algorithm that the pure-Ruby
implementation used. The exception is when calling `Set#divide` with a
block with 2-arity. The pure-Ruby method used tsort to implement this.
I developed an algorithm that only allocates a single intermediate
hash and does not need tsort.
* The `flatten_merge` protected method is no longer necessary, so it
is not implemented (it could be).
* Similar to Hash/Array, subclasses of Set are no longer reflected in
`inspect` output.
* RDoc from stdlib Set was moved to core Set, with minor updates.
This includes a comprehensive benchmark suite for all public Set
methods. As you would expect, the native version is faster in the
vast majority of cases, and multiple times faster in many cases.
There are a few cases where it is significantly slower:
* Set.new with no arguments (~1.6x)
* Set#compare_by_identity for small sets (~1.3x)
* Set#clone for small sets (~1.5x)
* Set#dup for small sets (~1.7x)
These are slower as Set does not currently use the AR table
optimization that Hash does, so a new set_table is initialized for
each call. I'm not sure it's worth the complexity to have an AR
table-like optimization for small sets (for hashes it makes sense,
as small hashes are used everywhere in Ruby).
The rbs and repl_type_completor bundled gems will need updates to
support core Set. The pull request marks them as allowed failures.
This passes all set tests with no changes. The following specs
needed modification:
* Modifying frozen set error message (changed for the better)
* `Set#divide` when passed a 2-arity block no longer yields the same
object as both the first and second argument (this seems like an issue
with the previous implementation).
* Set-like objects that override `is_a?` such that `is_a?(Set)` return
`true` are no longer treated as Set instances.
* `Set.allocate.hash` is no longer the same as `nil.hash`
* `Set#join` no longer calls `Set#to_a` (it calls the underlying C
function).
* `Set#flatten_merge` protected method is not implemented.
Previously, `set.rb` added a `SortedSet` autoload, which loads
`set/sorted_set.rb`. This replaces the `Set` autoload in `prelude.rb`
with a `SortedSet` autoload, but I recommend removing it and
`set/sorted_set.rb`.
This moves `test/set/test_set.rb` to `test/ruby/test_set.rb`,
reflecting that switch to a core class. This does not move the spec
files, as I'm not sure how they should be handled.
Internally, this uses the st_* types and functions as much as
possible, and only adds set_* types and functions as needed.
The underlying set_table implementation is stored in st.c, but
there is no public C-API for it, nor is there one planned, in
order to keep the ability to change the internals going forward.
For internal uses of st_table with Qtrue values, those can
probably be replaced with set_table. To do that, include
internal/set_table.h. To handle symbol visibility (rb_ prefix),
internal/set_table.h uses the same macro approach that
include/ruby/st.h uses.
The Set class (rb_cSet) and all methods are defined in set.c.
There isn't currently a C-API for the Set class, though C-API
functions can be added as needed going forward.
Implements [Feature #21216]
Co-authored-by: Jean Boussier <[email protected]>
Co-authored-by: Oliver Nutter <[email protected]>
|
|
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13156
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13141
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13141
|
|
https://github.com/ruby/ruby/actions/runs/14585602800/job/40910453142
Notes:
Merged: https://github.com/ruby/ruby/pull/13149
|
|
https://github.com/rubygems/rubygems/commit/e4f70a3e4f
|
|
https://github.com/rubygems/rubygems/commit/40cf54d256
|
|
https://github.com/rubygems/rubygems/commit/38a0bdc123
|
|
https://github.com/rubygems/rubygems/commit/bf63859e1e
|
|
https://github.com/rubygems/rubygems/commit/0aae094c89
|
|
https://github.com/rubygems/rubygems/commit/e6aa8aabcd
|
|
- The command can either be run using:
1. `bundle doctor --ssl`
2. `bundle doctor ssl`
The later is most useful when you need to specify
custom ssl options (such as the verify mode or the
TLS version when running the diagnostic).
The implementation will follow in the next commits.
https://github.com/rubygems/rubygems/commit/993d12874c
|
|
- See explanation in previous commit https://github.com/rubygems/rubygems/commit/170890befb4c
https://github.com/rubygems/rubygems/commit/8f1b5a4479
|
|
0363..036F ; Alphabetic # Mn [13] COMBINING LATIN SMALL LETTER A..COMBINING LATIN SMALL LETTER X
Notes:
Merged: https://github.com/ruby/ruby/pull/13117
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13117
|
|
platforms
https://github.com/rubygems/rubygems/commit/c39d2f84fd
|
|
incompatible
https://github.com/rubygems/rubygems/commit/282e4a8593
|
|
In frozen mode, the previous logic would not set the platform locked
originally in the materialized specification, and that would trigger the
warning about insecure materialization incorrectly.
https://github.com/rubygems/rubygems/commit/a18001e10c
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11975
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/11975
|
|
Don't mention "Found changes from the lockfile" because that's not
really true in general.
https://github.com/rubygems/rubygems/commit/0181c278e8
|
|
If both a native and a generic version are locked, but the native
version is incompatible with the running Ruby, Bundler will still keep
the native version in the lockfile, since it could be potentially useful
when using other rubies.
However, when `bundle update` is run, this was not the case because the
locked native gems were not using the right source when materializing.
They were using the lockfile source instead of the Gemfile source, and
that meant they could not be found when materializing, because the
lockfile source always uses local mode so does not see them.
The effect of this was normally that they were incorrectly removed from
the lockfile and a strange "this spec has been possibly yanked" was
printed in verbose mode. However, in certain situations (i.e., when the
generic gem would bring extra dependencies), it could also make `bundle
update` crash.
The solution is, when adding this extra locked specs to the result after
resolving, maybe sure they inherit the source from the resolved specs,
so they can be found when materializing.
`bundle install` did not have the issue because it passes locked specs
to the resolver, and assigns the right source to them in
`Definition#converge_locked_specs`.
https://github.com/rubygems/rubygems/commit/91ce881fda
|
|
https://github.com/rubygems/rubygems/commit/458fa5dc4c
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13083
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12759
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12847
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12847
|
|
Originally, if a class was defined with the class keyword, the cref had a
const_added callback, and the superclass an inherited callback, const_added was
called first, and inherited second.
This was discussed in
https://bugs.ruby-lang.org/issues/21143
and an attempt at changing this order was made.
While both constant assignment and inheritance have happened before these
callbacks are invoked, it was deemed nice to have the same order as in
C = Class.new
This was mostly for alignment: In that last use case things happen at different
times and therefore the order of execution is kind of obvious, whereas when the
class keyword is involved, the order is opaque to the user and it is up to the
interpreter.
However, soon in
https://bugs.ruby-lang.org/issues/21193
Matz decided to play safe and keep the existing order.
This reverts commits:
de097fbe5f3df105bd2a26e72db06b0f5139bc1a
de48e47ddf78aba02fd9623bc7ce685540a10743
Notes:
Merged: https://github.com/ruby/ruby/pull/13085
|
|
https://github.com/rubygems/rubygems/commit/5b312fd040
|
|
https://github.com/rubygems/rubygems/commit/08b3c48f41
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13037
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13037
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/13037
|
|
Instead, skip the spec when run by ruby-core. Maybe the root cause can
be fixed at some point.
https://github.com/rubygems/rubygems/commit/09594ae5b8
|
|
mutable dependencies array
That restores support for compact index dummy implementations that only lists
versions, without checksums or dependencies.
This format is undocumented, so we may want to get rid of it in the
future. However, some of our tests rely on it, and some implementations
did use it (gems.mutant.dev at least). And the way the code was written
suggest that support was intentional.
So for now, we should restore it.
https://github.com/rubygems/rubygems/commit/0427d8c983
|
|
have changed
Since we will now add it back if the final resolution is compatible, we
can also get this kind of edge case (`bundle add`) working.
https://github.com/rubygems/rubygems/commit/cdc5ebec77
|
|
Instead, remove them anytime we find dependencies don't match the
lockfile for a platform, and then add them back after resolution if
they ended up being valid.
https://github.com/rubygems/rubygems/commit/220bd77887
|
|
spec/ruby/security/cve_2020_10663_spec.rb
Notes:
Merged: https://github.com/ruby/ruby/pull/13004
|
|
The following method call:
```ruby
a(*nil)
```
A method call such as `a(*nil)` previously allocated an array, because
it calls `nil.to_a`, but I have determined this array allocation is
unnecessary. The instructions in this case are:
```
0000 putself ( 1)[Li]
0001 putnil
0002 splatarray false
0004 opt_send_without_block <calldata!mid:a, argc:1, ARGS_SPLAT|FCALL>
0006 leave
```
The method call uses `ARGS_SPLAT` without `ARGS_SPLAT_MUT`, so the
returned array doesn't need to be mutable. I believe all cases where
`splatarray false` are used allow the returned object to be frozen,
since the `false` means to not duplicate the array. The optimization
in this case is to have `splatarray false` push a shared empty frozen
array, instead of calling `nil.to_a` to return a newly allocated array.
There is a slightly backwards incompatibility with this optimization,
in that `nil.to_a` is not called. However, I believe the new behavior
of `*nil` not calling `nil.to_a` is more consistent with how `**nil`
does not call `nil.to_hash`. Also, so much Ruby code would break if
`nil.to_a` returned something different from the empty hash, that it's
difficult to imagine anyone actually doing that in real code, though
we have a few tests/specs for that.
I think it would be bad for consistency if `*nil` called `nil.to_a`
in some cases and not others, so this changes other cases to not
call `nil.to_a`:
For `[*nil]`, this uses `splatarray true`, which now allocates a
new array for a `nil` argument without calling `nil.to_a`.
For `[1, *nil]`, this uses `concattoarray`, which now returns
the first array if the second array is `nil`.
This updates the allocation tests to check that the array allocations
are avoided where possible.
Implements [Feature #21047]
Notes:
Merged: https://github.com/ruby/ruby/pull/12597
|
|
[Feature #21109]
By always freezing when setting the global rb_rs variable, we can ensure
it is not modified and can be accessed from a ractor.
We're also making sure it's an instance of String and does not have any
instance variables.
Of course, if $/ is changed at runtime, it may cause surprising behavior
but doing so is deprecated already anyway.
Co-authored-by: Jean Boussier <[email protected]>
Notes:
Merged: https://github.com/ruby/ruby/pull/12975
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12984
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12984
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12983
|
|
https://github.com/rubygems/rubygems/commit/a0f7851451
|
|
This test confirms that a bug that existed in 2.6.3
was fixed by https://github.com/rubygems/rubygems/commit/b8e55087f026
https://github.com/rubygems/rubygems/commit/9e4ca5c5b2
|
|
This reverts commit eb91c664dc0b4d69db09ae913f2d7a5ef3490d74.
Notes:
Merged: https://github.com/ruby/ruby/pull/12968
|
|
missing
https://github.com/rubygems/rubygems/commit/054a0cd76c
Notes:
Merged: https://github.com/ruby/ruby/pull/12968
|
|
The deployment setting already does this implicitly.
https://github.com/rubygems/rubygems/commit/402b11fa39
Notes:
Merged: https://github.com/ruby/ruby/pull/12968
|
|
with checksums
https://github.com/rubygems/rubygems/commit/8e2c5748d9
Notes:
Merged: https://github.com/ruby/ruby/pull/12968
|