mirror of
https://github.com/ruby/ruby.git
synced 2026-10-29 08:55:35 +08:00
The assumption is that we're usually calling these methods on boot, and they don't need CCs. CCs scale with the number of classes that use these methods in the app, so if you have 10k classes and these classes use 3 of these methods on average, then that saves 30k CC objects. Methods on Module that are marked cold are: public, protected, private, module_function, ruby2_keywords, alias_method, undef_method, remove_method, attr_reader, attr_writer, attr_accessor, include, prepend. If these methods ever get redefined, they get new method definitions that are not marked uncacheable (CCs will get created). In one of our apps (not the largest), we observed this difference after boot: | method | before | after | delta | |-------------------|-------:|------:|------------:| | `include` | 4518 | 2 | -4516 | | `alias_method` | 3921 | 0 | -3921 | | `ruby2_keywords` | 3784 | 0 | -3784 | | `private` | 3519 | 3 | -3516 | | `attr_reader` | 2738 | 0 | -2738 | | `attr_accessor` | 2288 | 0 | -2288 | | `prepend` | 354 | 1 | -353 | | `protected` | 303 | 0 | -303 | | `public` | 302 | 0 | -302 | | `undef_method` | 178 | 0 | -178 | | `attr_writer` | 124 | 0 | -124 | | `module_function` | 42 | 0 | -42 | | `remove_method` | 24 | 0 | -24 | | **total** | | | **-22,089** | NOTE: CC tables and ccs (the malloced struct) are still being created, so this only reduces the CC objects themselves. I will tackle that in a follow-up.
119 lines
2.3 KiB
C
119 lines
2.3 KiB
C
/**********************************************************************
|
|
|
|
inits.c -
|
|
|
|
$Author$
|
|
created at: Tue Dec 28 16:01:58 JST 1993
|
|
|
|
Copyright (C) 1993-2007 Yukihiro Matsumoto
|
|
|
|
**********************************************************************/
|
|
|
|
#include "internal/inits.h"
|
|
#include "ruby.h"
|
|
#include "builtin.h"
|
|
static void Init_builtin_prelude(void);
|
|
#include "prelude.rbinc"
|
|
|
|
#define CALL(n) {void Init_##n(void); Init_##n();}
|
|
|
|
void
|
|
rb_call_inits(void)
|
|
{
|
|
CALL(Thread_Mutex);
|
|
CALL(RandomSeedCore);
|
|
CALL(encodings);
|
|
CALL(sym);
|
|
CALL(var_tables);
|
|
CALL(Object);
|
|
CALL(top_self);
|
|
CALL(Encoding);
|
|
CALL(Comparable);
|
|
CALL(Enumerable);
|
|
CALL(String);
|
|
CALL(Exception);
|
|
CALL(eval);
|
|
CALL(jump);
|
|
CALL(Numeric);
|
|
CALL(Bignum);
|
|
CALL(syserr);
|
|
CALL(Array);
|
|
CALL(Hash);
|
|
CALL(Struct);
|
|
CALL(Regexp);
|
|
CALL(pack);
|
|
CALL(transcode);
|
|
CALL(marshal);
|
|
CALL(Range);
|
|
CALL(IO);
|
|
CALL(MemoryView); /* Must precede IO_Buffer */
|
|
CALL(IO_Buffer)
|
|
CALL(Dir);
|
|
CALL(Time);
|
|
CALL(Random);
|
|
CALL(load);
|
|
CALL(Ruby_module);
|
|
CALL(Box);
|
|
CALL(Proc);
|
|
CALL(uncached_methods); /* after every uncached method is defined */
|
|
CALL(Binding);
|
|
CALL(Math);
|
|
CALL(GC);
|
|
CALL(WeakMap);
|
|
CALL(Enumerator);
|
|
CALL(Ractor);
|
|
CALL(VM);
|
|
CALL(ISeq);
|
|
CALL(Thread);
|
|
CALL(signal);
|
|
CALL(Cont);
|
|
CALL(Fiber_Scheduler);
|
|
CALL(process);
|
|
CALL(Rational);
|
|
CALL(Complex);
|
|
CALL(pathname);
|
|
CALL(version);
|
|
CALL(vm_trace);
|
|
CALL(vm_stack_canary);
|
|
CALL(ast);
|
|
CALL(shape);
|
|
CALL(Prism);
|
|
CALL(unicode_version);
|
|
CALL(Set);
|
|
|
|
// enable builtin loading
|
|
CALL(builtin);
|
|
}
|
|
|
|
void
|
|
rb_call_builtin_inits(void)
|
|
{
|
|
#define BUILTIN(n) CALL(builtin_##n)
|
|
BUILTIN(jit_hook);
|
|
BUILTIN(yjit);
|
|
BUILTIN(zjit);
|
|
BUILTIN(basic_object);
|
|
BUILTIN(kernel);
|
|
BUILTIN(gc);
|
|
BUILTIN(ractor);
|
|
BUILTIN(numeric);
|
|
BUILTIN(io);
|
|
BUILTIN(dir);
|
|
BUILTIN(ast);
|
|
BUILTIN(trace_point);
|
|
BUILTIN(pack);
|
|
BUILTIN(pathname_builtin);
|
|
BUILTIN(warning);
|
|
BUILTIN(array);
|
|
BUILTIN(hash);
|
|
BUILTIN(string);
|
|
BUILTIN(symbol);
|
|
BUILTIN(timev);
|
|
BUILTIN(thread_sync);
|
|
BUILTIN(nilclass);
|
|
BUILTIN(marshal);
|
|
BUILTIN(jit_undef);
|
|
Init_builtin_prelude();
|
|
}
|
|
#undef CALL
|