Skip to content

concretization: improve error messages for requirements#45800

Merged
tgamblin merged 88 commits intospack:developfrom
scheibelp:features/err-msg-tests
Nov 5, 2025
Merged

concretization: improve error messages for requirements#45800
tgamblin merged 88 commits intospack:developfrom
scheibelp:features/err-msg-tests

Conversation

@scheibelp
Copy link
Copy Markdown
Member

@scheibelp scheibelp commented Aug 17, 2024

This is intended to test out concretization error messages. Each test culminates in a concretization attempt that must fail (because the problem is over-constrained by design).

Some of these tests add constraints to package definitions, and some add requirements to configuration. The error messages vary in quality but the tests are here to help experiment with tweaks to the .lp files to improve the messages. The tests do not include any enforcement of what appears in the error message: that has to be done manually, with something like spack unit-test -k error_messages.py -s -v.

Updates

  • September 4 2025: all tests related to requirements are improved as of ea7ab09
    • Theory: The concretizer has the freedom to choose a wrong version; the error weights for these type of messages was low, so it could short-circuit a cause chain by just assigning a wrong version
      • I've split the version error mechanism in two: arbitrary version selections that lead to version errors are penalized heavily. Version errors that result from other constraints are not.
    • A couple tests not related to requirements are generating bad error messages: test_version_range_null, test_null_variant_for_requested_version
  • Jan. 22nd 2025: When this PR was first created, the error messages for requirements were particularly bad, but I improved them quite a bit by heavily encouraging requirement groups to apply at least one of their constraints, which appears to properly hook into the causal chaining logic in error_messages.lp.

TODOs

  • testing: the tests should include asserts rather than just printing the errors for manual inspection
    • (fixed as of September 8 in 0899dbd)

(old) All the tests here fail (on purpose)

(old) All current tests added here do this by adding constraints to the package definition, but should probably also check mixing in config/command-line requirements.

@scheibelp scheibelp added the WIP label Aug 17, 2024
@spackbot-app spackbot-app bot added conflicts core PR affects Spack core functionality dependencies new-variant new-version tests General test capability(ies) labels Aug 17, 2024
@scheibelp scheibelp changed the title [WIP] concretization: improve error messages for requirements concretization: improve error messages for requirements Sep 17, 2025
@scheibelp
Copy link
Copy Markdown
Member Author

@becker33 I think all your requests are addressed now. I also cleaned up some of the comments in the tests

It may be arguable whether errmsg_requirements_external_mismatch is sufficiently-improved here: it used to be

    1. cannot satisfy a requirement for package 't1'.

and now it is

     1. Cannot build t1, since it is configured `buildable:false` and no externals satisfy the request

better, but perhaps still not good.

@tgamblin tgamblin merged commit 3949a27 into spack:develop Nov 5, 2025
30 of 32 checks passed
Comment on lines +310 to +314
{ attr("version", node(ID, Package), Version) } :-
requirement_group_member(ConditionID, Package, RequirementID),
activate_requirement(node(ID, Package), RequirementID),
pkg_fact(Package, condition_effect(ConditionID, EffectID)),
imposed_constraint(EffectID, "node_version_satisfies", Package, Version).
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.

Some timing with requirements on would have been nice in this PR, so to know if there is any slow-down / speed-up to be expected.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Apologies yes benchmarking would be useful: How do I do that? (i.e. how do I produce the before/after stats that you add to some PRs)?

This particular rule can be removed (although your comment likely does not apply to it specifically): I looked into it and this was originally added (in 75730ec) for 344d77a, but an intervening merge removed that logic and it appears that as a result this doesn't actually improve error output for any of the tests (nor any that I can come up with)

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.

How do I do that? (i.e. how do I produce the before/after stats that you add to some PRs)?

We have a Spack extension here https://github.com/spack/spack-benchmark In the README you'll find the commands.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Nov 13, 2025

I noticed a general slowdown of concretization yesterday, with respect to the last time I measured on my machine. I performed a test on a reduced set of specs (just because it takes a lot of time to do the full test).

Here are the results of this PR compared to the previous commit on develop (ecde809 vs 3949a27)

benchmark.pr.csv
benchmark.develop.csv
radiuss-reduced.txt

comparison

It seems this PR caused a general slowdown of concretization. For spack solve hdf5 --timers it's ~20% on my machine. I'll check if that can be improved with some small fix, but let me know if you can reproduce, or not.

@scheibelp
Copy link
Copy Markdown
Member Author

Benchmarking is reporting a regression for me comparing this with prior commit - the following is just the solve times (as the total times are much closer):

image

it's ~20% on my machine.

Is this average output as part of solve-benchmark?
I see a 14% increase in total solve time across all benchmarked specs.

There is likewise a regression when comparing ecde809 with 4170858

@scheibelp
Copy link
Copy Markdown
Member Author

scheibelp commented Nov 14, 2025

After 4170858, the only logic that isn't changing weights is

{ choose_version(node(ID, Package), Version) : pkg_fact(Package, version_declared(Version)) }
 :- attr("node", node(ID, Package)).

attr("version", node(ID, Package), Version) :- choose_version(node(ID, Package), Version).

If I revert that part on top of 4170858, then the benchparks show no significant timing change. This part is useful for error messages, but it only needs to exist when mixing in error_messages.lp, so optimistically would only increase concretization times for failed concretizations; I had trouble with that in other parts of this PR, but it seems like a worthy thing to chase to improve the timing.

EDIT: my initial attempt at this in #51576 does not work.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Nov 14, 2025

Is this average output as part of solve-benchmark?

No, it's the result of spack solve hdf5 --timers. I used that time to bisect the commit on my machine.

the only logic that isn't changing weights is, [ ... ]

Yes, it's the two extra rules that increased the time. Once v1.1 is released, I'll try to check if profiling with latest development version of clingo helps identifying better what to change. Unfortunately, using development version of clingo is also prone to trip into bugs (see potassco/clingo#583)

@hainest
Copy link
Copy Markdown
Contributor

hainest commented Nov 19, 2025

I've found that this PR makes the concretizer hang when given a deprecated spec. For example,

$ git checkout develop   # currently 443e1e3e36
$ spack spec [email protected]
<hangs>

$ git checkout 3949a273b19ee9aaf3e0e1637dc09c958d069e9c^
$ spack spec [email protected]
==> Error: failed to concretize `[email protected]` for the following reasons:
     1. Cannot satisfy '[email protected]'
     2. Cannot satisfy '[email protected]'
        required because [email protected] requested explicitly

If I manually update the python package to remove the deprecation, I get

$ git checkout develop
$ spack edit python
-    with default_args(deprecated=True):
+    with default_args(deprecated=False):
$ spack spec [email protected]
 -   [email protected]+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches:=0d98e93,4c24573,ebdca64,f2fd060 platform=linux os=linuxmint21 target=zen3 %c,[email protected]
...

I have confirmed this is not related to #51599 as I'm able to concretize openmpi without issue. It might be similar to #51279, but that issue was filed in early September before this PR was merged.


Update:
I found that this works, as well.

$ git checkout develop
$ spack spec --deprecated [email protected]
==> Warning: using "[email protected]" which is a deprecated version
 -   [email protected]+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches:=0d98e93,4c24573,ebdca64,f2fd060 platform=linux os=linuxmint21 target=zen3 %c,[email protected]
...

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Nov 21, 2025

@hainest Can you check #51612 ? That should solve the performance regressions of this PR, and more. With that I get:

$ time spack solve [email protected]
==> Error: failed to concretize `[email protected]` for the following reasons:
     1. Cannot satisfy '[email protected]' 1(3.14.0)
     2. Cannot satisfy '[email protected]' 4(3.14.0)
        required because [email protected] requested explicitly 

real	0m21,530s
user	0m20,953s
sys	0m0,521s

Without instead:

$ time spack solve [email protected]
^C
==> Error: Keyboard interrupt.
^C

real	1m30,229s
user	1m29,591s
sys	0m0,519s

@hainest
Copy link
Copy Markdown
Contributor

hainest commented Nov 22, 2025

@alalazo I've not checked #51612, but #51611 fixes the issue with the concretizer hanging when using a deprecated spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts core PR affects Spack core functionality dependencies new-variant new-version tests General test capability(ies) WIP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants