Actions
Feature #16562
openExpose rb_io_set_encoding_internal to reduce function calls on loading source files
Feature #16562:
Expose rb_io_set_encoding_internal to reduce function calls on loading source files
Status:
Open
Assignee:
-
Target version:
-
Description
References https://github.com/ruby/ruby/pull/2829
Removes a few rb_funcall calls from source file reading and the AST loader.
-
rb_ast_parse_file: removes 1 xrb_funcall, removes 1 transient string allocation ("-") -
load_file_internal: removes 3 xrb_funcall, removes 1 transient string allocation ("-") - Removes a branch from
rb_io_set_encodingwhich checks for a T_FILE type which I could not take with ruby tests or Rails (asserted with an inlinerb_bugfor backtrace :smile: ). I declare it dead - Removes static symbol
id_set_encodingfromio.c - Introduces a literal fstring
str_no_transcodingto represent the no transcoding option"-"
Now ... I don't think I like the API naming convention of rb_io_set_encoding_internal very much for the following reason: with internal it means not public API (but then again declaring it in ruby/io.h implies that too, but can also be interpreted as internal encoding, which can be confusing.
Open to ideas about the API and also the special Qfalse argument which assigns the no transcoding special case.
Master booting Redmine with Rails 6:
[RUBY_DEBUG_COUNTER] obj_newobj 2095742
[RUBY_DEBUG_COUNTER] frame_push_cfunc 2217390
This PR:
[RUBY_DEBUG_COUNTER] obj_newobj 2093369
[RUBY_DEBUG_COUNTER] frame_push_cfunc 2212686
Diffs:
-
4704less C function calls (my understanding isrb_calland friends would bumpframe_push_cfunc) -
2373less transient objects allocated (about half of the dispatch calls also allocated a "-" string)
Which is about inline with the loaded features for booting the process:
irb(main):002:0> $LOADED_FEATURES.size
=> 2165
Actions