You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Chapter4_8.md
+15-14Lines changed: 15 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -26,8 +26,8 @@ Throughput and response time have a generally reciprocal but subtly complex rela
26
26
27
27
In performance optimization, two main goals are:
28
28
29
-
1.**Optimal response time:** Minimize waiting for task completion.
30
-
2.**Maximal throughput:** Handle as many simultaneous tasks as possible.
29
+
1.**Optimal response time:** Minimize waiting for task completion.
30
+
2.**Maximal throughput:** Handle as many simultaneous tasks as possible.
31
31
32
32
These goals are contradictory: optimizing for response time requires minimizing system load, while optimizing for throughput requires maximizing it. Balancing these conflicting objectives is key to effective performance optimization.
33
33
@@ -87,9 +87,9 @@ Based on extensive testing, it is concluded that the root cause of discrepancies
87
87
88
88
MySQL's complexity makes performance modeling challenging, but focusing on specific subsystems can offer valuable insights into performance problems. For instance, when modeling the performance of major latches in MySQL 5.7, it's found that executing a transaction (with a transaction isolation level of Read Committed) involves certain operations:
89
89
90
-
-**Read Operations:** Pass through the trx-sys subsystem, potentially involving global latch queueing.
91
-
-**Write Operations:** Go through the lock-sys subsystem, which involves global latch queueing for lock scheduling.
92
-
-**Redo Log Operations:** Write operations require updates to the redo log subsystem, which also involves global latch queueing.
90
+
-**Read Operations:** Pass through the trx-sys subsystem, potentially involving global latch queueing.
91
+
-**Write Operations:** Go through the lock-sys subsystem, which involves global latch queueing for lock scheduling.
92
+
-**Redo Log Operations:** Write operations require updates to the redo log subsystem, which also involves global latch queueing.
@@ -180,8 +180,9 @@ Regarding algorithms, optimization opportunities are generally hard to find in m
180
180
181
181
Cache has a significant impact on performance, and maintaining cache-friendliness primarily involves the following principles:
182
182
183
-
1.**Sequential Memory Access:** Access memory data sequentially whenever possible. Sequential access benefits cache efficiency. For example, algorithms like direct insertion sort, which operate on small data sets, are highly cache-friendly.
184
-
2.**Avoid False Sharing:** False sharing occurs when different threads modify parts of the same cache line simultaneously, leading to frequent cache invalidations and performance degradation. This often happens when different members of the same struct are modified by different threads concurrently.
183
+
1.**Sequential Memory Access:** Access memory data sequentially whenever possible. Sequential access benefits cache efficiency. For example, algorithms like direct insertion sort, which operate on small data sets, are highly cache-friendly.
184
+
2.**Ensuring Cache-Friendly Code**: Whether frequently accessed functions are inlined, if there is code that hinders inlining, and if switch statements are used appropriately—all these factors can affect the cache friendliness of the code.
185
+
3.**Avoid False Sharing:** False sharing occurs when different threads modify parts of the same cache line simultaneously, leading to frequent cache invalidations and performance degradation. This often happens when different members of the same struct are modified by different threads concurrently.
185
186
186
187
False sharing is a well-known problem in multiprocessor systems, causing performance degradation in multi-threaded programs running in such environments. The figure below shows an example of false sharing.
0 commit comments