)救中国研究院 Secrets of performance 如何提高程序的性能 Bin lin Development Manager Microsoft research. china
Secrets of Performance 如何提高程序的性能 Bin Lin Development Manager Microsoft Research, China
提高性能的方法 Microsoft 软中国研究院 Faster hardware-$$$=速度 Use the right language, compiler optimizations Design scalable application Architectural design: cache -> RAM-> disk Choose right data structures and algorithms Tune code Avoid slow Os apis Tune. measure tune. measure tune. measure
提高性能的方法 • Faster hardware - $$$ = 速度 • Use the right language, compiler optimizations • Design scalable application – Architectural design: cache -> RAM -> disk – Choose right data structures and algorithms • Tune code – Avoid slow OS APIs – Tune, measure, tune, measure, tune, measure…
提高性能的方法 Microsoft 软中国研究院 Faster hardware-$$$=速度 Use the right language, compiler optimizations Design scalable application Architectural design: cache→>RAM→>disk Choose right data structures and algorithms Tune code Avoid slow Os apis Tune. measure tune. measure tune. measure
提高性能的方法 • Faster hardware - $$$ = 速度 • Use the right language, compiler optimizations • Design scalable application – Architectural design: cache -> RAM -> disk – Choose right data structures and algorithms • Tune code – Avoid slow OS APIs – Tune, measure, tune, measure, tune, measure…
Design: A Case Study )救中国研究院 Design a scalable SMTP server Scalable is the key 2-CPU. 4-cpu. 8-CPU machines Handle as many request as possible, with relatively fast response time
Design: A Case Study • Design a scalable SMTP server – Scalable is the key – 2-CPU, 4-CPU, 8-CPU machines – Handle as many request as possible, with relatively fast response time
Design: A Case Study 软中国研究院 A simple smtp server / Read SMTP commands/data from sockets 工f( ReadI1e()) // various housekeeping removed. // Parse SMTP recipients and other headers f(! ParseSMTPHeaders())( handle errors // Parse bodies If ( ParseSMTPBodies()) I // handle errors
Design: A Case Study • A simple SMTP server // Read SMTP commands/data from sockets If (ReadFile( … )) { // various housekeeping removed… } // Parse SMTP recipients and other headers If (!ParseSMTPHeaders(…)) { // handle errors… } // Parse bodies If (!ParseSMTPBodies(…)) { // handle errors… }