Skip to content

Commit 4357bb0

Browse files
committed
Best-effort compatibility of GC.stat
1 parent d596fd8 commit 4357bb0

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

doc/user/compatibility.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ Additionally, `FPE`, `ILL`, `KILL`, `SEGV`, `STOP`, and `VTALRM` cannot be trapp
157157

158158
When TruffleRuby is run as part of a polyglot application, any signals that are handled by another language become unavailable for TruffleRuby to trap.
159159

160+
### GC statistics
161+
162+
TruffleRuby provides similar `GC.stat` statistics to MRI, but not all statistics are available, and some statistics may be approximations. Use `GC.stat.keys` to see which are provided with real or approximate values. Missing values will return `0`.
163+
160164
## Features with Very Low Performance
161165

162166
### `ObjectSpace`

spec/ruby/core/gc/stat_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
GC.stat(:count).should be_kind_of(Integer)
1212
end
1313

14-
it "returns nil for a non-existent stat" do
15-
GC.stat(:does_not_exist).should be_nil
16-
end
17-
1814
it "increases count after GC is run" do
1915
count = GC.stat(:count)
2016
GC.start

src/main/ruby/truffleruby/core/gc.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,12 @@ def self.stat(option = nil)
8989
heap_available_slots: committed,
9090
heap_live_slots: used,
9191
heap_free_slots: committed - used,
92-
total_allocated_objects: 0,
9392
used: used,
9493
committed: committed,
9594
init: init,
9695
max: max,
97-
peak_used: 0,
98-
peak_committed: 0,
99-
peak_init: 0,
100-
peak_max: 0,
101-
last_used: 0,
102-
last_committed: 0,
103-
last_init: 0,
104-
last_max: 0,
10596
}
97+
stat.default = 0
10698

10799
memory_pool_names.each_with_index do |memory_pool_name, i|
108100
# Populate memory pool specific stats

0 commit comments

Comments
 (0)