Skip to content
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

RBX GC performance issues #604

Closed
chuckremes opened this issue Dec 13, 2010 · 2 comments
Closed

RBX GC performance issues #604

chuckremes opened this issue Dec 13, 2010 · 2 comments

Comments

@chuckremes
Copy link
Member

As requested, here is a small benchmark showing a perf issue with the rbx GC.

https://gist.github.com/739693

Running this same code under MRI completes in about 300ms.

Running with profiling turned on shows most of the time is spent in Tuple.new and Tuple#copy_from.

Interestingly, a pure "append" operation is wicked fast whereas inserting at the end causes a lot of tuple copies.

@dgtized
Copy link
Member

dgtized commented Dec 14, 2010

I could be wrong on this, but I believe the problem here is that Array#<< can use the fast path to the primitive, but that insert actually calls self[index, 0] = items, where items is the array of remaining values passed to insert.

The unfortunate result of this is that when you resize for an inplace insertion of an array, then we don't pre-allocate a new tuple that is 1.5 times the size of the previous tuple, and just resize to the exact additional space required.

The GC is doing exactly what it's supposed to here as far as I know, it's just array is triggering a Tuple#new and a Tuple#copy_from on every single insert.

The relevant lines in Array#set_index are from 248 to 275 in kernel/common/array.rb. Also line 930 in the same file shows where Array#insert is using set_index. I remember commenting at the time that we were using two paths for array resizing which meant that one was optimal and one was not, but we were looking at alternate array storage mechanisms at the time so we didn't fix it.

@evanphx
Copy link
Member

evanphx commented Dec 14, 2010

Remove pathalogical case from Array#[]=. Closed by a6952da.

srawlins pushed a commit to srawlins/rubinius that referenced this issue May 27, 2011
brixen added a commit that referenced this issue Jan 7, 2014
=== 2.2.0 / 2013-12-26

Special thanks to Vít Ondruch and Michal Papis for testing and finding bugs in
RubyGems as it was prepared for the 2.2.0 release.

Major enhancements:

* RubyGems can check for gem dependencies files (gem.deps.rb or Gemfile) when
  rubygems executables are started and uses the found dependencies.  This
  means `rake` will work similar to `bundle exec rake`.  To enable this set
  the `RUBYGEMS_GEMDEPS` environment variable to the location of your
  dependencies file.

  See Gem::use_gemdeps for further details.

* A RubyGems directory may now be shared amongst multiple ruby versions.  Upon
  activation RubyGems will automatically compile missing extensions for the
  current platform when the built objects are missing.  Issue #596 by Michal
  Papis

  By default different platforms do not share gem install locations so this
  must be configured by setting GEM_HOME to a common directory.  Some gems use
  fixed paths for requiring extensions and are not compatible with sharing gem
  directories.

  The default sharing location may be configured by RubyGems packagers through
  Gem.default_ext_dir_for.  Pull Request #744 by Vít Ondruch.

Minor enhancements:

* RubyGems checks the 'allowed_push_host' metadata value when pushing a gem to
  prevent an accidental push to a public repository (such as rubygems.org).
  If you have private gems you should set this value in your gem specification
  metadata.  Pull request #603 by Seamus Abshere.
* `gem list` now shows results for multiple arguments.  Pull request #604 by
  Zach Rabinovich.
* `gem pristine --extensions` will restore only gems with extensions.  Issue
  #619 by Postmodern.
* Gem::Specification#files is now sorted.  Pull request #612 by Justin George.
* For `gem list` and friends, "LOCAL" and "REMOTE" headers are omitted if
  only local or remote gem information is requested with --quiet.  Pull
  request #615 by Michal Papis.
* Added Gem::Specification#full_require_paths which is like require_paths, but
  returns a fully-qualified results.  Pull request #632 by Vít Ondruch.
* RubyGems now looks for the https_proxy environment variable for https://
  sources.  RubyGems will fall back to http_proxy if there is no https_proxy.
  Issue #610 by mkristian.
* RubyGems now creates directories in .gem files.  Issue #631 by marksolaris.
* RubyGems raises an exception when a specification includes its gem.  Issue
  #623 by notEthan.
* RubyGems now displays relevant release note information when updating
  RubyGems.  Issue #647 by Trevor Wennblom.
* Deprecated Gem::Installer::ExtensionBuildError in favor of
  Gem::Ext::BuildError.  The old constant is an alias for the new constant.
* When extensions are built the gem_make.out file is always written now, even
  on success.  This will help with debugging bad builds that report success.
* If a specification fails to validate RubyGems shows a link to the
  specification reference guide.  Issue #656 by Markus Heiler.
* When using `gem install -g`, RubyGems now detects the presence of an
  Isolate, Gemfile or gem.deps.rb file.
* Added Gem::StubSpecification#stubbed? to help determine if a user should run
  `gem pristine` to speed up gem loading.  Pull request #694 and #701 by Jon
  Leighton.
* RubyGems now warns when a gem has a pessimistic version dependency that may
  be too strict.
* RubyGems now warns when a gem has an open-ended dependency.
* RubyGems now raises an exception when a dependency for a gem is defined
  twice.
* Marked the license specification attribute as recommended.  Pull request
  #713 by Benjamin Fleischer.
* RubyGems uses io/console instead of `stty` when available.  Pull request
  #740 by Nobuyoshi Nakada
* Relaxed Gem.ruby tests for platforms that override where ruby lives.  Pull
  Request #755 by strzibny.

Bug fixes:

* RubyGems now returns an error status when any file given to `gem which`
  cannot be found.  Ruby bug #9004 by Eugene Vilensky.
* Fixed command escaping when building rake extensions.  Pull request #721 by
  Dmitry Ratnikov.
* Fixed uninstallation of gems when GEM_HOME is a relative directory.  Issue
  #708 by Ryan Davis.
* Default gems are now ignored by Gem::Validator#alien.  Issue #717 by David
  Bahar.
* Fixed typos in RubyGems.  Pull requests #723, #725, #731 by Akira Matsuda,
  pull request #736 by Leo Gallucci, pull request #746 by DV Suresh.
* RubyGems now holds exclusive locks on cached gem files to prevent incorrect
  updates.  Pull Request #737 by Smit Shah
* Improved speed of `gem install --ignore-dependencies`.  Patch by Terence
  Lee.

------------------------------------------------------------------------------
This issue was closed.
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

No branches or pull requests

3 participants