Skip to content

concretizer: add --minimal configuration/CLI option#28470

Open
tgamblin wants to merge 1 commit intodevelopfrom
minimal-concretization
Open

concretizer: add --minimal configuration/CLI option#28470
tgamblin wants to merge 1 commit intodevelopfrom
minimal-concretization

Conversation

@tgamblin
Copy link
Copy Markdown
Member

@tgamblin tgamblin commented Jan 17, 2022

This should merged after #28468, as it builds on top of it.

The reusing concretizer minimizes builds, but it still preserves defaults from packages and preferences while doing that. We can be more aggressive by making minimization the top priority, at the expense of "weird" concretizations.

This can be advantageous: if you write your packages as explicitly as possible, then you can use that with --minimal to get the smallest possible package configuration (at least in terms of the number of packages in the build). Conversely, you can use minimal concretization as kind of a worst case to ensure that you have the "right" constraints on your dependencies.

Example for intuition: cmake can optionally build without openssl, but it's enabled by default because many builds use that functionality. Using minimal: true will build cmake~openssl unless the user asks for cmake+openssl explicitly.

Examples

Say there's one cmake installed, with hash zd4m26e :

(spackle):spack> spack find -l cmake
==> 1 installed package
-- darwin-bigsur-skylake / [email protected] -------------------
zd4m26e [email protected]

By default, we would build a fancy new one:

$ spack spec -l cmake
[...]
mo7v6mw  [email protected]%[email protected]~doc+ncurses+openssl+ownlibs~qt build_type=Release arch=darwin-bigsur-skylake
xdbaqeo      ^[email protected]%[email protected]~symlinks+termlib abi=none arch=darwin-bigsur-skylake
kfureok          ^[email protected]%[email protected] arch=darwin-bigsur-skylake
qxn6sl3      ^[email protected]%[email protected]~docs certs=system arch=darwin-bigsur-skylake
xz6a265          ^[email protected]%[email protected]+cpanm+shared+threads arch=darwin-bigsur-skylake
xgt3tls              ^[email protected]%[email protected]+cxx~docs+stl patches=b231fcc4d5cff05e5c3a4814f6a5af0e9a966428dc2176540d2c05aff41de522 arch=darwin-bigsur-skylake
65edjf6              ^[email protected]%[email protected]~debug~pic+shared arch=darwin-bigsur-skylake
662adoo                  ^[email protected]%[email protected] arch=darwin-bigsur-skylake
fu7tfsr                      ^[email protected]%[email protected] libs=shared,static arch=darwin-bigsur-skylake
vjg67nd              ^[email protected]%[email protected] arch=darwin-bigsur-skylake
tjceldr                  ^[email protected]%[email protected] arch=darwin-bigsur-skylake
xevvljj              ^[email protected]%[email protected]+optimize+pic+shared arch=darwin-bigsur-skylake

With --reuse, we'd use the installed zd4m26e:

$ spack spec -l --reuse cmake
[...]
zd4m26e  [email protected]%[email protected]~doc+ncurses+openssl+ownlibs~qt build_type=Release arch=darwin-bigsur-skylake
53i52xr      ^[email protected]%[email protected]~symlinks+termlib abi=none arch=darwin-bigsur-skylake
us36bwr      ^[email protected]%[email protected]~docs+systemcerts arch=darwin-bigsur-skylake
74mwnxg          ^[email protected]%[email protected]+optimize+pic+shared arch=darwin-bigsur-skylake

--minimal alone would build a new cmake with options that require a dependency turned off (here, ~ncurses and ~openssl):

$ spack spec -l --minimal cmake
[...]
g6szokb  [email protected]%[email protected]~doc~ncurses~openssl+ownlibs~qt build_type=Release arch=darwin-bigsur-skylake

Using both picks zd4m26e again because that gets you zero builds:

$ spack spec -l --minimal --reuse cmake
[...]
zd4m26e  [email protected]%[email protected]~doc+ncurses+openssl+ownlibs~qt build_type=Release arch=darwin-bigsur-skylake
53i52xr      ^[email protected]%[email protected]~symlinks+termlib abi=none arch=darwin-bigsur-skylake
us36bwr      ^[email protected]%[email protected]~docs+systemcerts arch=darwin-bigsur-skylake
74mwnxg          ^[email protected]%[email protected]+optimize+pic+shared arch=darwin-bigsur-skylake

Using both with cmake ~openssl will reuse ncurses/53i52xr (because it doesn't add a build):

(spackle):spack> spack spec -l --minimal --reuse cmake~openssl
[...]
rcvz2la  [email protected]%[email protected]~doc+ncurses~openssl+ownlibs~qt build_type=Release arch=darwin-bigsur-skylake
53i52xr      ^[email protected]%[email protected]~symlinks+termlib abi=none arch=darwin-bigsur-skylake

I am not sure if people want this result or the one from spack spec -l --minimal cmake above. --minimize is minimizing builds, not nodes. I could see where both could be useful, but you can effectively get minimization of nodes right now by just using --minimal (see above), so I don't think we need to add another config. This is more composable.

  • add minimal option to concretizer.yaml
  • add --minimal CLI option to concretizer arguments
  • wire everything up
  • add some tests

Copy link
Copy Markdown
Member

@becker33 becker33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some quick questions, but I need to give this a once-over again after it's rebased.

Comment on lines +2051 to +2201
``minimal (bool)``
If ``True`` make minimizing nodes the top priority, even higher
than defaults from packages and preferences.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't quite match the description you gave in the PR, it sounds like it makes minimizing builds the priority -- I think we need to make sure to document which it is properly.

if reuse is on, minimize is on, and cmake+openssl is already installed, is spack spec cmake supposed to use the old one?

def __init__(self):
self.set_default_coanfiguration()

def set_default_coanfiguration(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def set_default_coanfiguration(self):
def set_default_configuration(self):

continue
spack.spec.Spec.ensure_valid_variants(s)
def __init__(self):
self.set_default_coanfiguration()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.set_default_coanfiguration()
self.set_default_configuration()

@tgamblin tgamblin force-pushed the minimal-concretization branch from e41ee22 to bde33c7 Compare May 4, 2022 01:08
@becker33 becker33 self-assigned this May 23, 2022
@tgamblin tgamblin force-pushed the minimal-concretization branch from bde33c7 to afde810 Compare May 24, 2022 18:41
The reusing concretizer minimizes builds, but it still preserves
defaults from packages and preferences while doing that. We can be
more aggressive by making minimization the top priority, at the
expense of "weird" concretizations.

This can be advantageous: if you write your packages as explicitly
as possible, then you can use that with `--minimal` to get the
smallest possible package configuration (at least in terms of the
number of packages in the build).  Conversely, you can use minimal
concretization as kind of a worst case to ensure that you have the
"right" constraints on your dependencies.

Example for intuition: `cmake` can optionally build without openssl, but
it's enabled by default because many builds use that functionality. Using
`minimal: true` will build `cmake~openssl` unless the user asks for
`cmake+openssl` explicitly.

- [x] add `minimal` option to `concretizer.yaml`
- [x] add `--minimal` CLI option to concretizer arguments
- [x] wire everything up
- [x] add some tests
@tgamblin tgamblin force-pushed the minimal-concretization branch from afde810 to 3985b30 Compare May 24, 2022 18:52
Comment on lines +682 to +684
# Solver paramters that affect setup -- see Solver documentation
self.reuse = spack.config.get(
"concretizer:reuse", False) if reuse is None else reuse
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now passed in the setup method and is a list of specs.

Copy link
Copy Markdown
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently needs:

  1. An update to resolve conflicts with the recently merged #28941 (reuse argument)
  2. spack commands --update-completion
  3. Maybe a few lines of docs at https://spack.readthedocs.io/en/latest/build_settings.html#concretizer-options ?

@tgamblin tgamblin added this to the v0.20.0 milestone Nov 7, 2022
@alalazo alalazo modified the milestones: v0.20.0, v0.21.0 May 3, 2023
@tgamblin tgamblin modified the milestones: v0.21.0, v0.22.0 Oct 17, 2023
@tgamblin tgamblin removed this from the v0.22.0 milestone Apr 29, 2024
@tgamblin tgamblin added this to the v0.23.0 milestone Apr 29, 2024
@tgamblin tgamblin modified the milestones: v0.23, v0.24 Oct 28, 2024
@becker33 becker33 modified the milestones: v1.0.0, v1.0.0 stretch goals Nov 25, 2024
@haampie haampie modified the milestones: v1.0.0 stretch goals, v1.1.0 Jul 24, 2025
@tgamblin tgamblin removed this from the v1.1.0 milestone Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants