Octachron / codept

Contextual Ocaml DEPendencies Tool: alternative ocaml dependency analyzer
Other
59 stars 10 forks source link

Is there a way to save solver state? #30

Closed jonahbeckford closed 4 months ago

jonahbeckford commented 6 months ago

Category: non-urgent optimization question

I am using codept as the dependency analyzer for an upcoming OCaml-based scripting framework called "DkCoder" [1]. Very excellent; thanks for codept!

DkCoder distinguishing features are:

  1. It comes with a simple package manager so you can use yours or other people's scripts.
  2. It work directly from vscode without having first installed OCaml.
  3. (Later) You should be able to export to a dune based project if you want to create native OCaml executables.

That first feature ("simple package manager") is where codept plays a part. Today I am using codept to analyze script code like:

let () = UnknownPackage_Std.Sound.say_hello ()
let () = Xyz.Example300.hi ()

to see that UnknownPackage_Std and Xyz are unknown module references.

DkCoder uses naming conventions to know that UnknownPackage_Std is an external package. Now that I know that UnknownPackage_Std is an external package, I can download that package (or perhaps add it to the includes if it is available locally) and continue the analysis until no more external packages need to be downloaded.

Since I'm just getting used to working with codept, I am using the codept_core library and am just restarting the Analysis.main function whenever I resolve (ie. download/include) an external package.

I think that throws away all of the solver state, right? What is the cleanest way to not throw away prior state?

(I'm also familiar with the codept signature files; I prepare them offline so the analysis resolves bundled DkCoder packages like cmdliner and lwt)

[1] It is free but some of it uses non-OSI binary downloads. But full source is available to anyone doing PL research (if you want it).

Octachron commented 6 months ago

Indeed, calling main redoes the whole computation and reads.

Unfortunately, there are no good entry points to restart a computation from a solver state yet, but this is rather easy to fix. I will try to have a look next week.

jonahbeckford commented 5 months ago

I'm trying to use codept at a lower level by reimplementing the let rec solve_harder ancestors state = ... function.

If successful I may not need this issue so please don't take any time on this yet.

jonahbeckford commented 4 months ago

It is much better to use codept as a library in my use case. So this issue is unnecessary ... and I suspect others who needed to re-use the solver state should just be implementing their own solve_harder loop.

Closing. Thx.