Scala High Performance Programming
图书信息
| 作者 | Vincent Theron, Michael Diamant |
| 出版社 | Packt Publishing |
| ISBN | 9781786467089 |
| 出版时间 | 2016-05-31 |
| 字数 | 405.7万 |
| 分类 | Packt Publishing,进口书,外文原版书,电脑,网络 |
读书简介
Leverage Scala and the functional paradigm to build performant softwareAbout This Book·Get the first book to explore Scala performance techniques in depth!·Real-world inspired use cases illustrate and support the techniques studied and the language features·This book is written by Vincent Theron and Michael Diamant, software engineers with several years of experience in the high-frequency trading and programmatic advertising industriesWho This Book Is ForThis book assumes a basic exposure to the Scala programming language and the Java Virtual Machine. You should be able to read and understand moderately advanced Scala code. No other knowledge is required.What You Will Learn·Analyze the performance of JVM applications by developing JMH benchmarks and profiling with Flight Recorder·Discover use cases and performance tradeoffs of Scala language features, and eager and lazy collections·Explore event sourcing to improve performance while working with stream processing pipelines·Dive into asynchronous programming to extract performance on multicore systems using Scala Future and Scalaz Task·Design distributed systems with conflict-free replicated data types (CRDTs) to take advantage of eventual consistency without synchronization·Understand the impact of queues on system performance and apply the Free monad to build systems robust to high levels of throughputIn DetailScala is a statically and strongly typed language that blends functional and object-oriented paradigms. It has experienced growing popularity as an appealing and pragmatic choice to write production-ready software in the functional paradigm. Scala and the functional programming paradigm enable you to solve problems with less code and lower maintenance costs than the alternatives. However, these gains can come at the cost of performance if you are not careful.Scala High Performance Programming arms you with the knowledge you need to create performant Scala applications. Starting with the basics of understanding how to define performance, we explore Scala's language features and functional programming techniques while keeping a close eye on performance throughout all the topics.We introduce you as the newest software engineer at a fictitious financial trading company, named MV Trading. As you learn new techniques and approaches to reduce latency and improve throughput, you'll apply them to MV Trading's business problems. By the end of the book, you will be well prepared to write production-ready, performant Scala software using the functional paradigm to solve real-world problems.Style and approachThis step-by-step guide will help you create high performance applications using Scala. Packed with lots of code samples, tips and tricks, every topic is explained in a detailed, easy-to-understand manner.
目录
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
- 502(暂无)
- 人机对话系统(曹均阔,陈国莲)
- 未解之谜(下)(百读)
- 做人要大气(郑斌)
- Guía espa?ol-rumana para una comunicación eficaz(Dana Oprică)
- 大学生初涉职场一本通(第2版)(杨添天 主编)
- 文治帝国:大宋300年的世运与人物【畅销书《一看就停不下来的中国史》作者重磅新书!】(艾公子)
