Hi all,
I migrated MemStore (https://github.com/interwolf/MemStore, an ocaml version memcached in its first stage) onto Mirage and it works fine (on 4.00.1+mirage-xen) for small data size. However, when I store large data, e.g., 1M kv pairs, it becomes slower and slower. I believe it is because I use a large data structure to store the kv, and when a new kv pair is set the whole data structure is copied (as shown below).
********************************
module OrdKey = struct
type t = string
let compare = Pervasives.compare
end
module KVMap = Map.Make(OrdKey)
let kv = ref KVMap.empty
……
(* each time when a new kv pair is set, the following is invoked *)
kv := KVMap.add !key_in_process line !kv
**********************************
I have no idea how to copy just the new kv, instead of the whole kv storage, when a new kv is set. Does anyone have some hint? Or there are example code for similar problems in the ocaml world?
Thank you all!
Yiming