3 ms·
I've been looking for a language which provides Software-Transactional-Memory with persistent data structures which fits in 2KB RAM on a microcontroller.
by billsix 9y ago
I've been looking for a language which provides Software-Transactional-Memory with persistent data structures which fits in 2KB RAM on a microcontroller.
- tomsmeding 9y agoI doubt you'll find that quickly. You can't do much in 2kb if you don't want to mutate your data, I think. I don't know much about STM, but I'd wager that uses some extra bookkeeping memory as well. So unless your own memory requirements are really low, this won't work.
- meredydd 9y agoFun fact: Clojure is one of the few languages in which STM is easy! You're right in the general case - STM incurs significant bookkeeping overhead (at least a word per mutable location, usually more), which is one of the reasons it never took off. (The actual reason is the CPU overhead, which slows down memory accesses so much you've lost all the performance you might gain from parallelism.) Clojure sidesteps this by having an incredibly small number of mutable locations. With a persistent data structures, every mutation operation already builds its own private version of the structure, and then atomically changes a pointer to point to the new version. So you've got MVCC built in, and you only need transactional metadata on one location (the ref).