---
# System prepended metadata

title: Solver-service re-design

---

# Solver-service re-design

```mermaid
graph LR
    A[A.Opam commits\nupdate\nlock]--->|Resquest| B[Cache of \nResponse]
    B[Cache of \nResponse] --->|Response| A[Opam commits\nupdate\nlock]

    C[Verify \nto \nresolve] ---> |Response|B[Cache \nof \nResponse]
    B[Cache \nof \nResponse] --->|Resquest| C[Verify \nto \nresolve]

    C[Verify \nto \nresolve] -->|Resquest| D[Distribute\nby\nplatform\nto worker-processes]
    C[Verify \nto \nresolve] --> GG[Get the names of\nthe opam urls packages]
    GG[Get the names of\nthe opam urls packages] --> D[Distribute\nby\nplatform\nto worker-processes]
    D[Distribute\nby\nplatform\nto\n workers] --> |Response|C[Verify \nto \nresolve]
    
  
    D --> H[wker1]
    D --> E[wker2]
    D --> F[wker3]
    D -->.......
    D --> G[wker n]
```

- The first stage use a lock to update all opam url commits in the request if there's a new hash commit.
- The second stage, try to get the a result from the cache. Each new response of a request will be stored.
- The third stage is important to improve the efficiency of the `Solver-service`. This stage is trying to verify if there's a change about the dependencies in the request that are related to the change in the opam urls commits. An example, if there is a new hash of [opam-repository](https://github.com/ocaml/opam-repository) and the hash bring changes which are not related to the dependencies or request, so resolving is unnecessary for the request if there's already a response in the cache. It's remove, looking for the oldest commits after a resolve to prevent the cache of builds in the pipeline of a CI. To be little bit concrete here this command will be used `git -C {clone-path} diff {old-hash} {new-hash} --- packages/{name}` to know if the changes implies a package. To be more efficient, the stage can have caching also.
- The last stage is to get all the opam urls packages, when the request is distributed to workers, those packages also are sent to the workers. The packages is sent by their opam urls hash commit in order to facilitate a caching.  A mechanism could be added to manage the workers like when a job(request) is canceled, the process could be killed at the time.