Skip to content

provide a persistent cache datastructure #516

@redianthus

Description

@redianthus

Hi!

I've been experimenting again with adding a global cache in Owi (because I think measuring hashconsing performances without it makes less sense). I think it would be very nice if Smtml could provide a second cache implementation that would be persistent (immutable). Currently, I have to use the cache like this :

let cache = Smtml.Cache.Strong.create 64

let cache_mutex = Mutex.create ()

let check (S (solver_module, s)) pc =
  let cached =
    Mutex.protect cache_mutex (fun () -> Smtml.Cache.Strong.find_opt cache pc)
  in
  match cached with
  | Some sat -> sat
  | None ->
    let module Solver = (val solver_module) in
    let sat = Solver.check_set s pc in
    Mutex.protect cache_mutex (fun () -> Smtml.Cache.Strong.replace cache pc sat);
    sat

Whereas, using a persistent cache I could 1. use an Atomic.t instead of a Mutex.t 2. avoid the first lock (i.e. when I'm simply reading the cache). I'm not sure it would be better, but that may very well be the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions