Issue #19845 has been reported by ioquatix (Samuel Williams).
----------------------------------------
Bug #19845: `Fiber[key] = value` fails if key is not interned.
https://bugs.ruby-lang.org/issues/19845
* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
See https://github.com/ruby/ruby/pull/8273 for the fix.
--
https://bugs.ruby-lang.org/
Issue #19896 has been reported by HParker (Adam Hess).
----------------------------------------
Bug #19896: Ruby method refinement memory leak
https://bugs.ruby-lang.org/issues/19896
* Author: HParker (Adam Hess)
* Status: Open
* Priority: Normal
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
GitHub pull request: https://github.com/ruby/ruby/pull/8487
When method redefinitions happen, sometimes the final definition does not get cleaned up,
Reproducable with the same script from: https://bugs.ruby-lang.org/issues/19894
``` ruby
10.times do
20_000.times do
$c = Class.new do
def foo; end
end
$m = Module.new do
refine $c do
def foo; end
end
end
Class.new do
using $m
def initialize
o = $c.new
o.method(:foo).unbind
end
end.new
end
puts `ps -o rss= -p #{$$}`
end
```
before:
```
19792
20944
22224
23504
24784
26064
27344
28624
29776
31056
```
after:
```
18560
18560
18560
18560
18560
18560
18560
18560
18560
18560
```
--
https://bugs.ruby-lang.org/
Issue #19288 has been reported by maciej.mensfeld (Maciej Mensfeld).
----------------------------------------
Bug #19288: Ractor JSON parsing significantly slower than linear parsing
https://bugs.ruby-lang.org/issues/19288
* Author: maciej.mensfeld (Maciej Mensfeld)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
a simple benchmark:
```ruby
require 'json'
require 'benchmark'
CONCURRENT = 5
RACTORS = true
ELEMENTS = 100_000
data = CONCURRENT.times.map do
ELEMENTS.times.map do
{
rand => rand,
rand => rand,
rand => rand,
rand => rand
}.to_json
end
end
ractors = CONCURRENT.times.map do
Ractor.new do
Ractor.receive.each { JSON.parse(_1) }
end
end
result = Benchmark.measure do
if RACTORS
CONCURRENT.times do |i|
ractors[i].send(data[i], move: false)
end
ractors.each(&:take)
else
# Linear without any threads
data.each do |piece|
piece.each { JSON.parse(_1) }
end
end
end
puts result
```
Gives following results on my 8 core machine:
```shell
# without ractors:
2.731748 0.003993 2.735741 ( 2.736349)
# with ractors
12.580452 5.089802 17.670254 ( 5.209755)
```
I would expect Ractors not to be two times slower on the CPU intense work.
--
https://bugs.ruby-lang.org/
Issue #19767 has been reported by rubyFeedback (robert heiler).
----------------------------------------
Bug #19767: [Not really a bug, but more a not ideal notification] "historical binary regexp match" when using the "n" modifier in a ruby regex
https://bugs.ruby-lang.org/issues/19767
* Author: rubyFeedback (robert heiler)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
To get my knowledge about ruby regexes up-to-date I have been
going through this tutorial/book here at:
https://learnbyexample.github.io/Ruby_Regexp/unicode.html
One example they provide is this, with some odd characters:
'fox:αλεπού'.scan(/\w+/n)
This will match the found word ("fox"), but it also reports
the following warning:
warning: historical binary regexp match /.../n against UTF-8 string
Now: this may be obvious to others, but to me personally I am not
sure what a "historical" binary regexp match actually is. I assume
it may have meant that this was more used in the past, and may be
discouraged now? Or is something else meant? What does "historical"
mean in this context?
I may not be the only one who does not fully understand the term
historical. Most of ruby's warnings are fairly easy to understand,
but this one seems odd. Right now I do not know whether we can use
the "n" modifier in a regex - not that I really have a good use
case for it (I am using UTF-8 these days, so I don't seem to need
ASCII-8BIT anyway), but perhaps the warning could be changed a little.
I have no good alternative suggestion how it can be changed, largely
because I do not know what it actually means, e. g. what is "historical"
about it (but, even then, I'd actually recommend against using the
word "historical" because I don't understand what it means; deprecated
is easy to understand, historical does not tell me anything).
Perhaps it could be expressed somewhat differently and we could get
rid of the word "historical" there? Either way, it's a tiny issue so
I was not even sure whether to report it. But, from the point of view
of other warnings, I believe the term "historical" does not tell the
user enough about what the issue is here.
(irb):1: warning: historical binary regexp match /.../n against UTF-8 string
=> ["fox"]
--
https://bugs.ruby-lang.org/
Issue #19904 has been reported by tenderlovemaking (Aaron Patterson).
----------------------------------------
Feature #19904: Deprecate or warn on multiple regular expression encodings
https://bugs.ruby-lang.org/issues/19904
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* Priority: Normal
----------------------------------------
It seems like you can pass multiple encoding flags to regular expression literals, but I think this should be a warning or possibly syntax error.
For example:
```ruby
x = /foo/nu
p x.encoding
```
`n` says the RE should be ASCII-8BIT, and `u` says it should be UTF-8. The last flag wins, so in this case the regular expression gets UTF-8 encoding. However, I think it should be a warning or even a syntax error if you specify multiple encoding options on a regular expression. It seems like a mistake if programmers specify multiple.
Thanks!
--
https://bugs.ruby-lang.org/
Issue #19899 has been reported by jbeschi (jacopo beschi).
----------------------------------------
Misc #19899: Ruby3.3.-preview2: Behaviour changes of Socket.recv when the sever closes the connection
https://bugs.ruby-lang.org/issues/19899
* Author: jbeschi (jacopo beschi)
* Status: Open
* Priority: Normal
----------------------------------------
I noticed that `Socket#recv` now returns `nil` instead of `""` when the server closes the connection, is it expected? If yes, I suggest mentioning it to the [release page](https://www.ruby-lang.org/en/news/2023/09/14/ruby-3-3-0-preview2-rele….
Example:
``` ruby
# server.rb
require "socket"
port = 3030
server = TCPServer.new("", port)
while(conn = server.accept) #serves forever
conn.print "hello"
conn.close
end
# client.rb
require 'socket'
port = 3030
socket = TCPSocket.new("localhost", port)
2.times do
res = socket.recv(1012)
puts "received:"
p res
end
socket.close
```
```
jacopo-37s-mb 3.2.0 ~ ruby client.rb
received:
"hello"
received:
""
jacopo-37s-mb 3.2.0 ~ rbenv local 3.3.0-preview2
jacopo-37s-mb 3.3.0-preview2 ~ ruby client.rb
received:
"hello"
received:
nil
```
Thanks!
--
https://bugs.ruby-lang.org/
Issue #18515 has been updated by kyanagi (Kouhei Yanagita).
Let's set aside `#pred` for now to avoid going off track.
I have created a new pull request with a simpler implementation and closed the old one.
New PR: https://github.com/ruby/ruby/pull/8525
As benchmark results show, huge memory savings are achieved, especially for large `Range`.
Execution speed is also increased.
```
prelude: |
rf_1 = 0..1
rf_1k = 0..1000
rf_1m = 0..1000000
big = 2**1000
rb_1 = big..big+1
rb_1k = big..big+1000
rb_1m = big..big+1000000
benchmark:
"Fixnum 1": rf_1.reverse_each { _1 }
"Fixnum 1K": rf_1k.reverse_each { _1 }
"Fixnum 1M": rf_1m.reverse_each { _1 }
"Bignum 1": rb_1.reverse_each { _1 }
"Bignum 1K": rb_1k.reverse_each { _1 }
"Bignum 1M": rb_1m.reverse_each { _1 }
```
### Max resident set size (bytes)
| |master |PR |ratio|
|:----------|--------:|-------:|----:|
|Fixnum 1 | 13.910M| 14.877M|1.069|
|Fixnum 1K | 14.778M| 14.762M|0.998|
|Fixnum 1M | 28.770M| 14.025M|0.487|
|Bignum 1 | 14.729M| 14.189M|0.963|
|Bignum 1K | 14.074M| 13.582M|0.965|
|Bignum 1M | 224.723M| 15.254M|0.067|
### Iteration per second (i/s)
| |master |PR |ratio|
|:----------|------:|-------:|----:|
|Fixnum 1 | 6.653M| 14.511M|2.181|
|Fixnum 1K |27.866k| 45.527k|1.633|
|Fixnum 1M | 28.659| 45.667|1.593|
|Bignum 1 | 3.534M| 4.635M|1.311|
|Bignum 1K | 6.790k| 7.693k|1.132|
|Bignum 1M | 5.720| 7.532|1.316|
----------------------------------------
Feature #18515: Add Range#reverse_each implementation for performance
https://bugs.ruby-lang.org/issues/18515#change-104776
* Author: kyanagi (Kouhei Yanagita)
* Status: Open
* Priority: Normal
----------------------------------------
PR is https://github.com/ruby/ruby/pull/5489
Current `Range#reverse_each` uses `Enumerable#reverse_each` which is implemented with `#to_a`.
So we are virtually not able to use `reverse_each` for a very large or beginless range, even if few elements are iterated on actually.
```
(1..2**100).reverse_each { |x| p x; break if x.odd? }
(..5).reverse_each { |x| p x; break if x == 0 }
(1..2**32).reverse_each.lazy.select { |x| Prime.prime?(x) }.take(3).to_a
```
This patch, implements `Range#reverse_each` for Integer elements, enables these examples.
I think `#reverse_each` for an endless range should raise an exception.
This is a different issue, so I'll create another ticket later.
-> posted: https://bugs.ruby-lang.org/issues/18551
--
https://bugs.ruby-lang.org/