mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Optimize exivar access on JIT-ed getivar
JIT support ofdd723771c1. $ benchmark-driver -v --rbenv 'before;before --jit;after --jit' benchmark/mjit_exivar.yml --repeat-count=4 before: ruby 2.8.0dev (2020-03-30T12:32:26Z mastere5db3da9d3) [x86_64-linux] before --jit: ruby 2.8.0dev (2020-03-30T12:32:26Z mastere5db3da9d3) +JIT [x86_64-linux] after --jit: ruby 2.8.0dev (2020-03-31T05:57:24Z mjit-exivar 128625baec) +JIT [x86_64-linux] Calculating ------------------------------------- before before --jit after --jit mjit_exivar 57.944M 53.579M 54.471M i/s - 200.000M times in 3.451588s 3.732772s 3.671687s Comparison: mjit_exivar before: 57944345.1 i/s after --jit: 54470876.7 i/s - 1.06x slower before --jit: 53579483.4 i/s - 1.08x slower
This commit is contained in:
		
							parent
							
								
									e5db3da9d3
								
							
						
					
					
						commit
						b736ea63bd
					
				
					 7 changed files with 107 additions and 12 deletions
				
			
		
							
								
								
									
										32
									
								
								benchmark/mjit_exivar.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								benchmark/mjit_exivar.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,32 @@
 | 
			
		|||
prelude: |
 | 
			
		||||
  # frozen_string_literal: true
 | 
			
		||||
  class Bench < Hash
 | 
			
		||||
    def initialize
 | 
			
		||||
      @exivar = nil
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def exivar
 | 
			
		||||
      @exivar
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  bench = Bench.new
 | 
			
		||||
 | 
			
		||||
  if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
 | 
			
		||||
    jit_min_calls = 10000
 | 
			
		||||
    i = 0
 | 
			
		||||
    while i < jit_min_calls
 | 
			
		||||
      bench.exivar
 | 
			
		||||
      i += 1
 | 
			
		||||
    end
 | 
			
		||||
    RubyVM::MJIT.pause # compile (1)
 | 
			
		||||
    # issue recompile
 | 
			
		||||
    bench.exivar
 | 
			
		||||
    RubyVM::MJIT.resume
 | 
			
		||||
    RubyVM::MJIT.pause # compile (2)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
benchmark:
 | 
			
		||||
  mjit_exivar: bench.exivar
 | 
			
		||||
 | 
			
		||||
loop_count: 200000000
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue