售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Scala High Performance Programming
Scala High Performance Programming
Credits
About the Authors
About the Reviewer
www.PacktPub.com
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
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. The Road to Performance
Defining performance
Performant software
Hardware resources
Latency and throughput
Bottlenecks
Summarizing performance
The problem with averages
Percentiles to the rescue
Collecting measurements
Using benchmarks to measure performance
Profiling to locate bottlenecks
Pairing benchmarks and profiling
A case study
Tooling
Summary
2. Measuring Performance on the JVM
A peek into the financial domain
Unexpected volatility crushes profits
Reproducing the problem
Throughput benchmark
Latency benchmark
The first latency benchmark
The coordinated omission problem
The second latency benchmark
The final latency benchmark
Locating bottlenecks
Did I test with the expected set of resources?
Was the system environment clean during the profiling?
Are the JVM's internal resources performing to expectations?
Where are the CPU bottlenecks?
What are the memory allocation patterns?
Trying to save the day
A word of caution
A profiling checklist
Taking big steps with microbenchmarks
Microbenchmarking the order book
Summary
3. Unleashing Scala Performance
Value classes
Bytecode representation
Performance considerations
Tagged types - an alternative to value classes
Specialization
Bytecode representation
Performance considerations
Tuples
Bytecode representation
Performance considerations
Pattern matching
Bytecode representation
Performance considerations
Tail recursion
Bytecode representation
Performance considerations
The Option data type
Bytecode representation
Performance considerations
Case study – a more performant option
Summary
4. Exploring the Collection API
High-throughput systems – improving the order book
Understanding historical trade-offs – list implementation
List
TreeMap
Adding limit orders
Canceling orders
The current order book – queue implementation
Queue
Improved cancellation performance through lazy evaluation
Set
Benchmarking LazyCancelOrderBook
Lessons learned
Historical data analysis
Lagged time series returns
Vector
Data clean up
Handling multiple return series
Array
Looping with the Spire cfor macro
Summary
5. Lazy Collections and Event Sourcing
Improving the client report generation speed
Diving into the reporting code
Using views to speed up report generation time
Constructing a custom view
Applying views to improve report generation performance
View caveats
SeqView extends Seq
Views are not memoizers
Zipping up report generation
Rethinking reporting architecture
An overview of Stream
Transforming events
Building the event sourcing pipeline
Streaming Markov chains
Stream caveats
Streams are memoizers
Stream can be infinite
Summary
6. Concurrency in Scala
Parallelizing backtesting strategies
Exploring Future
Future and crazy ideas
Future usage considerations
Performing side-effects
Blocking execution
Handling failures
Hampering performance through executor submissions
Handling blocking calls and callbacks
ExecutionContext and blocking calls
Asynchronous versus nonblocking
Using a dedicated ExecutionContext to block calls
Using the blocking construct
Translating callbacks with Promise
From callbacks to a Future-based API
Combining Future with Promise
Tasked with more backtest performance improvements
Introducing Scalaz Task
Creating and executing Task
Asynchronous behavior
The execution model
Modeling trading day simulations with Task
Wrapping up the backtester
Summary
7. Architecting for Performance
Distributed automated traders
A glimpse into distributed architectures
The first attempt at a distributed automated trader
Introducing CRDTs
The state-based increase-only counter
The operation-based increase-only counter
CRDTs and automated traders
When the balance is not enough
A new CRDT - the grow-only set
Free trading strategy performance improvements
Benchmarking the trading strategy
The danger of unbounded queues
Applying back pressure
Applying load-control policies
Rejecting work
Interrupting expensive processing
Free monads
Describing a program
Building an interpreter
Benchmarking the new trading strategy pipeline
A Task interpreter
Exploring free monads further
Summary
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜