万本电子书0元读

万本电子书0元读

顶部广告

Clojure High Performance Programming - Second Edition电子书

售       价:¥

2人正在读 | 0人评论 9.8

作       者:Shantanu Kumar

出  版  社:Packt Publishing

出版时间:2015-09-01

字       数:159.6万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Become an expert at writing fast and high performant code in Clojure 1.7.0 About This Book Enhance code performance by using appropriate Clojure features Improve the efficiency of applications and plan their deployment A hands-on guide to designing Clojure programs to get the best performance Who This Book Is For This book is intended for intermediate Clojure developers who are looking to get a good grip on achieving optimum performance. Having a basic knowledge of Java would be helpful. What You Will Learn Identify performance issues in Clojure programs using different profiling tools Master techniques to achieve numerical performance in Clojure Use Criterium library to measure latency of Clojure expressions Exploit Java features in Clojure code to enhance performance Avoid reflection and boxing with type hints Understand Clojure's concurrency and state-management primitives in depth Measure and monitor performance, and understand optimization techniques In Detail Clojure treats code as data and has a macro system. It focuses on programming with immutable values and explicit progression-of-time constructs, which are intended to facilitate the development of more robust programs, particularly multithreaded ones. It is built with performance, pragmatism, and simplicity in mind. Like most general purpose languages, various Clojure features have different performance characteristics that one should know in order to write high performance code. This book shows you how to evaluate the performance implications of various Clojure abstractions, discover their underpinnings, and apply the right approach for optimum performance in real-world programs. It starts by helping you classify various use cases and the need for them with respect to performance and analysis of various performance aspects. You will also learn the performance vocabulary that experts use throughout the world and discover various Clojure data structures, abstractions, and their performance characteristics. Further, the book will guide you through enhancing performance by using Java interoperability and JVM-specific features from Clojure. It also highlights the importance of using the right concurrent data structure and Java concurrency abstractions. This book also sheds light on performance metrics for measuring, how to measure, and how to visualize and monitor the collected data. At the end of the book, you will learn to run a performance profiler, identify bottlenecks, tune performance, and refactor code to get a better performance. Style and approach An easy-to-follow guide full of real-world examples and self-sufficient code snippets that will help you get your hands dirty with high performance programming with Clojure.
目录展开

Clojure High Performance Programming Second Edition

Table of Contents

Clojure High Performance Programming Second Edition

Credits

About the Author

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

eBooks, discount offers, and more

Questions

1. Performance by Design

Use case classification

The user-facing software

Computational and data-processing tasks

A CPU bound computation

A memory bound task

A cache bound task

An input/output bound task

Online transaction processing

Online analytical processing

Batch processing

A structured approach to the performance

The performance vocabulary

Latency

Throughput

Bandwidth

Baseline and benchmark

Profiling

Performance optimization

Concurrency and parallelism

Resource utilization

Workload

The latency numbers that 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 lesser-used data structures

Complexity guarantee

O(<7) implies near constant time

The concatenation of persistent data structures

Sequences and laziness

Laziness

Laziness in data structure operations

Constructing lazy sequences

Custom chunking

Macros and closures

Transducers

Performance characteristics

Transients

Fast repetition

Performance miscellanea

Disabling assertions in production

Destructuring

Recursion and tail-call optimization (TCO)

Premature end of iteration

Multimethods versus protocols

Inlining

Summary

3. Leaning on Java

Inspecting the equivalent Java source for Clojure code

Creating a new project

Compiling the Clojure sources into Java bytecode

Decompiling the .class files into Java source

Compiling the Clojure source without locals clearing

Numerics, boxing, and primitives

Arrays

Reflection and type hints

An array of primitives

Primitives

Macros and metadata

String concatenation

Miscellaneous

Using array/numeric libraries for efficiency

HipHip

primitive-math

Detecting boxed 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 compiler

Memory organization

HotSpot heap and garbage collection

Measuring memory (heap/stack) usage

Determining program workload type

Tackling memory inefficiency

Measuring latency with Criterium

Criterium and Leiningen

Summary

5. Concurrency

Low-level concurrency

Hardware memory barrier (fence) instructions

Java support and the Clojure equivalent

Atomic updates and state

Atomic updates in Java

Clojure's support for atomic updates

Faster writes with atom striping

Asynchronous agents and state

Asynchrony, queueing, and error handling

Why you should use agents

Nesting

Coordinated transactional ref and state

Ref characteristics

Ref history and in-transaction deref operations

Transaction retries and barging

Upping transaction consistency with ensure

Lesser 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

Future

Promise

Clojure parallelization and the JVM

Moore's law

Amdahl's law

Universal Scalability 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. Measuring Performance

Performance measurement and statistics

A tiny statistics terminology primer

Median, first quartile, third quartile

Percentile

Variance and standard deviation

Understanding Criterium output

Guided performance objectives

Performance testing

The test environment

What to test

Measuring latency

Comparative latency measurement

Latency measurement under concurrency

Measuring throughput

Average throughput test

The load, stress, and endurance tests

Performance monitoring

Monitoring through logs

Ring (web) monitoring

Introspection

JVM instrumentation via JMX

Profiling

OS and CPU/cache-level profiling

I/O profiling

Summary

7. Performance Optimization

Project setup

Software versions

Leiningen project.clj configuration

Enable reflection warning

Enable optimized JVM options when benchmarking

Distinguish between initialization and runtime

Identifying performance bottlenecks

Latency bottlenecks in Clojure code

Measure only when it is hot

Garbage collection bottlenecks

Threads waiting at GC safepoint

Using jstat to probe GC details

Inspecting generated bytecode for Clojure source

Throughput bottlenecks

Profiling code with VisualVM

The Monitor tab

The Threads tab

The Sampler tab

Setting the thread name

The Profiler tab

The Visual GC tab

The Alternate profilers

Performance tuning

Tuning Clojure code

CPU/cache bound

Memory bound

Multi-threaded

I/O bound

JVM tuning

Back pressure

Summary

8. Application Performance

Choosing libraries

Making a choice via benchmarks

Web servers

Web routing libraries

Data serialization

JSON serialization

JDBC

Logging

Why SLF4J/LogBack?

The setup

Dependencies

The logback configuration file

Optimization

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 such as Tomcat and Jetty

HTTP Kit

Aleph

Performance and queueing theory

Little's law

Performance tuning with respect to Little's law

Summary

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部