万本电子书0元读

万本电子书0元读

顶部广告

Rust High Performance电子书

售       价:¥

29人正在读 | 0人评论 9.8

作       者:Iban Eguia Moraza

出  版  社:Packt Publishing

出版时间:2018-03-28

字       数:36.5万

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

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

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Find bottlenecks, identify the proper algorithm to use, optimize performance, and create really efficient Rust applications About This Book ? Understand common performance pitfalls and improve the performance of your applications. ? Get to grips with parallel programming and multithreading with Rust. ? Learn metaprogramming in Rust. Who This Book Is For This book is for Rust developers keen to improve the speed of their code or simply to take their skills to the next level. What You Will Learn ? Master tips and tricks to make your code faster. ? Learn how to identify bottlenecks in your Rust applications ? Discover how to profile your Rust software. ? Understand the type system to create compile-time optimizations. ? Master the borrow checker . ? Learn metaprogramming in Rust to avoid boilerplate code. ? Discover multithreading and work stealing in Rust. ? Understand asynchronous programming in Rust. In Detail At times, it is difficult to get the best performance out of Rust. This book teaches you to optimize the speed of your Rust code to the level of languages such as C/C++. You'll understand and fix common pitfalls, learn how to improve your productivity by using metaprogramming, and speed up your code by concurrently executing parts of it safely and easily. You will master the features of the language which will make you stand out and use them to really improve the efficiency of your algorithms The book begins with a gentle introduction to help you identify bottlenecks when programming in Rust. We highlight common performance pitfalls, along with strategies to detect and resolve these issues early. We move on to mastering Rust's type system, which will enable us to create impressive optimizations in both performance and safety at compile time. You will then learn how to effectively manage memory in Rust, mastering the borrow checker. We move on to measuring performance and you will see how this affects the way you write code. Moving ahead, you will perform metaprogramming in Rust to boost the performance of your code and your productivity. You will finally learn parallel programming in Rust, which enables efficient and faster execution by using multithreading and asynchronous programming. Style and approach You'll embark on a learning journey that will teach about you deep-core concepts in the Rust language. Learning those concepts—such as understanding the borrow checker—will make you competent to write more efficient Rust code. To learn those core concepts, you'll perform practical work and see for yourself how specific patterns improve the performance of your code.
目录展开

Title Page

Copyright and Credits

Rust High Performance

Dedication

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Conventions used

Get in touch

Reviews

Common Performance Pitfalls

Asking the Rust compiler about performance

Optimizations

Build configuration

Optimization level

Debug information

Link-time optimizations

Debug assertions

Panic behavior

Runtime library paths

Translation issues

Indexing degradations

Using iterators

Iterator adaptors

Real-life example

Specialized adaptors

Interaction between adaptors

Itertools

Borrowing degradations

Cyclomatic complexity

Summary

Extra Performance Enhancements

Compile-time checks

Sequential state machines

Complex state machines

Real-life type system check example

Extra performance tips

Using closures to avoid runtime evaluation

Unstable sorting

Map hashing

Perfect hash functions

Standard library collections

Sequences

Maps

Sets

Summary

Memory Management in Rust

Mastering the borrow checker

Allocations

Mutability, borrowing, and owning

Lifetimes

Memory representation

Alignment

Complex enumerations

Unions

Shared pointers

The cell module

Cells

RefCell

The rc module

Summary

Lints and Clippy

Using Rust compiler lints

Lints

Avoiding anonymous parameters

Avoiding heap allocated box pointers

Avoiding missing implementations

Enforcing documentation

Pointing out trivial casts

Linting unsafe code blocks

Unused lints

Variant size differences

Lint groups

Clippy

Installation

Configuration

Lints

Casting

Bad practice

Performance lints

Unwraps

Shadowing

Integer overflow

Lint groups

Summary

Profiling Your Rust Application

Understanding the hardware

Understanding how the CPU works

Speeding up memory access with the cache

Cache misses

How can you fix it?

Cache invalidation

CPU pipeline

Branch prediction

The relevance of branch prediction for our code

Profiling tools

Valgrind

Callgrind

Cachegrind

OProfile

Summary

Benchmarking

Selecting what to benchmark

Benchmarking in nightly Rust

Benchmarking in stable Rust

Continuous integration for benchmarks

Travis-CI integration

Benchmark statistics with Criterion

Summary

Built-in Macros and Configuration Items

Understanding attributes

Trait derivations

Crate features

Configuration attributes

Macros

Console printing

String formatting

Compilation environment

Loading byte arrays and strings at compile time

Code paths

Checking preconditions and postconditions

Others

Nightly Rust

Conservative trait return

Constant functions

Inline assembly and naked functions

Using bigger integers

Single instruction multiple data

Allocation API

Compiler plugins

Summary

Must-Have Macro Crates

Working with external data

Data serialization and deserialization

Serializing and deserializing complex structures

Parsing byte streams

Learning about useful small crates

Creating lazily evaluated statics

Avoiding boilerplate code for the builder pattern

Managing errors

Logging efficiently in Rust

Creating command-line interfaces

Using Rust for web development

Creating extremely efficient templates

Connecting with a database

Creating a complete web server

Summary

Creating Your Own Macros

Creating your own standard macros

Macro variants

Complex macros

Creating procedural macros

Implementing a simple trait

Implementing complex derivations

Implementing getters

Implementing setters

Metaprogramming in nightly Rust

Understanding compiler plugins

Declarative macros

Summary

Multithreading

Concurrency in Rust

Understanding the Send and Sync traits

The Send trait

The Sync trait

Other types of concurrency in Rust

Understanding multithreading

Creating threads

Panicking in Rust

Moving data between threads

The move keyword

Sharing data between threads

Channels between threads

Multithreading crates

Non-blocking data structures

Scoped threads

Thread pooling

Parallel iterators

Summary

Asynchronous Programming

Introduction to asynchronous programming

Understanding I/O in the CPU

Getting the kernel to control the I/O

Asynchronous programming from the programmer's perspective

Understanding futures

Future combinators

Asynchronous I/O in Rust

Creating Tokio codecs

WebSockets in Rust

Understanding the new Generators

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部