Skip to content

solver: remove internal errors in the solver#51642

Merged
haampie merged 1 commit into
spack:developfrom
alalazo:solver/remove-internal-errors
Jan 8, 2026
Merged

solver: remove internal errors in the solver#51642
haampie merged 1 commit into
spack:developfrom
alalazo:solver/remove-internal-errors

Conversation

@alalazo

@alalazo alalazo commented Nov 25, 2025

Copy link
Copy Markdown
Member

internal_error facts are parsed from concretize.lp, which happens hundreds of times during unit tests. Since they don't improve the error message substantially, just remove them to get faster CI.

Results on:

Before

Screenshot from 2025-11-25 17-13-36

After
Screenshot from 2025-11-25 17-15-51

@alalazo alalazo requested review from becker33 and haampie November 25, 2025 16:17
@haampie

haampie commented Nov 25, 2025

Copy link
Copy Markdown
Member

Not noticeable in github actions

@alalazo alalazo force-pushed the solver/remove-internal-errors branch from d36d9c6 to 0eaa8eb Compare November 28, 2025 11:55
@alalazo alalazo marked this pull request as ready for review December 9, 2025 09:37
@alalazo

alalazo commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

@becker33 Are you fine with this? Internal errors are parsed from concretize.lp so many times during unit tests... I would be for removing them, since the error message is unintelligible to users anyhow, e.g.:

"Only nodes and virtual_nodes can have version satisfaction"

@becker33

becker33 commented Dec 9, 2025

Copy link
Copy Markdown
Member

I really don't think this is a good idea. The error messages aren't good, but they're the only thing that tells us anything about which constraint is being violated. The first thing I do with a concretizer error that doesn't report one is make sure to add more of them until I start seeing one of them, and then I know where to start debugging.

@alalazo

alalazo commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

The first thing I do with a concretizer error that doesn't report one is make sure to add more of them until I start seeing one of them, and then I know where to start debugging

You can also add error facts if you're debugging. I don't see a lot of differences between:

:- <constraint>, internal_error("<debug msg>").

and:

error(10, "<debug msg>") :- <constraint>.

In any case, concretize.lp is parsed a lot of times during unit tests, and we should avoid that. I guess you also agree that for users, these messages are equally bad as a fatal error, right?

@becker33

becker33 commented Dec 9, 2025

Copy link
Copy Markdown
Member

Yeah I agree these errors don't tell a user anything useful. But I disagree that it makes them useless. It's much better to give the user "something bad happened, here's the string to give the developers so they can figure it out" than to give them "nope, bad things happened. go away". But that's besides the point, I think those strings are really there for us to help with debugging and I'm surprised other folks don't find them essential to that effort.

@alalazo

alalazo commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

I think those strings are really there for us to help with debugging and I'm surprised other folks don't find them essential to that effort.

Never used internal errors to debug ASP, to be honest.

Also, I'm not suggesting to tell users to go away 🙂 I'm just saying that between:

$ spack solve zlib-ng
==> Error: Spack concretizer internal error. Please submit a bug report at https://github.com/spack/spack and include the command and environment if applicable.

and:

$ spack solve zlib-ng
==> Error: Spack concretizer internal error. Please submit a bug report and include the command, environment if applicable and the following error message.
    zlib-ng is unsatisfiable, errors are:
    internal_error("Only nodes and virtual_nodes can have version satisfaction")

there isn't a lot of added value for users.

In any case we should avoid parsing concretize.lp over and over during unit tests. Am I the only one seeing the 30s speed-up when running the tests locally, like in the description?

@alalazo

alalazo commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

I'll submit a competing PR to cache the symbols, but I'd like to get rid of this part of the code - it's also one of the things that are different from the solve done within Spack and outside of Spack.

@haampie

haampie commented Dec 10, 2025

Copy link
Copy Markdown
Member

I think those strings are really there for us to help with debugging and I'm surprised other folks don't find them essential to that effort.

Am I the only one seeing the 30s speed-up when running the tests locally, like in the description?

I'm getting a 10% speedup of unit tests locally. That's saving me more time than those internal errors when troubleshooting concretization bug reports. To me the time saved from day to day is more important.

@alalazo alalazo force-pushed the solver/remove-internal-errors branch from 38a72d9 to eb89b99 Compare December 16, 2025 07:38
@alalazo

alalazo commented Dec 16, 2025

Copy link
Copy Markdown
Member Author

I just re-run unit tests locally against 6a44ce5 using:

$ pytest -n 8 --dist=loadfile

develop

3 failed, 5839 passed, 128 skipped, 3 xfailed, 468 warnings in 359.93s (0:05:59) 

This PR

3 failed, 5839 passed, 128 skipped, 3 xfailed, 468 warnings in 288.13s (0:04:48)

So, for me locally it's runtime reduced by 20% on this specific pair of runs.1

Footnotes

  1. The 3 failed unit tests are expected in elf.py given the first gcc I have in PATH.

@alalazo alalazo force-pushed the solver/remove-internal-errors branch 2 times, most recently from 3075753 to 2e5f3bc Compare December 23, 2025 15:48

@becker33 becker33 left a comment

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.

There are several methods on the Result class that should be removed as part of this PR.

  • format_cores
  • format_minimal_cores
  • minimal_cores
  • minimize_core
  • format_core

We should also remove the assumptions field from the SpackSolverSetup class, and the assumptions key from the solve_kwargs dict.

We can probably also remove the cores and control fields from the Result class, as well as all the code for managing and setting them.

@alalazo alalazo force-pushed the solver/remove-internal-errors branch from 2e5f3bc to d6f374e Compare December 31, 2025 10:07
@alalazo alalazo requested a review from becker33 January 2, 2026 17:11
@alalazo

alalazo commented Jan 5, 2026

Copy link
Copy Markdown
Member Author

@becker33 Done. Ready for a re-review.

`internal_error` facts are parsed from `concretize.lp`,
which happens hundreds of times during unit tests.

Since they don't improve the error message substantially,
just remove them to get faster CI.

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
@alalazo alalazo force-pushed the solver/remove-internal-errors branch from d6f374e to b74e605 Compare January 7, 2026 18:50
@haampie haampie merged commit f86ad38 into spack:develop Jan 8, 2026
60 of 62 checks passed
@alalazo alalazo deleted the solver/remove-internal-errors branch January 8, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants