-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Excessive splitting with Method#to_proc
#3527
Comments
Thank you for the report, that repro is enough to show there is unexpected splitting there, it should split at most once since there is a single caller of |
I investigated this. (we could also force split + inline cache that, but the minimal performance gain doesn't seem worth the footprint cost) |
Regarding EDIT: @nirvdrum will do this |
I'm trying to track down a production issue where the
Array#<<
method keeps splitting. There's no deoptimization. If I trace splitting, the log just fills up with something like the following (I removed a few interspersed splits from other methods, but most of these appear back-to-back).Splitting Log
I've added logging to
RubyRootNode#cloneUninitialized
and with that, I've tracked the source of the split toTruffle::Splitter.add_substring
. In particular,Truffle::Splitter.split
accepts a block to work with the split results, but if no block is provided, it returns an array of the split components. To avoid code duplication, it does the following if a block is not provided:That's the source of the
Array#<<
splits. The string splitting code is quite large, so cutting that out we're left with:If you run
jt ruby --engine.TraceSplitting split_issue.rb
, you'll see a consecutive run of splits forArray#<<
:The splitting will stop once the dispatch cache limit in
MethodNodes.ToProcNode#toProcCachedSingleContext
is hit. In my production environment, however, the splitting never stops. I haven't yet determined why that is and my attempts at finding a small reproduction haven't produced the non-stop splitting. Unfortunately, due to security restrictions in the production environment I can only usejdb
as the debugger and that's making for a very slow process.The primary attribution stems back to a code loop that writes to a file once per second. It looks like:
The
File.open
call will callTruffle::IOOperations.normalize_options
, which in turn callsString#split
. The loop body is not dynamically declaring classes or methods, so I'm not sure why the splits won't converge.We can work around this by changing the way
Truffle::Splitter
works, but I think it's worth looking at the larger issue.The text was updated successfully, but these errors were encountered: