share binary gem between minor versions, but not major versions • C-API change • Add or removal of stdlib, incompatible too • e.g. Ripper, Fiddle, Syck ... When a New (Big) Version? Saturday, 11 May, 13
For example, nil.to_h #=> {} • As you can splat anything into array with to_ary, you can double spat anything into hash with to_hash Saturday, 11 May, 13
UTF32 (Python): space wasted, time efficient • UTF16 (Windows / Coacoa / Java): efficient but wrong ("".length) or correct but ineffective ("".codepoints()) Saturday, 11 May, 13
a metadatum of string. • Choose ANY encoding for the best of your job. • Byte array is just a special encoding of string. ascii-8bit == binary, but ascii-7bit/us-ascii are not. Saturday, 11 May, 13
if you don’t want to handle them. (Encoding.default_internal). • But you may still find some incompatible encoding problems. 2.0 CHANGE: now default internal is utf-8 ༗ਓ๊ԇ Ruby Ճྃ encoding 这 样 త 问题 , ୠଖ 实 ݪຊత 问题 ੋ㟬ࣸྃ 错 తఔং, ׄೳ䋯ࣕቮ, Ճྃ encoding ࠽ݪຊత 错误 ࿐ग़དྷྃ Saturday, 11 May, 13
so only one core can be occupied in the ruby side • In the C-extension side there’s no such limit • Invoke zlib inside ruby threads, you can make use of any number of cores Saturday, 11 May, 13
of mostly used range of Float • 50% or more faster on Float benchmarks • Rails app? Probably not, depends on how much Float objects are created Saturday, 11 May, 13
from superscalar CPU • Pros: Totally control generated machine • Cons: Requires a lot of work • Cons: Very few ones know what’s happening Saturday, 11 May, 13
not • Memory is slow and cheap, cache is fast and expensive, it decides modern CPU architecture with a small cache. Machine preloads a segment of memory in cache, so if the memory is fragmented it will be slow. Semi-space algorithms is good for compacting young generations. Saturday, 11 May, 13
Complex code • API myths: In java calling GC doesn’t actually start GC. • Performance myths: “xxx is faster than C” means “calling C in xxx is slow” Saturday, 11 May, 13
for different generations • Can move objects but slow c-extension (v8, rubinius, ...) • Can be 3 generations (python), or infinite (java G1GC) Saturday, 11 May, 13
for different generations • Can move objects but slow c-extension (v8, rubinius, ...) • Can be 3 generations (python), or infinite (java G1GC) • Mostly require read and write barriers in C ABI Saturday, 11 May, 13
Young gen is “shiny” objects only: String, Array, Class. If an array is used by C extension, it becomes “shady” object • No break C-API although breaks ABI (so need to bump a version to 2.1) Saturday, 11 May, 13
Young gen is “shiny” objects only: String, Array, Class. If an array is used by C extension, it becomes “shady” object • No break C-API although breaks ABI (so need to bump a version to 2.1) • No read barriers Saturday, 11 May, 13
notify the GC that there’s a pointer from old gen to young gen • The “notification” is called write barriers (to notify GC that there’s a reference from old gen to new gen) • Should add write barriers while not breaking current gems Saturday, 11 May, 13