Book Image

Clojure High Performance Programming

By : Shantanu Kumar
Book Image

Clojure High Performance Programming

By: Shantanu Kumar

Overview of this book

<p>Clojure is a young, dynamic, functional programming language that runs on the Java Virtual Machine. It is built with performance, pragmatism, and simplicity in mind. Like most general purpose languages, Clojure’s features have different performance characteristics that one should know in order to write high performance code.<br /><br />Clojure High Performance Programming is a practical, to-the-point guide that shows you how to evaluate the performance implications of different Clojure abstractions, learn about their underpinnings, and apply the right approach for optimum performance in real-world programs.<br /><br />This book discusses the Clojure language in the light of performance factors that you can exploit in your own code.</p> <p>You will also learn about hardware and JVM internals that also impact Clojure’s performance. Key features include performance vocabulary, performance analysis, optimization techniques, and how to apply these to your programs. You will also find detailed information on Clojure's concurrency, state-management, and parallelization primitives.</p> <p>This book is your key to writing high performance Clojure code using the right abstraction, in the right place, using the right technique.</p>
Table of Contents (15 chapters)
Clojure High Performance Programming
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Latency numbers every programmer should know


Hardware and software have progressed over the years. Latencies for various operations put things into perspective. The latency numbers for 2013 are as shown in the following table. (Reproduced with the permission of Aurojit Panda and Colin Scott of Berkeley University: http://www.eecs.berkeley.edu/~rcs/research/interactive_latency.html)

Operation

Time taken as of 2013

L1 cache reference

1 ns (nano second)

Branch mis-predict

3 ns

L2 cache reference

4 ns

Mutex lock/unlock

17 ns

Compress 1KB with Zippy (http://code.google.com/p/snappy/)

2 μs (1000 ns = 1 μs : micro second)

Send 2000 bytes over commodity network

500 ns (that is, 0.5 μs)

SSD random read

16 μs

Roundtrip in same datacenter

500 μs

Read 1,000,000 bytes sequentially from SSD

200 μs

Disk seek

4 ms (1000 μs = 1 ms)

Read 1,000,000 bytes sequentially from disk

2 ms

Packet roundtrip CA to Netherlands

150 ms