Clojure High Performance Programming Second Edition by Kumar Shantanu
Author:Kumar, Shantanu
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2015-09-28T16:00:00+00:00
Upping transaction consistency with ensure
Clojure's transactional consistency is a good balance between performance and safety. However, at times, we may need the Serializable consistency in order to preserve the correctness of the transaction. Concretely, in the face of the transaction retries, when a transaction's correctness depends on the state of a ref, in the transaction, wherein the ref is updated simultaneously in another transaction, we have a condition called "write skew". The Wikipedia entry on the write skew, https://en.wikipedia.org/wiki/Snapshot_isolation, describes it well, but let's see a more concrete example. Let's say we want to design a flight simulation system with two engines, and one of the system level constraints is not to switch off both engines at the same time. If we model each engine as a ref, and certain maneuvers do require us to switch off an engine, we must ensure that the other engine is on. We can do it with ensure. Usually, ensure is required when maintaining a consistent relationship (invariants) across the refs is necessary. This cannot be ensured by the validator functions, because they do not come into play until the transaction commits. The validator functions will see the same value hence cannot help.
The write-skew can be solved using the namesake ensure function that essentially prevents a ref from modification by other transactions. It is similar to a locking operation, but in practice, it provides better concurrency than the explicit read-and-update operations, when the retries are expensive. Using ensure is quite simple—(ensure ref-object). However, it may be performance-wise expensive, due to the locks it holds during the transaction. Managing performance with ensure involves a trade-off between the retry latency, and the lost throughput due to the ensured state.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Ajax | Assembly Language Programming |
Borland Delphi | C & C++ |
C# | CSS |
Compiler Design | Compilers |
DHTML | Debugging |
Delphi | Fortran |
Java | Lisp |
Perl | Prolog |
Python | RPG |
Ruby | Swift |
Visual Basic | XHTML |
XML | XSL |
Deep Learning with Python by François Chollet(12528)
Hello! Python by Anthony Briggs(9873)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9763)
The Mikado Method by Ola Ellnestam Daniel Brolund(9754)
Dependency Injection in .NET by Mark Seemann(9300)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8264)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7748)
Grails in Action by Glen Smith Peter Ledbrook(7673)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7523)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(6767)
Microservices with Go by Alexander Shuiskov(6536)
Practical Design Patterns for Java Developers by Miroslav Wengner(6428)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6406)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6385)
Angular Projects - Third Edition by Aristeidis Bampakos(5795)
The Art of Crafting User Stories by The Art of Crafting User Stories(5320)
NetSuite for Consultants - Second Edition by Peter Ries(5260)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5081)
Kotlin in Action by Dmitry Jemerov(5025)
