YJIT: Include actual memory region size in stats (#6736)

This commit is contained in:
Takashi Kokubun 2022-11-15 15:20:02 -08:00 committed by GitHub
parent d1fb659547
commit 0d384ce6e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2022-11-15 23:20:21 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
3 changed files with 9 additions and 2 deletions

View File

@ -262,6 +262,7 @@ module RubyVM::YJIT
$stderr.puts "inline_code_size: " + ("%10d" % stats[:inline_code_size])
$stderr.puts "outlined_code_size: " + ("%10d" % stats[:outlined_code_size])
$stderr.puts "freed_code_size: " + ("%10d" % stats[:freed_code_size])
$stderr.puts "code_region_size: " + ("%10d" % stats[:code_region_size])
$stderr.puts "yjit_alloc_size: " + ("%10d" % stats[:yjit_alloc_size]) if stats.key?(:yjit_alloc_size)
$stderr.puts "live_page_count: " + ("%10d" % stats[:live_page_count])
$stderr.puts "freed_page_count: " + ("%10d" % stats[:freed_page_count])

View File

@ -210,12 +210,15 @@ impl CodeBlock {
self.page_size
}
pub fn mapped_region_size(&self) -> usize {
self.mem_block.borrow().mapped_region_size()
}
/// Return the number of code pages that have been mapped by the VirtualMemory.
pub fn num_mapped_pages(&self) -> usize {
let mapped_region_size = self.mem_block.borrow().mapped_region_size();
// CodeBlock's page size != VirtualMem's page size on Linux,
// so mapped_region_size % self.page_size may not be 0
((mapped_region_size - 1) / self.page_size) + 1
((self.mapped_region_size() - 1) / self.page_size) + 1
}
/// Return the number of code pages that have been reserved by the VirtualMemory.

View File

@ -402,6 +402,9 @@ fn rb_yjit_gen_stats_dict() -> VALUE {
// Code GC count
hash_aset_usize!(hash, "code_gc_count", CodegenGlobals::get_code_gc_count());
// Size of memory region allocated for JIT code
hash_aset_usize!(hash, "code_region_size", cb.mapped_region_size());
// Rust global allocations in bytes
#[cfg(feature="stats")]
hash_aset_usize!(hash, "yjit_alloc_size", global_allocation_size());