<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/array.c, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) a28c5151f567cada0d2f5c0c3ec4df7f97b80784: [Backport #19855]</title>
<updated>2023-08-29T12:06:04+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-08-29T12:06:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5d568e18980b2fdec4701b52f2d89833fa20c0a8'/>
<id>5d568e18980b2fdec4701b52f2d89833fa20c0a8</id>
<content type='text'>
	Fix Array#bsearch when block returns a non-integer numeric value

	---
	 array.c                 | 4 ++--
	 test/ruby/test_array.rb | 4 ++++
	 2 files changed, 6 insertions(+), 2 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Fix Array#bsearch when block returns a non-integer numeric value

	---
	 array.c                 | 4 ++--
	 test/ruby/test_array.rb | 4 ++++
	 2 files changed, 6 insertions(+), 2 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't allow re-embedding frozen arrays</title>
<updated>2022-12-23T16:21:14+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2022-12-23T14:33:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7891f9407184ca6b4636092555d2546e3830c2ff'/>
<id>7891f9407184ca6b4636092555d2546e3830c2ff</id>
<content type='text'>
Frozen arrays should not move from heap allocated to embedded because
frozen arrays could be shared roots for other (shared) arrays. If the
frozen array moves from heap allocated to embedded it would cause issues
since the shared array would no longer know where to set the pointer
in the shared root.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Frozen arrays should not move from heap allocated to embedded because
frozen arrays could be shared roots for other (shared) arrays. If the
frozen array moves from heap allocated to embedded it would cause issues
since the shared array would no longer know where to set the pointer
in the shared root.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix typo in array.c</title>
<updated>2022-12-22T18:16:55+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2022-12-22T18:16:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4f73de67edc18207148fa311eff8f463ac873981'/>
<id>4f73de67edc18207148fa311eff8f463ac873981</id>
<content type='text'>
We should be using the size of RArray and not RString for arrays.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We should be using the size of RArray and not RString for arrays.
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Correct Array#compact! description</title>
<updated>2022-12-11T17:24:01+00:00</updated>
<author>
<name>Jonathan Lim</name>
<email>snowblink@gmail.com</email>
</author>
<published>2022-12-11T17:24:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e1ca089b5dddd30c4ac8de9c7ec9e52948768117'/>
<id>e1ca089b5dddd30c4ac8de9c7ec9e52948768117</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Introduce BOP_CMP for optimized comparison</title>
<updated>2022-12-06T20:37:23+00:00</updated>
<author>
<name>Daniel Colson</name>
<email>danieljamescolson@gmail.com</email>
</author>
<published>2022-11-23T02:16:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e69b91fae4602b69c5ef45fcf82932adde8b31d8'/>
<id>e69b91fae4602b69c5ef45fcf82932adde8b31d8</id>
<content type='text'>
Prior to this commit the `OPTIMIZED_CMP` macro relied on a method lookup
to determine whether `&lt;=&gt;` was overridden. The result of the lookup was
cached, but only for the duration of the specific method that
initialized the cmp_opt_data cache structure.

With this method lookup, `[x,y].max` is slower than doing `x &gt; y ?
x : y` even though there's an optimized instruction for "new array max".
(John noticed somebody a proposed micro-optimization based on this fact
in https://github.com/mastodon/mastodon/pull/19903.)

```rb
a, b = 1, 2
Benchmark.ips do |bm|
  bm.report('conditional') { a &gt; b ? a : b }
  bm.report('method') { [a, b].max }
  bm.compare!
end
```

Before:

```
Comparison:
         conditional: 22603733.2 i/s
              method: 19820412.7 i/s - 1.14x  (± 0.00) slower
```

This commit replaces the method lookup with a new CMP basic op, which
gives the examples above equivalent performance.

After:

```
Comparison:
              method: 24022466.5 i/s
         conditional: 23851094.2 i/s - same-ish: difference falls within
error
```

Relevant benchmarks show an improvement to Array#max and Array#min when
not using the optimized newarray_max instruction as well. They are
noticeably faster for small arrays with the relevant types, and the same
or maybe a touch faster on larger arrays.

```
$ make benchmark COMPARE_RUBY=&lt;master@5958c305&gt; ITEM=array_min
$ make benchmark COMPARE_RUBY=&lt;master@5958c305&gt; ITEM=array_max
```

The benchmarks added in this commit also look generally improved.

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Prior to this commit the `OPTIMIZED_CMP` macro relied on a method lookup
to determine whether `&lt;=&gt;` was overridden. The result of the lookup was
cached, but only for the duration of the specific method that
initialized the cmp_opt_data cache structure.

With this method lookup, `[x,y].max` is slower than doing `x &gt; y ?
x : y` even though there's an optimized instruction for "new array max".
(John noticed somebody a proposed micro-optimization based on this fact
in https://github.com/mastodon/mastodon/pull/19903.)

```rb
a, b = 1, 2
Benchmark.ips do |bm|
  bm.report('conditional') { a &gt; b ? a : b }
  bm.report('method') { [a, b].max }
  bm.compare!
end
```

Before:

```
Comparison:
         conditional: 22603733.2 i/s
              method: 19820412.7 i/s - 1.14x  (± 0.00) slower
```

This commit replaces the method lookup with a new CMP basic op, which
gives the examples above equivalent performance.

After:

```
Comparison:
              method: 24022466.5 i/s
         conditional: 23851094.2 i/s - same-ish: difference falls within
error
```

Relevant benchmarks show an improvement to Array#max and Array#min when
not using the optimized newarray_max instruction as well. They are
noticeably faster for small arrays with the relevant types, and the same
or maybe a touch faster on larger arrays.

```
$ make benchmark COMPARE_RUBY=&lt;master@5958c305&gt; ITEM=array_min
$ make benchmark COMPARE_RUBY=&lt;master@5958c305&gt; ITEM=array_max
```

The benchmarks added in this commit also look generally improved.

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix typos (#6775)</title>
<updated>2022-11-21T05:07:18+00:00</updated>
<author>
<name>Yudai Takada</name>
<email>13041216+ydah@users.noreply.github.com</email>
</author>
<published>2022-11-21T05:07:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=29e6d97517bbd4dcc540464c8473172232f3e228'/>
<id>29e6d97517bbd4dcc540464c8473172232f3e228</id>
<content type='text'>
* s/Innteger/Integer/

* s/diretory/directory/

* s/Bufer/Buffer/

* s/defalt/default/

* s/covearge/coverage/</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* s/Innteger/Integer/

* s/diretory/directory/

* s/Bufer/Buffer/

* s/defalt/default/

* s/covearge/coverage/</pre>
</div>
</content>
</entry>
<entry>
<title>Using UNDEF_P macro</title>
<updated>2022-11-16T09:58:33+00:00</updated>
<author>
<name>S-H-GAMELINKS</name>
<email>gamelinks007@gmail.com</email>
</author>
<published>2022-11-15T04:24:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6'/>
<id>1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Set array capacity/shared immediately after alloc</title>
<updated>2022-11-14T20:40:47+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2022-11-14T20:40:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9a6c3355c5c9541b9afb94d4ee770a7584c7ac15'/>
<id>9a6c3355c5c9541b9afb94d4ee770a7584c7ac15</id>
<content type='text'>
If auto-compaction is enabled, then we have to set the capacity/shared
immediately after allocating a heap array. If compaction runs before
capacity/shared is set then it could cause the array to be re-embedded,
which can cause crashes.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If auto-compaction is enabled, then we have to set the capacity/shared
immediately after allocating a heap array. If compaction runs before
capacity/shared is set then it could cause the array to be re-embedded,
which can cause crashes.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use `roomof` macro for rounding up divisions</title>
<updated>2022-10-14T10:23:25+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-10-04T09:10:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5ccb625fbbd1e774636a9fdbe0bf1c3d38e085d5'/>
<id>5ccb625fbbd1e774636a9fdbe0bf1c3d38e085d5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add Data class implementation: Simple immutable value object</title>
<updated>2022-09-30T09:23:19+00:00</updated>
<author>
<name>Victor Shepelev</name>
<email>zverok.offline@gmail.com</email>
</author>
<published>2022-09-30T09:23:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ad651925e365ca18645f05b5e9b2eca9cd5721bc'/>
<id>ad651925e365ca18645f05b5e9b2eca9cd5721bc</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
