Recently we added some keys to GC.stat in order to measure the GC
performance of Ractor local GC and the associated global GC.
This commit refactors some of those terms: "global" was used in two
places with different meanings which could get confusing.
When it was passed to GC.stat as scope: :global it meant "Give me
aggregate stats for all the GCs running in this process".
Whereas inside the output of GC.stat, global referred to the number of
"global" GCs that are run. That is: stop-the-world GCs that run on
every ractor heap in the process.
Also the global_gc_count that GC.stat reports for a Ractor ignored
global GCs that other Ractors started, even though they swept its heap.
In this commit we fix this confusing behaviour, and make the GC.stat
output more consistent.
We've replaced the scope: parameter to GC.stat with the boolean
process: keyword arg. The default is process: false which means
GC.stat will return stats for the Ractor that executes the code (the
main Ractor if no other Ractors have been created). process: true will
return aggregate stats over all the Ractors in the process (including
dead ones).
Inside GC.stat(process: false), count and global_gc_count now
include every global GC that has swept that Ractor's heap. So Ractor
local gc count == count - global_gc_count.
heap_marked_slots now counts only the marked objects in that Ractor's
own heap. Before, the Ractor that started a global GC counted the
marked objects of every heap, and the other Ractors reported 0.
We also provide a new key global_gc_invocation_count that is the
number of global GCs that have been triggered by the Ractor in question.
We've also moved some keys related to the global page pool out of the
default GC.stat output and into GC.stat(process: true), because they
are process-wide and not Ractor specific.
* Refactor dir.rb sample
The original (1998) sample with a for-loop and use of case/when isn't what we'd write nowadays
* [DOC] Update sample/dir.rb [ci skip]
Do not leave a `Dir` opened.
* [DOC] Update sample/dir.rb [ci skip]
Fix ArgumentError.
---------
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
The `lambda_body` grammar rule has a `"}"`, which is throwing off the `exyacc.rb` regular expressions. This changes the regular expression to account for `"}"` as well, which makes the output of `ruby sample/exyacc.rb < parse.y` change by the following diff:
```diff
632,634d631
< ", &@3);
< $$ = $2;
< }
```
Which makes it closer to a valid EBNF.
I noticed that some files in rubygems were executable, and I could think
of no reason why they should be.
In general, I think ruby files should never have the executable bit set
unless they include a shebang, so I run the following command over the
whole repo:
```bash
find . -name '*.rb' -type f -executable -exec bash -c 'grep -L "^#!" $1 || chmod -x $1' _ {} \;
```
Previously, trying to use this would result in:
undefined method `uri' for #<DRb::HTTP0::ServerSide:0x00000aec9f1637f8> (NoMethodError)
Also, use a relative require to load sample/drb/http0.rb.
Fixes [Bug #13431]