Skip to content

Avoid uncached isBuiltin and uncached calls in Enumerable#6369

Merged
headius merged 1 commit intojruby:masterfrom
headius:cached_isbuiltin_and_enumerable_calls
Aug 28, 2020
Merged

Avoid uncached isBuiltin and uncached calls in Enumerable#6369
headius merged 1 commit intojruby:masterfrom
headius:cached_isbuiltin_and_enumerable_calls

Conversation

@headius
Copy link
Member

@headius headius commented Aug 28, 2020

There are several changes here to avoid uncached method lookups along hot paths:

  • All uses of RubyBasicObject.isBuiltin except for two have been replaced with CachingCallSite.isBuiltin. The two that remain are for the IO stream wrappers and are not valuable to cache. This came up in a profile of RubyKon where Array#any?'s uncached isBuitin must be on a hot path.
  • All uncached method calls in RubyEnumerable are replaced by CallSite.call, including the various callEach forms. These sites are localized as much as possible to avoid conflicts, but will still churn quite a bit in a typical application that has many Enumerable implementers. Long-term we should move Enumerable to a Ruby implementation that can be split and specialized.

In addition, in RubyEnumerable all lambdafiable block callbacks
have been replaced by lambdas (fewer class files) and all deprecated methods moved to the bottom of the file.

There are several changes here to avoid uncached method lookups
along hot paths:

* All uses of RubyBasicObject.isBuiltin except for two have been
  replaced with CachingCallSite.isBuiltin. The two that remain are
  for the IO stream wrappers and are not valuable to cache. This
  came up in a profile of RubyKon where Array#any?'s uncached
  isBuitin must be on a hot path.
* All uncached method calls in RubyEnumerable are replaced by
  CallSite.call, including the various callEach forms. These sites
  are localized as much as possible to avoid conflicts, but will
  still churn quite a bit in a typical application that has many
  Enumerable implementers. Long-term we should move Enumerable to
  a Ruby implementation that can be split and specialized.

In addition, in RubyEnumerable all lambdafiable block callbacks
have been replaced by lambdas (fewer class files) and all
deprecated methods moved to the bottom of the file.
@headius headius added this to the JRuby 9.3.0.0 milestone Aug 28, 2020
@headius headius merged commit 6b885b0 into jruby:master Aug 28, 2020
@headius headius deleted the cached_isbuiltin_and_enumerable_calls branch August 28, 2020 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant