Web site

For more books click to >> CiCi Island

download

Electronic version is only for preview and learning exchange use, please delete within 24 hours after downloading, support genuine edition, like to buy genuine books

  • E-book download (Pipi Cloud Disk – click “Normal Download”)
  • Purchase genuine

Cover page

The editors recommend

Java programmers advanced must read classic, a total of 6 printing, won the 51CTO reading channel “* by readers favorite original IT technology book award” thousands of readers praise, tens of thousands of readers’ choice, tens of thousands of Java enthusiasts and programmers benefit! A good programmer, not only can write programs, more to write high quality applications, feel the great wisdom of Java development, let your Java program more beautiful Focus on Java application optimization method, skill and thought of software design level, code level, deep insight into the JVM optimization method of theory combined with the actual virtual machine level, The use of rich examples to help readers understand the theoretical knowledge of boutique books recommended (please click the series of links to view) “Java programming practice treasure code +Java program performance optimization (set of 2 volumes)” “Java 123 — an old bird learning experience in Java (TWO-DIMENSIONAL code version)” “Java programming notes: Learn Java from practice “” Java programming practical treasure book” “Java interesting programming 100 examples” “Java Web programming practical treasure book — JSP+Servlet+Struts 2+Hibernate+Spring+Ajax” “I have an agreement with mathematics — interesting mathematics and algorithm analysis” Mathematical Thinking training of Programmers (Interesting Interpretation)

Content abstract

Java is the most widely used software development platform at present, so it is of great practical significance to learn optimization methods for Java programs. Java Performance Tuning: Making Your Java Applications Faster and More Stable systematically explains the knowledge and techniques related to Java performance tuning. This book consists of six chapters, which introduce optimization methods for Java programs from software design, software coding, JVM tuning and program fault rejection. Chapter 1 introduces the basic concepts, laws, system tuning procedures, and considerations of performance. Chapter 2 introduces performance-related design patterns and components at the design level. Chapter 3 covers how to write high-performance Java programs at the code level. Chapter 4 covers parallel development and how to improve system performance through multithreading. Chapter 5 focuses on the JVM virtual machine and shows how to improve the performance of Java programs by setting appropriate JVM parameters. Chapter 6 is the tools section, which introduces various tools for capturing and monitoring program or system performance metrics, including related troubleshooting tools. This book is suitable for all Java programmers, software designers, architects and software development enthusiasts, for Java engineers with certain experience, this book can help him break through technical bottlenecks, in-depth Java kernel development!

Author’s brief introduction

Ge Yiming graduated from Zhejiang University of Technology with a master’s degree in Computer Software and theory. Obtained the national certification system analyst title, OCP (Oracle database certification expert). Now I am working in UtStarcom Communications Co., LTD., engaged in Java software development. Many years of software development experience, participated in the development of several software projects. Familiar with Java, PHP, MySQL, Oracle and other development languages and databases, have a strong interest in Java software development, performance optimization, distributed software and in-depth research. I have published many technical papers in school.

Orders to record

Chapter 1 Overview of Java Performance Tuning 1.1 Overview of Performance 1.1.1 Understanding program Performance 1.1.2 Performance Reference Indicators 1.1.3 Barrel Principle and Performance Bottlenecks 1.1.4 Amdahl’s Law 1.2 Performance Tuning Layers 1.2.1 Design Tuning 1.2.2 Code Tuning 1.2.3 JVM Tuning 1.2.4 Database Tuning 1.2.5 Operating System Tuning 1.3 Basic Tuning Strategies and Methods 1.3.1 General Steps of Optimization 1.3.2 System Tuning Considerations 1.4 Summary Chapter 2 Design Optimization 2.1 Making Good Use of Design Patterns 2.1.1 Singleton Patterns 2.1.2 Proxy Mode 2.1.3 Share mode 2.1.4 Decorator mode 2.1.5 Observer mode 2.1.6 Value Object mode 2.1.7 Service Proxy mode 2.2 Common Optimization Components and Methods 2.2.1 Buffer 2.2.2 Cache 2.2.3 Object Reuse — “pooling” 2.2.4 Parallel replacing serial 2.2.5 Load balancing 2.2.6 Time for Space 2.2.7 Space for Time 2.3 Summary Chapter 3 Java Program optimization 3.1 String Optimization processing 3.1.1 String objects and their characteristics 3.1.2 Memory leaks in the subString() method 3.1.3 String splitting and lookup 3.1.4 StringBuffer and StringBuilder 3.2 Core Data Structures 3.2.1 List interface 3.2.2 Map interface 3.2.3 Set interface 3.2.4 Optimized collection access code 3.2.5 RandomAccess interface 3.3 Using NIO to improve performance 3.3.1 NIO’s Buffer class family and Channel 3.3.2 Basic principles of Buffer 3.3.3 Operations related to Buffer 3.3.4 MappedByteBuffer performance Evaluation 3.3.5 Direct memory Access 3.4 Reference Types 3.4.1 Strong Reference 3.4.2 Soft Reference 3.4.3 Weak Reference 3.4.4 Virtual reference 3.4.5 WeakHashMap class and its implementation 3.5 Techniques that help improve performance 3.5.1 Careful use of exceptions 3.5.2 Using local variables 3.5.3 Replacing multiplication and division with bit operations 3.5.4 Replacing Switch 3.5.5 Replacing two-dimensional arrays with one-dimensional arrays 3.5.6 Extracting expressions 3.5.7 Expanding loops 3.5.8 Boboolean operations instead of bit operations 3.5.9 Using arrayCopy () 3.5.10 USING Buffer for I/O operations 3.5.11 Using Clone () instead of new 3.5.12 Static methods instead of instance methods 3.6 Summary Chapter 4 Parallel program development and optimization 4.1 Parallel program design Mode 4.1.1 Future Mode 4.1.2 Master-worker mode 4.1.3 System Suspension mode 4.1.4 Unchanged Mode 4.1.5 Producer-consumer Mode 4.2 JDK multitasking framework 4.2.1 Pitfalls of unrestricted Threads 4.2.2 Simple ThreadPool implementation 4.2.3 Executor Framework 4.2.4 Custom Thread pool 4.2.5 Optimizing thread pool size 4.2.6 Extending ThreadPoolExecutor 4.3 JDK Concurrent data structures 4.3.1 Concurrent List 4.3.2 Concurrent Set 4.3.3 Concurrent Map 4.3.4 Concurrent Queue 4.3.5 Concurrent Deque 4.4 Concurrent control methods 4.4.1 Java Memory model and Volatile 4.4.2 Synchronized 4.4.3 ReentrantLock 4.4.4 ReadWriteLock Read-write lock 4.4.5 Condition object 4.4.6 Semaphore Semaphore 4.4.7 ThreadLocal thread-local variables 4.5 Performance and optimization of “locks” 4.5.1 Overhead of threads 4.5.2 Avoiding deadlocks 4.5.3 Reducing lock holding time 4.5.4 Reducing lock granularity 4.5.5 Read/write split locks to replace exclusive locks 4.5.6 Lock split 4.5.7 Synchronized 4.5.8 Locking Coarsening 4.5.9 Spinning Locks 4.5.10 Lock Elimination 4.5.11 Locking Bias 4.6 Parallel computation without locks 4.6.1 Non-blocking synchronization/locking 4.6.2 Atomic operations 4.6.3 Amino Framework introduction 4.6.4 Amino set 4.6.5 Amino tree 4.6.6 Amino Figure 4.6.7 Amino Simple scheduling mode 4.7 Coroutines 4.7.1 Concept of coroutines 4.7.2 Introduction to the Kilim framework 4.7.3 Task and Its Status 4.7.4 Fiber and its Status 4.7.5 Kilim Development Environment Configuration 4.7.6 Hello World of Kilim 4.7.7 Multitasking Communication 4.7.8 Kilim Instances and Performance Evaluation 4.8 Summary Chapter 5 JVM Tuning 5.1 Java Virtual Machine Memory model 5.1.1 Program counters 5.1.2 Java Virtual Machine stack 5.1.3 Local Method stack 5.1.4 Java heap 5.1.5 Method area 5.2 JVM Memory Allocation Parameters 5.2.1 Setting the maximum heap memory 5.2.2 Setting the minimum heap memory 5.2.3 Setting the New generation 5.2.4 Setting the Persistent generation 5.2.5 Setting the Thread stack 5.2.6 Proportional allocation 5.2.7 Heap allocation Parameters summary 5.3 Garbage Collection basis 5.3.1 Role of garbage collection 5.3.2 Garbage collection algorithms and ideas 5.3.3 Types of garbage collectors 5.3.4 Criteria for evaluating GC strategies 5.3.5 New generation serial collectors 5.3.6 Old generation serial collectors 5.3.7 Parallel collectors 5.3.8 The New generation Parallel recycling collector 5.3.9 the older generation Parallel recycling collector 5.3.10 CMS collector 5.3.11 G1 collector 5.3.12 Stop the World case 5.3.13 Impact of collector on system performance 5.3.14 Summary of RELATED GC Parameters 5.4 Common Tuning Cases and Methods 5.4.1 Reserving New objects for the New generation 5.4.2 Large Objects entering the old age 5.4.3 Setting the age when objects enter the old age 5.4.4 Stable and oscillating heap size 5.4.5 Throughput First cases 5.4.6 Using large pages 5.4.7 Reducing pauses 5.5 Practical JVM Parameters 5.5.1 JIT compilation parameters 5.5.2 Heap Dump 5.5.3 Error handling 5.5.4 Obtaining GC information 5.5.5 Class and object tracing 5.5.6 Controlling GC 5.5.7 Selecting class Validators 5.5.8 Thread control under Solaris 5.5.9 Using large Page 5.5.10 Compression Pointers 5.6 Actual JVM Tuning 5.6.1 Introduction to Tomcat and Startup Acceleration 5.6.2 Introduction to Web Applications 5.6.3 Chapter 6 Java Performance Tuning Tools 6.1 Linux Command Line Tools 6.1.1 Top Command 6.1.2 SAR command 6.1.3 vmstat Command 6.1.4 iostat Command 6.1.5 Pidstat Tool 6.2 Windows Tools 6.2.1 Task Manager 6.2.2 Perfmon Performance Monitoring Tool 6.2.3 Process Explorer 6.2.4 Pslist Command Line 6.3 JDK Command line tool 6.3.1 JPS command 6.3.2 jstat command 6.3.3 jinfo command 6.3.4 jmap command 6.3.5 jhat command 6.3.6 jstack command 6.3.7 jstatd command 6.3.8 hprof tool 6.4 JConsole Tool 6.4.1 JConsole Connection to Java Programs 6.4.2 Overview of Java Programs 6.4.3 Memory Monitoring 6.4.4 Thread Monitoring 6.4.5 Class loading 6.4.6 VM Information 6.4.7 MBean Management 6.4.8 Using plug-ins 6.5 Visual VM All-in-one Tool 6.5.1 Visual VM Connecting Applications 6.5.2 Monitoring Application Overview 6.5.3 Thread Dump and Analysis 6.5.4 Performance Analysis 6.5.5 Snapshot 6.5.6 Memory Snapshot Analysis 6.5.7 MBean Management 6.5.8 TDA using 6.5.9 BTrace introduction 6.6 Visual VM support for OQL 6.6.1 Visual VM Basic OQL syntax 6.6.2 Built-in Heap object 6.6.3 Object functions 6.6.4 Collection/Statistics functions 6.6.5 Programmatic OQL 6.7 MAT Memory analysis tool 6.7.1 Introduction to MAT 6.7.2 Shallow heap and Deep Heap 6.7.3 Dominator Tree 6.7.4 Garbage collection root 6.7.5 Memory leak detection 6.7.6 Maximum object reporting 6.7.7 Finding the dominator 6.7.8 Thread Analysis 6.7.9 Collection Usage Analysis 6.7.10 Extending MAT 6.8 MAT’s support for OQL 6.8.1 Select clause 6.8.2 From clause 6.8.3 Where clause 6.8.4 Built-in Objects and Methods 6.9 Introduction to JProfile 6.9.1 JProfile Usage Configuration 6.9.2 Memory view 6.9.3 Heap snapshot 6.9.4 CPU view 6.9.5 Thread view 6.9.6 JVM statistics 6.9.7 Triggers 6.10 Summary

Before the speech

Java is one of the most widely used software development platforms. With the growth of Java and the Java community, Java is no longer simply a computer language, but a platform, a culture, and a community. As a platform, the JVM virtual machine plays an important role. With the exception of the Java language, any computer language that can be compiled into bytecode belongs to the Java platform. Groovy, Scala, JRuby, and so on are all part of the Java platform that rely on the JVM virtual machine, and the Java platform is enriched by them. As a culture, Java has almost become synonymous with “open source.” In Java programs, there are countless open source software and frameworks, such as Tomcat, Struts, Hibernate, Spring and so on. Even the JDK and JVM themselves have many open source implementations, such as OpenJDK and Harmony. It can be said that the spirit of “sharing” is most vividly embodied in the Java world. As a community, Java has countless developers, countless forums, and countless resources. From desktop application software, embedded development to enterprise application, background server, middleware, you can see the figure of Java. The complexity of its application forms and the number of participants are also staggering. The Java community has become a good and large ecosystem. Moreover, as a pure software development language, Java is very easy to learn and has a smoother learning curve than older computer languages such as C++. Because it tries to simplify or remove many obscure, redundant, and difficult parts of C++, such as Pointers, virtual functions, multiple inheritance, and so on. This book mainly introduces Java application optimization methods and skills, divided into six chapters. Chapter 1 is an overview, introducing the basic concepts of performance, two important laws (the barrel principle and Amdahl’s Law), and the general process and considerations of system tuning. From the design level, Chapter 2 introduces performance-related design patterns, components, and software design ideas that help improve performance. Chapter 3 covers how to write high-performance Java code at the code level. The main content involved is string optimization, file I/O optimization, the use of core database structure, Java reference types and some common conventions. Chapter 4 introduces parallel program development and how to improve system performance through multithreading. This paper introduces concurrency design pattern, thread pool, use of concurrent data structure, concurrency control method, optimization of “lock”, use of no lock and coroutine. Chapter 5 focuses on the JVM virtual machine and shows how to improve the performance of Java programs by setting appropriate JVM parameters. Chapter 6 is a tools section that focuses on tools for capturing and monitoring program or system performance metrics, as well as Java application-specific troubleshooting tools. The main features of this book are: * Focusing on Java application optimization methods, techniques, and ideas, and dissecting some implementations of the JDK in depth. * With a strong hierarchy and coherence, introduced in turn in the software design level, code level, JVM virtual machine level optimization methods. * Combining theory with practice, rich examples are used to help readers understand theoretical knowledge. To read this book thoroughly and achieve good learning effect, readers are required to have basic knowledge of Java. This book is not a book for beginners. Therefore, this book is suitable for: * Java developers with some development experience; * Java software designer and architect; * System tuning personnel; * Programmers who have some Java background and want to go further. JDK 1.5 and JDK 1.6 are the same as JDK 5 and JDK 6 respectively. * JVM VMS refer to Hot Spot VMS unless otherwise specified; * The programs and examples in this book run in JDK 1.6 unless otherwise specified. For the source programs involved in this book, please log in to the website of Tsinghua University Press, search the page of this book, and download them as prompted. The process of writing this book was much harder than I expected. I spent many sleepless nights trying to make the book clearer and more accurate. Even thinking about it now, it gives me the chills. However, due to the limitation of writing level and writing time, the book will inevitably have inappropriate places. To this end, readers can contact the author via email. During the writing of this book, I was filled with gratitude. Before finishing this book, my father was seriously ill, but I was too busy to spare much time to take care of him. Fortunately, THANKS to my mother’s strong support and my father’s understanding, I was able to muster up courage and devote myself to writing. At the same time, my mother’s good care for me helps me concentrate more on my work. At the same time, I would like to thank my working unit UtStarcom and my two senior staff Rex Zhu and Tao Tao. It is their careful guidance to me in daily work that enables me to make progress and accumulate. This is the basis of the book. Finally, thanks again to my mother, I wish her good health. GeYiMing