DefaultImmutableAttributesFactoryTest.groovy

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
This is a follow up on #10004

It missed one code path for the translation of values, resulting in some

issues for kotlin projects attempting to publish resolved version to

Ivy.

    • -0
    • +16
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 1 more file in changeset.
Proper transformation of deprecated usage values

This is a follow up on #10004

It missed one code path for the translation of values, resulting in some

issues for kotlin projects attempting to publish resolved version to

Ivy.

    • -0
    • +16
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 1 more file in changeset.
Replace most usages of `NamedObjectInstantiator.INSTANCE` with injection of a global service instead. This allows the instantiator to be contextualized, for example to handle caching of the generated types.

    • -2
    • +2
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 25 more files in changeset.
Replace most usages of `NamedObjectInstantiator.INSTANCE` with injection of a global service instead. This allows the instantiator to be contextualized, for example to handle caching of the generated types.

    • -2
    • +2
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 27 more files in changeset.
Replace most usages of `NamedObjectInstantiator.INSTANCE` with injection of a global service instead. This allows the instantiator to be contextualized, for example to handle caching of the generated types.

    • -2
    • +2
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 27 more files in changeset.
Replace most usages of `NamedObjectInstantiator.INSTANCE` with injection of a global service instead. This allows the instantiator to be contextualized, for example to handle caching of the generated types.

    • -2
    • +2
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 27 more files in changeset.
Split off value snapshotting and attributes related methods of TestUtil

    • -2
    • +2
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 64 more files in changeset.
Fix concat for attributes with same name, different type

When 2 containers contain attributes with the same name and different

types, the `concat` and `safeConcat` methods of `ImmutableAttributesFactory`

now treat these attributes as equal for the purposes of merging.

Previously, these methods would produce an `AttributeContainer`

containing both attributes.

This was a violation of the `AttributeContainer` contract which states:

"It is not allowed to have two attributes with the same name but

different types in the container"

    • -0
    • +30
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 2 more files in changeset.
Add test coverage for attribute merging

    • -0
    • +29
    ./DefaultImmutableAttributesFactoryTest.groovy
Revert "Revert "Speed up attribute matching""

    • -3
    • +6
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 14 more files in changeset.
Revert "Speed up attribute matching"

    • -6
    • +3
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 14 more files in changeset.
Make ImmutableAttributes more efficient

Keep the mapping from attribute to value in a map

instead of going up the parent chain on every request.

This is faster since attributes are queried much more

often than they are created and creation is de-duplicated,

so there are only a few such attribute containers in the

whole build.

    • -3
    • +6
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 8 more files in changeset.
Improve attribute matching across build boundaries to also work correctly for values created using `ObjectFactory.named()`.

    • -3
    • +2
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 21 more files in changeset.
Added query methods to `ImmutableAttributes` to allow the value of an attribute to be queried as an `AttributeValue` without eagerly unpacking the value of the attribute.

This is just a restructure, the value is still eagerly unpacked in the query method in this change.

    • -2
    • +44
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 8 more files in changeset.
Retain the value of a variant attribute as an isolated value, rather than retaining the original value. Attribute values are snapshot at the point where the attribute is registered and are isolated from further changes to the original value.

This change allows attribute matching to more safely happen in parallel and means that attribute values can behave more consistently with other features that use isolated and snapshot values, such as task inputs or artifact transforms.

    • -3
    • +6
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 18 more files in changeset.
Added some unit test coverage for `DefaultImmutableAttributesFactory`.

    • -11
    • +31
    ./DefaultImmutableAttributesFactoryTest.groovy
Removed some production methods that are used only by tests.

    • -79
    • +30
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 4 more files in changeset.
Throw specific error when attempting to modify attributes after resolve

This restores the previous behvaior.

    • -0
    • +10
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 4 more files in changeset.
Remove test cases that are not supported anymore

The feature to create attributes from a polymorphic map has been removed

    • -22
    • +0
    ./DefaultImmutableAttributesFactoryTest.groovy
Rework caching of `ImmutableAttributes`

This commit completly reworks the storage of attributes and immutable attributes. At the root of

the change is the `ImmutableAttributesFactory`, which is used to create, combine and cache

immutable attribute sets. This factory lives at the build scope level, and does *not* use a `Map`

to represent attributes. Instead, it creates a "tree" of attributes, which are mutated by adding

a new attribute. This dramatically reduces the memory pressure caused by the creation of immutable

attributes, as long at the set of attributes and values is small (which should be the case).

It's worth noting that the factory is not a _perfect_ cache. For example, depending on the order

of attributes, several "sets", corresponding to several "path to root" can be created. For example,

we can see `(foo, bar, baz)` and `(baz, foo, bar)`. Even if they are equivalent, there will be

2 distinct paths in the cache. This is not a problem, since equality check works, and the overhead

of de-duplicating is significant, so doesn't bring any advantage.

The commit also introduces a `lockAttributes` method on `ConfigurationInternal`, which allows

effectively locking the attribute set of a configuration, transforming it to an immutable

attribute set. This avoids, if multiple consumers ask for the configuration attributes in an

immutable form, to do the conversion several times (thus reducing the pressure again).

Last but not least, `DefaultAttributesContainer` is the mutable version of the attribute

container, and relies internally on `ImmutableAttributes`. This allows us to keep the semantics

of mutable attributes during the configuration phase (and, in particular, changes the attributes

of a configuration after the artifacts are created should be visible to the artifact attributes),

while deduplicating attributes and keeping memory usage low at the same time.

The drawback of this approach is the general complexity of the code, and having to pass the

`ImmutableAttributesFactory` along.

    • -0
    • +209
    ./DefaultImmutableAttributesFactoryTest.groovy
  1. … 39 more files in changeset.