Project

General

Profile

Feature #22060

Updated by nobu (Nobuyoshi Nakada) 5 months ago

Currently, Pathname implementation is mainly in pathname_builtin.rb and only a few methods in pathname.c. 
 The code in pathname_builtin.rb is using `File` methods probably for platform portabilities. 
 This is kind of smart but is a roundabout way and is hard to understand. 
 I think it can be easier to understand maintain and more efficient by migrating some internal methods to pathname.c. 

 Comparison with master 9fefb48643: 

 |                      |master w/o JIT|PR w/o JIT|master w/ JIT|PR w/ JIT| 
 |:-------------------|-------------:|---------:|------------:|--------:| 
 |p1+p2                 |        332.541k|    696.202k|       347.315k| 952.254k| 
 |                      |               -|       2.09x|          1.04x|      2.86x| 
 |abs.root?             |          3.282M|     97.180M|         3.504M|    82.821M| 
 |                      |               -|      29.61x|          1.07x|     25.23x| 
 |rel.root?             |          3.298M|    101.917M|         3.535M|    96.676M| 
 |                      |               -|      30.91x|          1.07x|     29.32x| 
 |abs.absolute?         |         22.184M|    110.749M|        31.099M| 129.464M| 
 |                      |               -|       4.99x|          1.40x|      5.84x| 
 |rel.absolute?         |         30.862M|    111.914M|        47.010M| 118.712M| 
 |                      |               -|       3.63x|          1.52x|      3.85x| 
 |p1.cleanpath          |        395.604k|    904.909k|       418.752k|     1.342M| 
 |                      |               -|       2.29x|          1.06x|      3.39x| 
 |p2.cleanpath          |        445.949k|    982.354k|       468.972k|     1.451M| 
 |                      |               -|       2.20x|          1.05x|      3.25x| 
 |relative_path_from    |        137.595k|    271.209k|       144.976k| 393.710k| 
 |                      |               -|       1.97x|          1.05x|      2.86x| 

 Although YJIT is not effective on `Pathname#root?`, probably it is too simple for JIT. 

 [GH-16907](https://github.com/ruby/ruby/pull/16907) 

Back