[#115244] [Ruby master Feature#19987] add sample method to Range — "horv77@... (Andras Horvath) via ruby-core" <ruby-core@...>
Issue #19987 has been reported by horv77@protonmail.com (Andras Horvath).
6 messages
2023/11/05
[#115247] [Ruby master Feature#19988] AI for inner code behavior analysis at runtime — "horv77@... (Andras Horvath) via ruby-core" <ruby-core@...>
Issue #19988 has been reported by horv77@protonmail.com (Andras Horvath).
3 messages
2023/11/05
[#115404] Ruby 3.2.2 - rbconfig.rb's MAKEFILE_CONFIG — Jay Mav via ruby-core <ruby-core@...>
Hello Ruby Dev Team,
4 messages
2023/11/17
[ruby-core:115317] [Ruby master Feature#19993] Optionally Free all memory at exit
From:
"mame (Yusuke Endoh) via ruby-core" <ruby-core@...>
Date:
2023-11-09 03:16:50 UTC
List:
ruby-core #115317
Issue #19993 has been updated by mame (Yusuke Endoh).
I wonder what kind of micro-benchmark would have the largest overhead.
Loading 100,000 empty files
```
$ time ./miniruby -e 'n = "a"; 100000.times { require "./empty-files/#{ n }"; n.succ! }'
real 0m2.706s
user 0m1.112s
sys 0m1.567s
$ time ./miniruby --free-on-shutdown -e 'n = "a"; 100000.times { require "./empty-files/#{ n }"; n.succ! }'
./miniruby: warning: Free on shutdown is experimental and may be unstable
real 0m2.747s
user 0m1.318s
sys 0m1.402s
```
Defining 1,000,000 global variables
```
$ time ./miniruby -e 's = []; n = "a"; 1000000.times { s << "$#{ n }=1"; n.succ! }; eval(s.join(";"))'
real 0m1.512s
user 0m1.251s
sys 0m0.260s
$ time ./miniruby --free-on-shutdown -e 's = []; n = "a"; 1000000.times { s << "$#{ n }=1"; n.succ! }; eval(s.join(";"))'
./miniruby: warning: Free on shutdown is experimental and may be unstable
real 0m1.628s
user 0m1.352s
sys 0m0.276s
```
I don't even know if the real-world cases could be ever a problem, but I agree it's safe to default off.
----------------------------------------
Feature #19993: Optionally Free all memory at exit
https://bugs.ruby-lang.org/issues/19993#change-105236
* Author: HParker (Adam Hess)
* Status: Open
* Priority: Normal
----------------------------------------
Add a runtime option allowing Ruby to optionally free all memory at shutdown.
# why
Today, memory sanitizers are difficult to use with Ruby, since not all memory is freed at shutdown. it is difficult to detect memory leaks or errors in Ruby or in Ruby C extensions when these tools are not available.
While implementing this feature, we were able to identify and fix a number of memory leaks and errors.
https://github.com/ruby/ruby/pull/8556
https://github.com/ruby/ruby/pull/8512
https://github.com/ruby/ruby/pull/8503
https://github.com/ruby/ruby/pull/8487
https://github.com/ruby/ruby/pull/8452
https://github.com/ruby/ruby/pull/8501
https://github.com/ruby/ruby/pull/8481
https://github.com/ruby/ruby/pull/8555
This shows that having access to tools like this can make finding and fixing memory bugs easier.
# current progress
Today we can allow ruby developers to enable freeing memory at shutdown via the `free-at-shutdown` runtime option.
PR: https://github.com/ruby/ruby/pull/8868
running,
without `--free-on-shutdown`:
```
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -- ./miniruby basictest/test.rb
```
```
==573270== LEAK SUMMARY:
==573270== definitely lost: 658,324 bytes in 5,387 blocks
==573270== indirectly lost: 955,708 bytes in 11,957 blocks
==573270== possibly lost: 2,071,096 bytes in 12 blocks
==573270== still reachable: 161,881 bytes in 275 blocks
==573270== suppressed: 0 bytes in 0 blocks
==573270== Reachable blocks (those to which a pointer was found) are not shown.
==573270== To see them, rerun with: --leak-check=full --show-leak-kinds=all
```
with `--free-on-shutdown`
```
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -- ./miniruby --free-on-shutdown basictest/test.rb
```
```
==573306== HEAP SUMMARY:
==573306== in use at exit: 0 bytes in 0 blocks
==573306== total heap usage: 43,643 allocs, 43,643 frees, 29,222,534 bytes allocated
==573306==
==573306== All heap blocks were freed -- no leaks are possible
```
# future plans
* Continue improving memory safety
* add `valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -- ./miniruby --free-on-shutdown basictest/test.rb` to CI
* Allow C extensions to do a "optional destruct for memory safety" so they can leverage the same memory sanitizer tools.
--
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/