[HN Gopher] Software Transactional Memory (1997)
___________________________________________________________________
Software Transactional Memory (1997)
Author : luu
Score : 15 points
Date : 2022-07-26 20:34 UTC (1 days ago)
(HTM) web link (dl.acm.org)
(TXT) w3m dump (dl.acm.org)
| arghnoname wrote:
| GCC supports code generation that will call into several
| different software transactional memory (STM) engines. It's not
| difficult to write your own engine that is called instead of a
| default version.
|
| What this basically does is generate multiple versions of
| functions that can be called both in and not in a transaction.
| Functions that may be called in a transaction have to be side-
| effect free (i.e., no system calls, recursively). The modified
| functions run code for each line of memory read or written so the
| STM engine can decide what to do with it (e.g., reads can be
| redirected to other locations, writes can be used to dirty memory
| or redirected to a scratch location).
|
| There are different trade-offs for efficiency, conflicts, etc.
| For instance, if each transaction begin just started with a
| global exclusive lock it would be correct, simple, and you'd
| never get conflicts, but just serializes everything. There are
| trade-offs.
|
| Languages with more rigid semantics and a propensity towards
| immutability would require less annotation. The GCC version
| generates these invocations for engine functions on most loads
| and stores. As you'd imagine, it's pretty expensive as is and
| basically is not used as a generic method of concurrency control
| for this reason.
| anonymousDan wrote:
| Interesting, do you have a link to the documentation for this
| (or even a paper describing the design)? Does Clang/LLVM have
| something similar? I wonder would adding STM to Rust be more
| practical in terms of performance (or does the question even
| make sense given it already guarantees data race freedom)?
| arghnoname wrote:
| There's an Intel ABI specification that GCC closely follows.
| The gcc implementation is called libitm and their
| specification is just listed as a diff of intel's
| specification.
|
| Here is gcc's doc on libitm
| https://gcc.gnu.org/onlinedocs/libitm/ Here is intel's
| document (much more useful): https://gcc.gnu.org/wiki/Transac
| tionalMemory?action=AttachFi...
|
| I'm not sure what the support story is like on clang.
| gpderetta wrote:
| A few years ago it seemed that every cpu architecture was
| going to get hardware transactional memory acceleration.
| SPARC had it, POWER had it, even Intel added it. A
| transactional memory proposal for C++ made it into a
| Technical Report, it got implemented in GCC and it seemed to
| be ready to be merged into the standard.
|
| Then I'm not sure what happened, things seem to have run out
| of steam, Intel never managed to make its HTM to work well
| and it unofficially deprecated it and generally TM went out
| of fashion. The TR is still there and gets minor updates, but
| I haven't heard about any push to merge it.
| CMCDragonkai wrote:
| I've been working on a JS database to support optimistic
| concurrency control. I did some research and arrived on 2
| seemingly related concepts but from independent research lines.
| Software transactional memory in functional programming/Haskell
| land versus snapshot isolation in database research.
|
| After reading them both, I asked this unanswered question on SO:
| https://stackoverflow.com/q/72084071/582917. My theory is that
| STM is the same as SI, but most SI database implementations don't
| just do value comparisons, but actually check a logical
| timestamp. This is probably done for performance reasons as
| databases handle larger pieces of data than functions would when
| using STM.
|
| Along the way I also discovered SSI serializable snapshot
| isolation but it isn't yet available in rocksdb but cockroachdb
| apparently has a fork of rocksdb with it but I couldn't find it.
|
| Anyway the db library which wraps around rocksdb is available to
| be used embedded in any nodejs program at
| https://github.com/MatrixAI/js-db.
| anonymousDan wrote:
| These are apples and oranges. Snapshot isolation is a
| consistency guarantee, STM is a concurrency control mechanism.
| STM can be used to provide snapshot isolation (or stronger
| guarantees such as linearizability).
| hardwaresofton wrote:
| No modern language I know of beats Haskell's support for STM:
|
| https://wiki.haskell.org/Software_transactional_memory
|
| As I always say, Haskell is the Mercedes of programming
| languages.
___________________________________________________________________
(page generated 2022-07-27 23:01 UTC)