emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sqlite3


From: Qiantan Hong
Subject: Re: sqlite3
Date: Mon, 6 Dec 2021 12:57:08 +0000

> Which still raises the other important question of how to serialize
> data, and how to do it better than `read' and `print'.
I agree that this is the real question, and my crude answer would
be to store an append-only log of deltas.
In fact I think if we can do this we don’t even need (g)dbm,
just storing the log in plain s-exp will be performant enough.

The detail gets messier. If we have a hash table whose value
is not mutable, we only need to append a log entry every
persistent-puthash.

What if the values are mutated? I can see two options:
1. A persistent hash table can be declared as :value-mutable t.
   In such case it will make an internal copy of its values
   (using COPY-TREE), and we provide a
   (PERSISTENT-HASH-CHECKPOINT &optional KEY),
   which compares the live value of KEY and “internally cached”
   value of KEY, store the delta if they’re different.
   (If KEY is not provided, do it for every keys)
   
   Cons: potentially doubled memory usage, and potentially
   slow checkpointing.

2. A very radical approach (I consider it probably the “right” way).
    Add a cell-mutated-hook to Emacs Lisp VM so that one
    can attach an “observer” to a slot of a datum in the memory.
    To avoid the performance nightmare, we probably need to have
    two disjoint kinds of watched and unwatched datum. 
    Basically, add an watched counterpart to every Elisp VM type we
    currently have, and implementation of the original unwatched type
    is unchanged so they can hopefully be accessed without any overhead.


Best,
Qiantan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]