Index

Show enters and exits. Hide enters and exits.

03:38:05evanoooh
03:38:09evanfacinating!
03:38:10evanhttp://gist.github.com/140407
03:39:22evanyou can see inlined methods inlining methods
03:39:33evanwhat a wonderful holiday gift that it seems to be working!
03:50:57ddubthat looks like a lot of inlining
03:51:43evanyeah! awesome huh?
03:53:45ddub:)
03:53:52evanddub: reload it
03:53:55ddubis it faster?
03:53:59evanit's got class names now too
03:54:03evana bit easier to read
03:54:06ddubooh, classy
03:54:59evanmy simple test earlier showed a speed up from 18s to 15s
03:55:08evani'm trying to get it working first
03:55:18evanthen checking out the code it's generating
03:55:20ddubhow does inlining play with inline caching?
03:55:27evanit's better
03:55:42evanand the ICs inform inlining
03:55:49ddubis it like objc where it inlines the cache result, or is the idea that there is a dependency on expiration?
03:55:56evanso if an IC said "hey, we called Symbol#to_s every time here"
03:56:00evanthen when we compile that method
03:56:04evanwe inline Symbol#to_s
03:56:40evanthe ICs provide a way of saying "is the shit this time the same shit as last time?"
03:56:48evanso you can get to the target method ASAP
03:57:04evandispatch wise, it looks like
03:57:24evancall ic_check_cache => call target_method
03:57:38evanwith inlining, there are no calls, instead it's
03:57:50evanif obj.class.class_id == expected_class_id
03:58:00evan <code_for_target_method_here>
03:58:03evanelse
03:58:07ddubok, thats how I thought it would work
03:58:10evan return uncommon();
03:58:10evanend
03:58:55evaneach IC is a little database
03:59:07evanof receiver classes seen
03:59:18evanthat informs the JIT on how to make the code awesome
04:00:36ddubis the class id check once per inlined call or once per compiled method?
04:00:53evanhas to be once per inline call
04:00:56evan"call"
04:01:16evanbecause the reciever of the method isn't always the receiver of the inlined method
04:01:35evandef foo(a) a.bar; end
04:01:48dduband no requirement that the inlined code won't mutate the method table, eh?
04:01:51evanthe guard checks that a.class_id is the expected class id everytime
04:02:16ddubwell I meant more like def foo(a) a.bar; a.baz; end
04:02:30evanwhere a.bar redefines a.baz
04:02:38evan?
04:03:11ddubwell, I was wondering whether if did two checks to make sure the class corresponding to 'a' hasn't mutated, or one
04:03:24evanwell
04:03:30evanthere is deoptimization
04:03:33evanthat occurs on method changes
04:03:43evanso if foo inlines bar, and bar changes
04:03:47evanthen we deoptimize foo
04:04:07evanbut deoptimizing whene foo is currently running
04:04:11evanhm.
04:04:15evani don't handle that currently.
04:04:37ddubyeah, that seems ... mind-blowing
04:05:12evani wonder what the JVM does for that
04:05:28ddubponders
04:05:53evanafter each inlined method, i could check a flag in the CallFrame
04:06:05evanif it's set, bail to uncommon
04:06:21evanso after each inlining:
04:06:31evanif(call_frame->deoptimize_now) return uncommon();
04:06:48ddubbut.. that doesn't sound nearly as much fun as regenerating the method and rewriting the call stack
04:07:03evani could set the flags by looking up the CallFrame chain to find runnings of methods that needs to be deoptimized
04:07:12evanyou're right
04:07:14evani'm a wus.
04:07:19ddubtsk tsk
04:07:32ddubtake the easy way out now, I guarantee you'll have to swing back around for rubinius 3.0
04:07:40evanhah
04:07:52ddubbut perfect software never ships
04:08:08ddubwhat determines if a method is inlined?
04:08:20evana couple things currently
04:08:26evanthis is far from perfect yet
04:08:32evan1) the IC contains one receiver
04:08:42evanso we know we only ever called one method
04:09:05evan2) if the method is less than 20 instructions: it's small
04:09:17evan3) less than 200: normal
04:09:20evan4) otherwise large
04:09:48evanoh wait
04:09:55evanno no
04:09:59evani've got the logic different
04:10:03evananyway, it's based on size
04:10:22evansmall methods are allowed to inline more than normal methods
04:10:30evanso that wrapper methods can inline their destination
04:10:52evani'll need to do tests
04:10:57evanto figure out the right logic though
04:11:28ddubsounds like a job for benchmarking
04:11:40evanyep
04:12:53evanoh cooool!
04:13:00evanHash#[] got inlined
04:14:09evanwell, i'm off to dinner and a movie.
04:14:21evanperhaps a romantic comedy will enlight me into good inlining policies
04:16:01ddubinlining is hard
04:16:15ddubbut the good news is that you don't have to get it perfect
04:20:59slavahi evan