ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:115978] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects
@ 2023-12-30 16:39 jeremyevans0 (Jeremy Evans) via ruby-core
  2023-12-30 17:57 ` [ruby-core:115979] " luke-gru (Luke Gruber) via ruby-core
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2023-12-30 16:39 UTC (permalink / raw
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #20104 has been reported by jeremyevans0 (Jeremy Evans).

----------------------------------------
Bug #20104: Regexp#match returns nil but allocates T_MATCH objects
https://bugs.ruby-lang.org/issues/20104

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.4.0dev (2023-12-30T03:14:38Z master 8e32c01742) [x86_64-openbsd7.4]
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED
----------------------------------------
Between Ruby 3.2 and 3.3, behavior changed so that Regexp#match will allocate a T_MATCH object even when there is no match.  Example code:

```ruby
h = {}
GC.start
GC.disable
ObjectSpace.count_objects(h)
matches = h[:T_MATCH] || 0
md = /\A[A-Z]+\Z/.match('1')
ObjectSpace.count_objects(h)
new_matches = h[:T_MATCH] || 0
puts "/\\A[A-Z]+\\Z/.match('1') => #{md.inspect} generates #{new_matches - matches} T_MATCH objects"
```

Result with Ruby 1.9-3.2:

```
/\A[A-Z]+\Z/.match('1') => nil generates 0 T_MATCH objects
```

Results with Ruby 3.3.0 and current master branch:

```
/\A[A-Z]+\Z/.match('1') => nil generates 1 T_MATCH objects
```

This results in a measurable performance decrease for both Sinatra and Roda web applications, as reported at: https://old.reddit.com/r/ruby/comments/18sxtv9/ruby_330_performance_ups_and_downs/

Thanks to GitHub users kiskoza and tagliala for producing a minimal example showing this issue: https://github.com/caxlsx/caxlsx/issues/336



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:115979] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects
  2023-12-30 16:39 [ruby-core:115978] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects jeremyevans0 (Jeremy Evans) via ruby-core
@ 2023-12-30 17:57 ` luke-gru (Luke Gruber) via ruby-core
  2024-01-04 22:45 ` [ruby-core:116021] " luke-gru (Luke Gruber) via ruby-core
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: luke-gru (Luke Gruber) via ruby-core @ 2023-12-30 17:57 UTC (permalink / raw
  To: ruby-core; +Cc: luke-gru (Luke Gruber)

Issue #20104 has been updated by luke-gru (Luke Gruber).


So I looked into this and it's this commit that introduces that behavior: 7193b404a1a56e50f8046d0382914907020c1559

----------------------------------------
Bug #20104: Regexp#match returns nil but allocates T_MATCH objects
https://bugs.ruby-lang.org/issues/20104#change-105942

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.4.0dev (2023-12-30T03:14:38Z master 8e32c01742) [x86_64-openbsd7.4]
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED
----------------------------------------
Between Ruby 3.2 and 3.3, behavior changed so that Regexp#match will allocate a T_MATCH object even when there is no match.  Example code:

```ruby
h = {}
GC.start
GC.disable
ObjectSpace.count_objects(h)
matches = h[:T_MATCH] || 0
md = /\A[A-Z]+\Z/.match('1')
ObjectSpace.count_objects(h)
new_matches = h[:T_MATCH] || 0
puts "/\\A[A-Z]+\\Z/.match('1') => #{md.inspect} generates #{new_matches - matches} T_MATCH objects"
```

Result with Ruby 1.9-3.2:

```
/\A[A-Z]+\Z/.match('1') => nil generates 0 T_MATCH objects
```

Results with Ruby 3.3.0 and current master branch:

```
/\A[A-Z]+\Z/.match('1') => nil generates 1 T_MATCH objects
```

This results in a measurable performance decrease for both Sinatra and Roda web applications, as reported at: https://old.reddit.com/r/ruby/comments/18sxtv9/ruby_330_performance_ups_and_downs/

Thanks to GitHub users kiskoza and tagliala for producing a minimal example showing this issue: https://github.com/caxlsx/caxlsx/issues/336



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:116021] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects
  2023-12-30 16:39 [ruby-core:115978] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects jeremyevans0 (Jeremy Evans) via ruby-core
  2023-12-30 17:57 ` [ruby-core:115979] " luke-gru (Luke Gruber) via ruby-core
@ 2024-01-04 22:45 ` luke-gru (Luke Gruber) via ruby-core
  2024-01-04 23:43 ` [ruby-core:116022] " jeremyevans0 (Jeremy Evans) via ruby-core
  2024-02-01  0:07 ` [ruby-core:116529] " naruse (Yui NARUSE) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: luke-gru (Luke Gruber) via ruby-core @ 2024-01-04 22:45 UTC (permalink / raw
  To: ruby-core; +Cc: luke-gru (Luke Gruber)

Issue #20104 has been updated by luke-gru (Luke Gruber).


So my PR has been merged but I believe a backport is desirable for 3.3. I'm not sure who to ping for a backport request. Thanks!

----------------------------------------
Bug #20104: Regexp#match returns nil but allocates T_MATCH objects
https://bugs.ruby-lang.org/issues/20104#change-106011

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.4.0dev (2023-12-30T03:14:38Z master 8e32c01742) [x86_64-openbsd7.4]
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED
----------------------------------------
Between Ruby 3.2 and 3.3, behavior changed so that Regexp#match will allocate a T_MATCH object even when there is no match.  Example code:

```ruby
h = {}
GC.start
GC.disable
ObjectSpace.count_objects(h)
matches = h[:T_MATCH] || 0
md = /\A[A-Z]+\Z/.match('1')
ObjectSpace.count_objects(h)
new_matches = h[:T_MATCH] || 0
puts "/\\A[A-Z]+\\Z/.match('1') => #{md.inspect} generates #{new_matches - matches} T_MATCH objects"
```

Result with Ruby 1.9-3.2:

```
/\A[A-Z]+\Z/.match('1') => nil generates 0 T_MATCH objects
```

Results with Ruby 3.3.0 and current master branch:

```
/\A[A-Z]+\Z/.match('1') => nil generates 1 T_MATCH objects
```

This results in a measurable performance decrease for both Sinatra and Roda web applications, as reported at: https://old.reddit.com/r/ruby/comments/18sxtv9/ruby_330_performance_ups_and_downs/

Thanks to GitHub users kiskoza and tagliala for producing a minimal example showing this issue: https://github.com/caxlsx/caxlsx/issues/336



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:116022] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects
  2023-12-30 16:39 [ruby-core:115978] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects jeremyevans0 (Jeremy Evans) via ruby-core
  2023-12-30 17:57 ` [ruby-core:115979] " luke-gru (Luke Gruber) via ruby-core
  2024-01-04 22:45 ` [ruby-core:116021] " luke-gru (Luke Gruber) via ruby-core
@ 2024-01-04 23:43 ` jeremyevans0 (Jeremy Evans) via ruby-core
  2024-02-01  0:07 ` [ruby-core:116529] " naruse (Yui NARUSE) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2024-01-04 23:43 UTC (permalink / raw
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #20104 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

This is already marked for backport to 3.3, it just needs to be closed.

----------------------------------------
Bug #20104: Regexp#match returns nil but allocates T_MATCH objects
https://bugs.ruby-lang.org/issues/20104#change-106012

* Author: jeremyevans0 (Jeremy Evans)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.4.0dev (2023-12-30T03:14:38Z master 8e32c01742) [x86_64-openbsd7.4]
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED
----------------------------------------
Between Ruby 3.2 and 3.3, behavior changed so that Regexp#match will allocate a T_MATCH object even when there is no match.  Example code:

```ruby
h = {}
GC.start
GC.disable
ObjectSpace.count_objects(h)
matches = h[:T_MATCH] || 0
md = /\A[A-Z]+\Z/.match('1')
ObjectSpace.count_objects(h)
new_matches = h[:T_MATCH] || 0
puts "/\\A[A-Z]+\\Z/.match('1') => #{md.inspect} generates #{new_matches - matches} T_MATCH objects"
```

Result with Ruby 1.9-3.2:

```
/\A[A-Z]+\Z/.match('1') => nil generates 0 T_MATCH objects
```

Results with Ruby 3.3.0 and current master branch:

```
/\A[A-Z]+\Z/.match('1') => nil generates 1 T_MATCH objects
```

This results in a measurable performance decrease for both Sinatra and Roda web applications, as reported at: https://old.reddit.com/r/ruby/comments/18sxtv9/ruby_330_performance_ups_and_downs/

Thanks to GitHub users kiskoza and tagliala for producing a minimal example showing this issue: https://github.com/caxlsx/caxlsx/issues/336



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:116529] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects
  2023-12-30 16:39 [ruby-core:115978] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects jeremyevans0 (Jeremy Evans) via ruby-core
                   ` (2 preceding siblings ...)
  2024-01-04 23:43 ` [ruby-core:116022] " jeremyevans0 (Jeremy Evans) via ruby-core
@ 2024-02-01  0:07 ` naruse (Yui NARUSE) via ruby-core
  3 siblings, 0 replies; 5+ messages in thread
From: naruse (Yui NARUSE) via ruby-core @ 2024-02-01  0:07 UTC (permalink / raw
  To: ruby-core; +Cc: naruse (Yui NARUSE)

Issue #20104 has been updated by naruse (Yui NARUSE).

Backport changed from 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: REQUIRED to 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONE

ruby_3_3 f585171a6b1d6c20b3c162fd59dc874510ed2a49 merged revision(s) e12d4c654e3cb7a4473014610bc3bae41aaf811e.

----------------------------------------
Bug #20104: Regexp#match returns nil but allocates T_MATCH objects
https://bugs.ruby-lang.org/issues/20104#change-106547

* Author: jeremyevans0 (Jeremy Evans)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.4.0dev (2023-12-30T03:14:38Z master 8e32c01742) [x86_64-openbsd7.4]
* Backport: 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONE
----------------------------------------
Between Ruby 3.2 and 3.3, behavior changed so that Regexp#match will allocate a T_MATCH object even when there is no match.  Example code:

```ruby
h = {}
GC.start
GC.disable
ObjectSpace.count_objects(h)
matches = h[:T_MATCH] || 0
md = /\A[A-Z]+\Z/.match('1')
ObjectSpace.count_objects(h)
new_matches = h[:T_MATCH] || 0
puts "/\\A[A-Z]+\\Z/.match('1') => #{md.inspect} generates #{new_matches - matches} T_MATCH objects"
```

Result with Ruby 1.9-3.2:

```
/\A[A-Z]+\Z/.match('1') => nil generates 0 T_MATCH objects
```

Results with Ruby 3.3.0 and current master branch:

```
/\A[A-Z]+\Z/.match('1') => nil generates 1 T_MATCH objects
```

This results in a measurable performance decrease for both Sinatra and Roda web applications, as reported at: https://old.reddit.com/r/ruby/comments/18sxtv9/ruby_330_performance_ups_and_downs/

Thanks to GitHub users kiskoza and tagliala for producing a minimal example showing this issue: https://github.com/caxlsx/caxlsx/issues/336



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-01  0:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-30 16:39 [ruby-core:115978] [Ruby master Bug#20104] Regexp#match returns nil but allocates T_MATCH objects jeremyevans0 (Jeremy Evans) via ruby-core
2023-12-30 17:57 ` [ruby-core:115979] " luke-gru (Luke Gruber) via ruby-core
2024-01-04 22:45 ` [ruby-core:116021] " luke-gru (Luke Gruber) via ruby-core
2024-01-04 23:43 ` [ruby-core:116022] " jeremyevans0 (Jeremy Evans) via ruby-core
2024-02-01  0:07 ` [ruby-core:116529] " naruse (Yui NARUSE) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).