Windows 2000 Performance Guide Windows 2000 Performance Guide Mark Friedman and Odysseas Pentakalos Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo Windows 2000 Performance Guide by Mark Friedman and Odysseas Pentakalos Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly & Associates, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly & Associates books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information contact our corporate/institutional sales department: (800) 998-9938 [email protected]. Editor: Robert Denn Production Editor: Emily Quill Cover Designer: Ellie Volckhausen Interior Designer: David Futato Printing History: January 2002: First Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly & Associates, Inc. Many of the designations used by manufacturers and sellerstodistinguishtheirproductsareclaimedastrademarks.Wherethosedesignationsappear in this book, and O’Reilly & Associates, Inc. was aware of a trademark claim, the designations havebeenprintedincapsorinitialcaps.Theassociationbetweentheimageofasticklebackfish and Windows 2000 performance is a trademark of O’Reilly & Associates, Inc. Whileeveryprecautionhasbeentakeninthepreparationofthisbook,thepublisherassumesno responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. Library of Congress Cataloging-in-Publication Data Friedman, Mark, 1951 June 13- Windows 2000 performance guide: help for Windows 2000 administrators / Mark Friedman & Odysseas Pentakalos. p. cm. ISBN 1-56592-466-5 1. Microsoft Windows (Computer file) 2. Operating systems (Computers) I. Pentakalos, Odysseas. II. Title. QA76.76.O63 F774 2001 005.4'4769--dc21 2001036167 [M] Preface The book you hold in your hands originally arose from need. Professionally, we felt the need to answer both basic and not-so-basic questions about the performance of Intel-based computer systems running various versions of the Microsoft Windows 2000 operating system, including both Windows NT and Windows XP. We expect thatmostreadersofthisbookareseekinganswerstocommonquestionsaboutcom- puterandoperatingsystemperformanceoutofsimilarpersonalorprofessionalcuri- osity.Thisbook,infact,evolvedfromaseminarintendedtoaddresssuchquestions that one of the authors developed and taught over a number of years. Thematerialinthebookistheresultofresearchperformedoverthelastfiveyearson successiveversionsoftheWindowsNToperatingsystem,beginningwithVersion3.5 andcontinuingtothepresentday.(Asthisbookwasgoingtopress,wewereexperi- menting with early versions of Windows XP. As best we can currently determine, almost all of the information provided here regarding Windows 2000 performance canalsobeappliedtothe32-bitversionofWindowsXP.)Muchofthematerialhere is original, derived from our observations and analysis of running systems, some of whichmaycontradictofficialdocumentationandthewritingsandrecommendations of other authorities. Rest assured that we carefully reviewed any findings reported here that run counter to the received wisdom. While we strive to make the discussion here definitive, there are necessarily many places where our conclusions are tentative and subject to modification should new information arise. We expect readers to be willing to challenge our conclusions in the face of strong empirical evidence to the contrary, and urge you to communicate to us (via the publisher) when you discover errors of commission or omission, for which we assume full responsibility. If you observe behavior on one of your Win- dows2000machinesthatseemstocontradictwhatwesayinthebook,pleaseshare those observations with us. With your help, we should be able to produce a subse- quent version of this book that is even more authoritative. Our research for the book began with all the standard sources of information about the Windows 2000 operating system. We frequently cite official documentation ix This is the Title of the Book, eMatter Edition Copyright © 2013 O’Reilly & Associates, Inc. All rights reserved. included in the operating system help files. We also refer to the extensive reference material provided in the Windows 2000 Resource Kit. David Solomon and Mark Russinovich’sInsideWindows2000,publishedbyMicrosoftPress,wasanothervalu- able source of inside information. The Windows 2000 platform System Develop- ment Kit (SDK) and Device Driver Development Kit (DDK) documentation, along with Microsoft Developer Network (MSDN) KnowledgeBase entries and other tech- nical articles, also proved useful from time to time. Intel processor hardware docu- mentation (available at http://www.intel.com) was helpful as well, particularly in writing Chapters 4 and 5. At many points in the text, we cite other reference mate- rial, including various academic journals and several excellent books. From time to time, we also mention worthy magazine articles and informative white papers pub- lished by various vendors. This book contains a complete bibliography. Originally, we intended this book to serve as an advanced text, picking up where Russ Blake’s outstanding Optimizing Windows NT left off. Unfortunately, Blake’s book is currently out of print and woefully obsolete. Blake led a team of developers who implemented a performance monitoring API for the initial version of Windows NT 3.1, when the OS first became available in 1992. Russ’s book also documented usingPerformanceMonitor,theall-purposeperformancemonitoringapplicationthe team developed. We acknowledge a tremendous debt to Russ, Bob Watson, and other members of that team. Writing when he did, Blake had little opportunity to observe real-world Windows NT environments. Consequently, almost all the exam- ples he analyzes are based on artificial workloads generated by an application called PerformanceProbe,whichhealsodeveloped.(ThePerformanceProbeprogramisno longer available in the Windows 2000Resource Kit; it is available in earlier versions of the NT 3.5 and 4.0 Resource Kits.) While we also experiment in places with artificial workloads running under con- trolled conditions, we were fortunate to dive into Windows NT some years after it first became available. That allowed us to observe and measure a large number of real-world Windows NT and Windows 2000 machine environments. One advan- tage of real-world examples and case studies is that they are more likely to resemble the environments that you encounter. We should caution you, however, that many of the examples we chose to write about reflect extreme circumstances where the behavior we are trying to illustrate is quite pronounced. However, even when the systems you are observing do not evidence similar exaggerated symptoms, you should still be able to apply the general principles illustrated. Our focus is on explaining how Windows 2000 and various hardware components associated with it work, how to tell when the performance of some application run- ningunderWindows2000isnotoptimal,andwhatyoucandoaboutit.Thepresen- tation is oriented toward practical problem-solving, with an emphasis on understanding and interpreting performance measurement data. Many realistic examples of performance problems are described and discussed. x | Preface This is the Title of the Book, eMatter Edition Copyright © 2013 O’Reilly & Associates, Inc. All rights reserved. Intended Audience We have tried to aim this book at a variety of computer systems professionals, from system administrators who have mastered the basics of installing and maintaining Windows2000serversandworkstations,todeveloperswhoaretryingtobuildhigh- performance applications for this platform, to performance management and capac- ityplanningprofessionalswithexperienceonotherplatforms.Althoughwepresume no specific background or prior level of training for our readers, our experience teaching this material suggests that this is not a book for beginners. If you find the material at hand too challenging, we recommend reading a good book on Windows 2000operatingsysteminternalsoronbasicoperatingsystemprinciplesfirst.Wetry to pick up the discussion precisely where most other official documentation and publishedsourcesleaveoff.Thisincludesthecoursematerialassociatedwithobtain- ing MCSE certification, which provides a very limited introduction to this topic. Computer performance remains a core topic of interest to experienced program- mers, database administrators, network specialists, and system administrators. We wrotethisbookforprofessionalswhoseektounderstandthistopicinthecontextof Windows 2000 and the hardware environment it supports. At a minimum, you shouldhaveaworkingknowledgeofWindows2000.Werecommendthatyouhave read and are familiar with the section on performance in the Windows 2000 Profes- sional Resource Kit, which introduces the topic and documents the basic tools. For best results, you should have ready access to a computer running Windows 2000 Professional or Server so that you can refer frequently to a live system while you are reading, and put the abstract concepts we discuss into practice. We understand that many people will buy this book because they hope it will assist them in solving some specific Windows 2000 performance problem they are experi- encing. We hope so, too. Please understand, though, that for all but the simplest applications, there may be many possible solutions. While we do try to provide spe- cific and detailed answers to Frequently Asked Questions, our approach to problem diagnosisismoretheoreticalandgeneralthanthemanybooksthatpromisethatthis sortofunderstandingiseasilyacquired.Itispossiblethatwehavechosentoillustrate a discussion of some topic of immediateinterest with an example that looks remark- ably similar to a problem that you currently face. We all get lucky from time to time. Organization of This Book This book consists of twelve chapters and a bibliography. Chapter1, Perspectives on Performance Management, introduces a broad range of best practices in computer performance and capacity planning. Chapter2, Measurement Methodology, describes the Windows 2000 performance monitoring API, which is the source of most of the performance data that is dealt with in subsequent chapters. Preface | xi This is the Title of the Book, eMatter Edition Copyright © 2013 O’Reilly & Associates, Inc. All rights reserved. Chapter3, Processor Performance, discusses the basics of processor performance monitoring at the system, processor engine, process, and thread levels. Since the thread, not the process, is the unit of execution in Windows 2000, we focus on thread scheduling and thread execution priority. Chapter4,OptimizingApplicationPerformance,isorganizedaroundadescriptionof a programming optimization exercise that compares and contrasts several popular CPU usage code-profiling tools. Chapter5,Multiprocessing,discussesperformanceconsiderationswhenyouarerun- ningWindows2000Server,AdvancedServer,andDatacenteronmachineswithtwo or more processors. Chapter6, Memory Management and Paging, discusses Windows 2000 virtual mem- ory management and describes the techniques Windows 2000 uses to manage RAM and the working sets of active application processes. Chapter7,FileCachePerformanceandTuning,tacklestheWindows2000filecache, a built-in operating system service that is crucial to the performance of a number of important applications, including Windows 2000 network file sharing and IIS. Chapter8,Disk Subsystem Performance, introduces basic disk performance concepts. Chapter9,Filesystem Performance, looks at filesystem performance. Chapter10, Disk Array Performance, discusses the disk array technology used in most larger Windows 2000 servers. Chapter11,IntroductiontoNetworkingTechnologyisasurveyofcomputernetwork- ing, with an emphasis on the TCP/IP support in Windows 2000. Chapter12, Internet Information Server Performance, focuses on the Microsoft web server application Internet Information System (IIS). The bibliography contains a list of references for those who would like to pursue these topics in more depth. Conventions Used in This Book We have used the following conventions in this book: • Italic is used for filenames, directories, URLs, and hostnames. It is also used for emphasis and to introduce new terms. • Constantwidth is used for commands, keywords, functions, and utilities. • Constantwidthitalic is occasionally used for replaceable items in code. xii | Preface This is the Title of the Book, eMatter Edition Copyright © 2013 O’Reilly & Associates, Inc. All rights reserved. This icon signifies a tip relating to the nearby text. This icon signifies a warning relating to the nearby text. How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly & Associates, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 (800) 998-9938 (in the United States or Canada) (707) 829-0515 (international or local) (707) 829-0104 (fax) We have a web page for this book, where we list errata and any additional informa- tion. You can access this page at: http://www.oreilly.com/catalog/w2kperf/ To comment or ask technical questions about this book, send email to: [email protected] Formoreinformationaboutbooks,conferences,ResourceCenters,andtheO’Reilly Network, see O’Reilly’s web site at: http://www.oreilly.com Acknowledgments BothauthorsgratefullyacknowledgethesupportandassistanceofRobertDennand his staff at O’Reilly, without whom the book you hold in your hands would never have been completed. We are especially grateful for Robert’s steady hand and patiencethroughoutthelonggestationperiodforthisbook.Atonepointwethought thathemightselectanengravingofaslothtoadornthefrontcover.Wewouldalso liketoacknowledgethehelpofmanyotherindividualswhoreviewedearlierdraftsof the book, including Dave Butchart, Janet Bishop, Bob Gauthier, Todd Glasgow, Kitrick Sheets, Jim Quigley, and Rich Olcott. They all contributed to making the final text clearer and more readable. Any errors that remain are solely the responsi- bility of the authors. Preface | xiii This is the Title of the Book, eMatter Edition Copyright © 2013 O’Reilly & Associates, Inc. All rights reserved.