Tải bản đầy đủ (.pdf) (7 trang)

1430244585 prone 6938

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.43 MB, 7 trang )

THE EXPERT’S VOICE® IN .NET


For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.


Contents at a Glance
Foreword....................................................................................................................... xv
About the Authors........................................................................................................ xvii
About the Technical Reviewers.................................................................................... xix
Acknowledgments........................................................................................................ xxi
Introduction................................................................................................................ xxiii
■■Chapter 1: Performance Metrics..................................................................................1
■■Chapter 2: Performance Measurement. .......................................................................7
■■Chapter 3: Type Internals...........................................................................................61
■■Chapter 4: Garbage Collection. ..................................................................................91
■■Chapter 5: Collections and Generics........................................................................145
■■Chapter 6: Concurrency and Parallelism..................................................................173
■■Chapter 7: Networking, I/O, and Serialization..........................................................215
■■Chapter 8: Unsafe Code and Interoperability. ..........................................................235
■■Chapter 9: Algorithm Optimization. .........................................................................259
■■Chapter 10: Performance Patterns...........................................................................277
■■Chapter 11: Web Application Performance. .............................................................305
Index............................................................................................................................335

v


Introduction


This book has come to be because we felt there was no authoritative text that covered all three areas relevant to
.NET application performance:


Identifying performance metrics and then measuring application performance to verify
whether it meets or exceeds these metrics.



Improving application performance in terms of memory management, networking, I/O,
concurrency, and other areas.



Understanding CLR and .NET internals in sufficient detail to design high-performance
applications and fix performance issues as they arise.

We believe that .NET developers cannot achieve systematically high-performance software solutions without
thoroughly understanding all three areas. For example, .NET memory management (facilitated by the CLR
garbage collector) is an extremely complex field and the cause of significant performance problems, including
memory leaks and long GC pause times. Without understanding how the CLR garbage collector operates,
high-performance memory management in .NET is left to nothing but chance. Similarly, choosing the proper
collection class from what the .NET Framework has to offer, or deciding to implement your own, requires
comprehensive familiarity with CPU caches, runtime complexity, and synchronization issues.
This book’s 11 chapters are designed to be read in succession, but you can jump back and forth between topics
and fill in the blanks when necessary. The chapters are organized into the following logical parts:


Chapter 1 and Chapter 2 deal with performance metrics and performance measurement.
They introduce the tools available to you to measure application performance.




Chapter 3 and Chapter 4 dive deep into CLR internals. They focus on type internals
and the implementation of CLR garbage collection—two crucial topics for improving
application performance where memory management is concerned.



Chapter 5, Chapter 6, Chapter 7, Chapter 8, and Chapter 11 discuss specific areas of the
.NET Framework and the CLR that offer performance optimization opportunities—using
collections correctly, parallelizing sequential code, optimizing I/O and networking
operations, using interoperability solutions efficiently, and improving the performance of
Web applications.



Chapter 9 is a brief foray into complexity theory and algorithms. It was written to give you
a taste of what algorithm optimization is about.



Chapter 10 is the dumping ground for miscellaneous topics that didn’t fit elsewhere in the
book, including startup time optimization, exceptions, and .NET Reflection.

Some of these topics have prerequisites that will help you understand them better. Throughout the course of the
book we assume substantial experience with the C# programming language and the .NET Framework, as well as
familiarity with fundamental concepts, including:

xxiii



■ Introduction



Windows: threads, synchronization, virtual memory



Common Language Runtime (CLR): Just-In-Time (JIT) compiler, Microsoft Intermediate
Language (MSIL), garbage collector



Computer organization: main memory, cache, disk, graphics card, network interface

There are quite a few sample programs, excerpts, and benchmarks throughout the book. In the interest of not
making this book any longer, we often included only a brief part—but you can find the whole program in the
companion source code on the book’s website.
In some chapters we use code in x86 assembly language to illustrate how CLR mechanisms operate or to
explain more thoroughly a specific performance optimization. Although these parts are not crucial to the book’s
takeaways, we recommend dedicated readers to invest some time in learning the fundamentals of x86 assembly
language. Randall Hyde’s freely available book “The Art of Assembly Language Programming”
( is an excellent resource.
In conclusion, this book is full of performance measurement tools, small tips and tricks for improving minor
areas of application performance, theoretical foundations for many CLR mechanisms, practical code examples,
and several case studies from the authors’ experience. For almost ten years we have been optimizing applications
for our clients and designing high-performance systems from scratch. During these years we trained hundreds of
developers to think about performance at every stage of the software development lifecycle and to actively seek

opportunities for improving application performance. After reading this book, you will join the ranks of
high-performance .NET application developers and performance investigators optimizing existing applications.
Sasha Goldshtein
Dima Zurbalev
Ido Flatow

xxiv


About the Technical Reviewers
Todd Meister has been working in the IT industry for over fifteen years.
He’s been a Technical Editor on over 75 titles ranging from SQL Server to
the .NET Framework. Besides technical editing titles he is the Senior IT
Architect at Ball State University in Muncie, Indiana. He lives in central
Indiana with his wife, Kimberly, and their five incisive children.

Fabio Claudio Ferracchiati is a prolific writer and technical reviewer on cutting-edge technologies. He has
contributed to many books on .NET, C#, Visual Basic, SQL Server, Silverlight, and ASP.NET. He is a .NET Microsoft
Certified Solution Developer (MCSD) and lives in Rome, Italy. He is employed by Brain Force.

xix


Acknowledgments
Writing a book is such a huge undertaking that it would have taken us another year to publish it if not for the
unconditional support of our families, friends, and colleagues.
Our manager at SELA Group, David Bassa, has given us all possible help to see this book to completion, and
was very understanding when other projects slipped through the tracks when the book’s deadlines loomed.
The editorial team at Apress made this project enjoyable and tolerated our second-language English to
shape the book as you see it today. Gwenan, Kevin, and Corbin: thank you for your professionalism and patience.

Last but not least, a great many thanks to our families, who have sacrificed countless hours on this book’s
altar. Without your support, this book would never be published.

xxi



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×