Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Clojure High Performance Programming
Table of Contents
Clojure High Performance Programming
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Performance by Design
Use case classification
User-facing software
Computational and data-processing tasks
CPU bound
Memory bound
Cache bound
Input/Output (I/O) bound
Online transaction processing (OLTP)
Online analytical processing (OLAP)
Batch processing
Structured approach for performance
Performance vocabulary
Latency
Throughput
Bandwidth
Baseline and benchmark
Profiling
Performance optimization
Concurrency and parallelism
Resource utilization
Workload
Latency numbers every programmer should know
Summary
2. Clojure Abstractions
Non-numeric scalars and interning
Identity, value, and epochal time model
Variables and mutation
Collection types
Persistent data structures
Constructing less-used data structures
Complexity guarantee
Concatenation of persistent data structures
Sequences and laziness
Laziness
Laziness in data structure operations
Constructing lazy sequences
Custom chunking
Macros and closures
Transients
Fast repetition
Performance miscellanea
Disabling assertions in production
Destructuring
Recursion and tail-call optimization (TCO)
Premature end in reduce
Multimethods versus protocols
Inlining
Summary
3. Leaning on Java
Inspect the equivalent Java source for Clojure code
Create a new project
Compile Clojure sources into Java bytecode
Decompile the .class files into Java source
Numerics, boxing, and primitives
Arrays
Reflection and type hints
Array of primitives
Primitives
Macros and metadata
Miscellaneous
Using array/numeric libraries for efficiency
HipHip
primitive-math
Resorting to Java and native code
Proteus – mutable locals in Clojure
Summary
4. Host Performance
The hardware
Processors
Branch prediction
Instruction scheduling
Threads and cores
Memory systems
Cache
Interconnect
Storage and networking
The Java Virtual Machine
The just-in-time (JIT) compiler
Memory organization
HotSpot heap and garbage collection
Measuring memory (heap/stack) usage
Measuring latency with Criterium
Criterium and Leiningen
Summary
5. Concurrency
Low-level concurrency
Hardware memory barrier instructions
Java support and its Clojure equivalent
Atomic updates and state
Atomic updates in Java
Clojure's support for atomic updates
Asynchronous agents and state
Asynchrony, queuing, and error handling
Advantages of agents
Nesting
Coordinated transactional ref and state
Ref characteristics
Ref history and intransaction deref operations
Transaction retries and barging
Upping transaction consistency with ensure
Fewer transaction retries with commutative operations
Agents can participate in transactions
Nested transactions
Performance considerations
Dynamic var binding and state
Validating and watching the reference types
Java concurrent data structures
Concurrent maps
Concurrent queues
Clojure support for concurrent queues
Concurrency with threads

JVM support for threads
Thread pools in the JVM
Clojure concurrency support
Asynchronous execution with Futures
Anticipated asynchronous execution result with promises
Clojure parallelization and the JVM
Moore's law
Amdahl's law
Clojure support for parallelization
pmap
pcalls
pvalues
Java 7's fork/join framework
Parallelism with reducers
Reducible, reducer function, reduction transformation
Realizing reducible collections
Foldable collections and parallelism
Summary
6. Optimizing Performance
A tiny statistics terminology primer
Median, first quartile, and third quartile
Percentile
Variance and standard deviation
Understanding criterium output
Guided performance objectives
Performance testing
Test environment
What to test
Measuring latency
Measuring throughput
Load, stress, and endurance tests
Performance monitoring
Introspection
JVM instrumentation via JMX
Profiling
OS and CPU-cache-level profiling
I/O profiling
Performance tuning
JVM tuning
I/O tuning and backpressure
Summary
7. Application Performance
Data sizing
Reduced serialization
Chunking to reduce memory pressure
Sizing for file/network operations
Sizing for JDBC query results
Resource pooling
JDBC resource pooling
I/O batching and throttling
JDBC batch operations
Batch support at API level
Throttling requests to services
Precomputing and caching
Concurrent pipelines
Distributed pipelines
Applying back pressure
Thread pool queues
Servlet containers like Tomcat and Jetty
HTTP Kit
Performance and queuing theory
Little's Law
Summary
Index
← Prev
Back
Next →
← Prev
Back
Next →