(maint) Switch from -fd to -fp for specs to reduce disk space usage
Revert "Add initial support for building in a RHEL 7 mock"

This reverts commit b471b9d2a37ca10d0d20c294e813b5a46e6cabd9.
Merge pull request #2353 from melissaanne/maint/stable/revert-el7-mock

Revert "Add initial support for building in a RHEL 7 mock"
(PUP-751) Check for reparse once per compile

Previously, whenever the known_resource_types
(Puppet::Resource::TypeCollection) was retrieved from the
environment it would check if there were any files that needed to be
reparsed. If any files needed a reparse, then the entire TypeCollection
was thrown away and redone.

In most cases the reparse check did not need to touch the filesystem
because the Puppet::Util::PeriodicWatcher would return a cached result
until the filetimeout had expired. Unfortunately the check was done so
often that the overhead of simply checking if enough time had passed
caused it to take a considerable amount of time.

This changes it so that the environment's known resource types are only
recalculated if the new check_for_reparse method determines that it
should. The new method is only called at the beginning of a compile and
so the files will never be checked while a compilation is being
executed.
(maint) Backport benchmarking from 3.5 to 3.4.2

This backports the bechmarking from Puppet "3.5.0" (i.e. master)
to 3.4.2 and modifies the many_modules benchmark to not use lookup
to get the "benchmarking" environment.
(maint) Make benchmark:defined_types work on 3.4.2

This changes the use of lookup to creating an Environment.
(maint) Set required conf parameters to make benchmarks do something

The backport did not consider that environments needed to be configured
differently than for the new env support in 3.5.
Merge pull request #2356 from hlindberg/maint_add-benchmarking-to-stable

(PUP-751) Add benchmarking to stable
Merge pull request #2355 from zaphod42/issue/stable/pup-751-backport-performance-fix-to-stable

(PUP-751) Check for reparse once per compile
(maint) Implement FileSystem.file? for consistency

The filesystem abstraction implements `.directory?` but not `.file?` which is
somewhat inconsistent. This commit adds that method and uses the same
behavior implemented by `.directory?`.
(maint) fixup yumrepo provider to use fs abstraction

There were a few places where the filesystem abstraction was being
ignored; this commit corrects those cases. This commit also refactors
the associated tesets and simplifies #create for easier testing.
Merge branch 'maint/master/fixup-yumrepo-filesystem-access'
(PUP-751) Check for reparse once per compile

Previously, whenever the known_resource_types
(Puppet::Resource::TypeCollection) was retrieved from the
environment it would check if there were any files that needed to be
reparsed. If any files needed a reparse, then the entire TypeCollection
was thrown away and redone.

In most cases the reparse check did not need to touch the filesystem
because the Puppet::Util::PeriodicWatcher would return a cached result
until the filetimeout had expired. Unfortunately the check was done so
often that the overhead of simply checking if enough time had passed
caused it to take a considerable amount of time.

This changes it so that the environment's known resource types are only
recalculated if the new check_for_reparse method determines that it
should. The new method is only called at the beginning of a compile and
so the files will never be checked while a compilation is being
executed.

In my local benchmark runs (the many_modules benchmark) this resulted in
a speedup from ~0.8 seconds to ~0.6 seconds.
(maint) Optimize adding tags

Resources add a lot of tags and so streamlining that ends up with a
overall savings for catalog compilation. This removes an extra call to
collect, removes several method calls, and relies on the fact that the
@tags object is a set and so we don't need to check for the tag already
being there.
(maint) Use JSON for parsing metadata.json

Now that puppet depends on JSON we can use it to parse the metadata.json
file. The built in json parsers will be much faster than PSON.
(maint) Remove String check

There isn't any need to check for the String class because it also
responds to to_str. This reduces the number of calls in the case of
things that respond to to_str
(maint) Reduce calls to settings

During the lifetime of a scope object the value of the trusted data
settings should not change. Rather than looking this up on every
invocation of setvar, which is fairly expensive, the scope can simply
hold onto the value from when it was instantiated.
(maint) Hold token name in local variabel

The tokens name was fetch multiple times in quick succession. The lexer
is in a very tight inner loop and so any reduction of method calls can
produce improvements in performance. Although most work for language
performance is focussed on the new parser, this is a simple, small win
that we can easily take now.
(PUP-751) Benchmark defined resource types

This adds a benchmark for compiling defined resource types. There are
simply multiple modules that have a single defined resource type in
each. The site.pp produces 2 instances of each defined type.

Current timings on my local machine:

                     user     system      total        real
    Run 1        0.780000   0.150000   0.930000 (  0.935276)
    Run 2        0.760000   0.140000   0.900000 (  0.901496)
    Run 3        0.780000   0.130000   0.910000 (  0.912020)
    Run 4        0.780000   0.130000   0.910000 (  0.917095)
    Run 5        0.780000   0.130000   0.910000 (  0.908075)
    Run 6        0.810000   0.140000   0.950000 (  0.950874)
    Run 7        0.820000   0.130000   0.950000 (  0.948420)
    Run 8        0.780000   0.140000   0.920000 (  0.918298)
    Run 9        0.780000   0.130000   0.910000 (  0.905121)
    Run 10       0.770000   0.130000   0.900000 (  0.903823)
    > total:     7.840000   1.350000   9.190000 (  9.200498)
    > avg:       0.784000   0.135000   0.919000 (  0.920050)
(PUP-751) Preserve environment across resource copy

The resource's environment was lost when a copy was made. This caused
the type information to be looked up again, from scratch, as well as a
total loss of the associated environment information (it would switch
from one environment to another). By preserving the environment any
calls to resource_type, or other methods that require the environment,
are much faster.

This also preserves the rstype cache of the resource_type to cut down
the looks a slight amount more.

Here is the breakdown of the speedups to this point on my machine:

Initial(bca4d4e):
> total:     7.520000   1.250000   8.770000 (  8.789636)
> avg:       0.752000   0.125000   0.877000 (  0.878964)

Prefer defined types(2617d61):
> total:     7.150000   1.170000   8.320000 (  8.326319)
> avg:       0.715000   0.117000   0.832000 (  0.832632)

Preserve environment(3f8e94c):
> total:     6.170000   0.860000   7.030000 (  7.057820)
> avg:       0.617000   0.086000   0.703000 (  0.705782)

I also tried to change the order of loading in
Puppet::Parser::Scope#find_resource_type to have it look for defined
types first, but that resulted in an overall slowdown:

> total:     6.740000   0.730000   7.470000 (  7.476968)
> avg:       0.674000   0.073000   0.747000 (  0.747697)