HomePhorge

monkey_patch: cache Symbol to_proc result.
397dfa8fc9daUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

monkey_patch: cache Symbol to_proc result.

If we use it, our monkey-patch version of Symbol to_proc is worth caching the
resulting proc - the hit rate is through the roof, because we only really act
on a small set of symbols.

This reduces some extra object and memory allocation by reusing the same proc
every time we transform the same symbol.

That saves 99.84 percent of the memory allocated from this method - about four
percent of the total memory allocation in my test run of Puppet with real
manifests and behaviours. (About 10MB out of 260MB originally; 26kb after.)

This applies to all versions - newer Rubies with a real implementation of
to_proc don't cache the result, so we do it for them.

Older versions *cough* 1.8.5 *cough* still get our hand-written implementation
of the proc, so that they work. It probably is equivalent to the real version,
but I would rather allow core changes to show.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>

Conflicts:
lib/puppet/util/monkey_patches.rb

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>

Details

Provenance
Daniel Pittman <daniel@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU54c4f0a36807: lexer: remove some unused stats collection
Branches
Unknown
Tags
Unknown

Event Timeline

Daniel Pittman <daniel@puppetlabs.com> committed rPU397dfa8fc9da: monkey_patch: cache Symbol to_proc result. (authored by Daniel Pittman <daniel@puppetlabs.com>).Sep 18 2012, 2:55 AM