Skip to content

Make :reproducible-resource-limit standards-compliant#1353

Open
bclement-ocp wants to merge 3 commits into
OCamlPro:nextfrom
bclement-ocp:standards-reproducible-resource-limit
Open

Make :reproducible-resource-limit standards-compliant#1353
bclement-ocp wants to merge 3 commits into
OCamlPro:nextfrom
bclement-ocp:standards-reproducible-resource-limit

Conversation

@bclement-ocp

Copy link
Copy Markdown
Collaborator

Fixes #1279

@bclement-ocp bclement-ocp force-pushed the standards-reproducible-resource-limit branch 2 times, most recently from 3855fe3 to 2bcd6f4 Compare May 22, 2026 14:27
@bclement-ocp bclement-ocp requested a review from Halbaroth May 22, 2026 14:27
@bclement-ocp

Copy link
Copy Markdown
Collaborator Author

Hm I actually want to try something a bit better for the implementation of with_steps_limit, let me update the PR.

@bclement-ocp bclement-ocp force-pushed the standards-reproducible-resource-limit branch 2 times, most recently from 4c7e6af to 4b9394e Compare May 22, 2026 15:30
@bclement-ocp

Copy link
Copy Markdown
Collaborator Author

OK this version should be better @Halbaroth — I've moved the call to with_steps_limit down inside solve, which ensures that it's after the call to reset_refs (which calls reset_steps) otherwise weird things would be happening. I've also made sure that with_steps_limit always returns an Error if the limit was reached.

It's not that useful right now because we actually update the internal state of the solver through mutability so we ignore the result at the moment, but I think it should be a more robust way of checking for the limit in a follow-up PR.

@bclement-ocp bclement-ocp force-pushed the standards-reproducible-resource-limit branch from 4b9394e to a46cfcf Compare May 26, 2026 06:20
@bclement-ocp

Copy link
Copy Markdown
Collaborator Author

OK I messed something up apparently, I'll revisit this. Marking as draft for now.

@bclement-ocp bclement-ocp marked this pull request as draft May 26, 2026 07:43
@Halbaroth

Copy link
Copy Markdown
Collaborator

Ok, I was reviewing it.

@bclement-ocp

Copy link
Copy Markdown
Collaborator Author

Apologies — the previous version had a bug (it would raise an uncaught Step_limit_reached on a timeout) and trying to fix that bug broke all the tests :(

@bclement-ocp bclement-ocp force-pushed the standards-reproducible-resource-limit branch from a46cfcf to f60ea5c Compare June 8, 2026 09:31
@bclement-ocp bclement-ocp marked this pull request as ready for review June 8, 2026 09:31
@bclement-ocp

Copy link
Copy Markdown
Collaborator Author

OK, I went with a slightly simpler approach (no atomic token to detect when the limit is reached, because we don't actually need it for now) to just implement what should be needed for the :reproducible-resource-limit behavior from the SMT-LIB standard. I think this works now :)

@hra687261 hra687261 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, other than some typos/superficial remarks.

Comment thread src/lib/util/steps.mli Outdated
Comment thread tests/cram/reproducible-resource-limit.t Outdated
Comment thread src/lib/util/steps.ml Outdated
Comment thread CHANGES.md Outdated
Comment on lines +214 to +216
(* At the moment we ignore the [Error] case here: the unknown reason
should have already been set internally by the solver when the
[Util.Step_limit_reached] exception was raised. *)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Which error case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Old comment from a previous implementation, I'll remove it.

Comment on lines +217 to +218
let ( let& ) f scope = f ~scope in
let& () = Steps.with_step_limit limit in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The operator seems to be only used once (right after its declaration), I don't know if it's worth keeping it, inlining it would make the code more readable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It'd increase indentation though ;)

It is the "resource binding" operator from memprof-limits — I think it is useful to have a way to explicitly say "we are creating a scope where resources (here a fixed number of steps) are acquired" rather than a simple function call, but did not want to put it in a module of its own for a single use. I can add a short documentation to explain this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, I was not familiar with it, I agree it is useful, I don't know if there is a better place to put it that within the code. And yes a comment would be helpful :)

info ["S"; "steps-bound"] ~docv ~doc) in

let reproducible_resource_limit =
let doc = "Set the reproducible resource limit." in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe give a bit more details here? (e.g. that what we measure is the number of steps and that if the limit is 0 then there is no limit)

bclement-ocp and others added 2 commits June 19, 2026 11:31
Co-authored-by: Hichem R. A. <hra687261@gmail.com>
Co-authored-by: Hichem R. A. <hra687261@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make reproducible-resource-limit use steps

3 participants