微软先进技术专题(六):如何提高程序的性能 Secrets of Performance

)救中国研究院 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… }

Design: A Case Study(cont) 软中国研究院 // Local delivery or routing 工f( LocalDelivery(….)) Deliver(.) 1 else t Route(….) // Send SMTP response through Socket 工f( Writers1e(.)) // various housekeeping skips
Design: A Case Study (cont.) // Local delivery or routing If (LocalDelivery( … )) { Deliver( … ); } else { Route( … ); } // Send SMTP response through Socket If (WriteFile(…)) { // various housekeeping skips… }

Traditional Thread architecture Microsoft )救中国研究院 I thread to receive and dispatch SMTP request 64 worker threads doing Worker Parse SMTP headers Thread SMTP Request Parse sMTP bodies Receiver (Other workers) Socket Local delivery Worker Thread Routing All in the same thread sequentially
Traditional Thread Architecture SMTP Request Receiver (Socket) Worker Thread Worker Thread (Other workers) • 1 thread to receive and dispatch SMTP request • 64 worker threads doing: – Parse SMTP headers – Parse SMTP bodies – Local delivery – Routing – All in the same thread sequentially…

The Evolution of hardware )救中国研究院 Relative Performance(Latency) 800 8600 日cPU E400 口RAM 200 口Disk 0 19921994199619982000 Time
The Evolution of Hardware Relative Performance (Latency) 0 200 400 600 800 1992 1994 1996 1998 2000 Time Performance CPU RAM Disk

Bridge the Gap-Caches 软中国研究院 CPU LI cache 8K instruction cache, plus 8K data cache Closely coupled 0.333 clock/instruction -practical 1 CPI CPU L2 cache 512K static RAM Coupled with full clock-speed, 64-bit, cache bus Latency: 4-1-1-1-7 clocks/instruction 1O caches(RAM based file caches)
Bridge the Gap - Caches • CPU L1 cache – 8K instruction cache, plus – 8K data cache – Closely coupled – 0.333 clock/instruction – practical 1 CPI • CPU L2 cache – 512K static RAM – Coupled with full clock-speed, 64-bit, cache bus – Latency: 4-1-1-1 – 7 clocks/instruction • I/O caches (RAM based file caches)

The Price of failure )救中国研究院 Let's look at the costs Assume I second to zero a register LI cache hit-1 second(1x L2 cache hit- 4 seconds(plus 3 seconds extra work-7x) RAM hit-25-150 seconds(24x-150x) Disk or net hit -3 weeks(2, 000,000x)
The Price of Failure • Let’s look at the costs: – Assume 1 second to zero a register – L1 cache hit - 1 second (1x) – L2 cache hit - 4 seconds (plus 3 seconds extra work - 7x) – RAM hit - 25-150 seconds (24x-150x) – Disk or net hit - 3 weeks (2,000,000x)
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 微软先进技术专题(五):微软的软件开发 Software Development at Microsoft.pdf
- 微软先进技术专题(四):写好代码的10个秘诀_ 10 Things You Can Do To Write Better Code.ppt
- 微软先进技术专题(三):如何获得公开发表的研究 How to Get Good Research Published.pdf
- 微软先进技术专题(二):如何做研究 How To Do Research.pdf
- 微软先进技术专题(一):软件开发和艺术 The Art and Science of Software Development.pdf
- 清华大学《Windows操作系统原理》_Windows设备驱动程序开发.ppt
- 清华大学《Windows操作系统原理》_Windows应用程序设计.ppt
- 清华大学《Windows操作系统原理》_网络network.ppt
- 清华大学《Windows操作系统原理》_I/O系统.ppt
- 清华大学《Windows操作系统原理》_存储管理.ppt
- 清华大学《Windows操作系统原理》_进程和处理机管理.ppt
- 清华大学《Windows操作系统原理》_操作系统概述&Windows2000/XP的体系结构.ppt
- 清华大学:《操作系统》课程教学资源(PPT课件)第八章 外部设备管理.ppt
- 清华大学:《操作系统》课程教学资源(PPT课件)第六章 存储管理.ppt
- 清华大学:《操作系统》课程教学资源(PPT课件)第七章 文件系统.ppt
- 清华大学:《操作系统》课程教学资源(PPT课件)第五章 处理机管理.ppt
- 清华大学:《操作系统》课程教学资源(PPT课件)第四章 进程管理.ppt
- 清华大学:《操作系统》课程教学资源(PPT课件)第三章 用户管理和配置管理.ppt
- 清华大学:《操作系统》课程教学资源(PPT课件)第一章 绪论(向勇).ppt
- 清华大学:《操作系统》课程教学资源(PPT课件)第二章 作业管理和用户接口.ppt
- 微软先进技术专题(七):产品设计 Product Design.pdf
- 《计算机辅助教育》课程PPT课件(姚海莹).ppt
- flash制作_动画制作基础知识.ppt
- 人工智能的研究领域.ppt
- 计算机组成原理_第一章 计算机系统概论 小结.ppt
- 计算机组成原理_第一章 计算机系统概论.ppt
- 计算机组成原理_第七章 外围设备 讲稿.ppt
- 计算机组成原理_第三章 计算机的运算方法 小结.ppt
- 计算机组成原理_第三章 计算机的运算方法.ppt
- 计算机组成原理_第二章 总线 小结.ppt
- 计算机组成原理_第二章 总线.ppt
- 计算机组成原理_第五章中央处理器.ppt
- 计算机组成原理_第六章 存储器 讲稿1.ppt
- 计算机组成原理_第六章 存储器 讲稿2.ppt
- 计算机组成原理_第六章 存储器 讲稿3.ppt
- 计算机组成原理_第四章 指令系统.ppt
- 计算机组成原理_第四章 指令系统 小结.ppt
- 软件工程理论:《软件工程》课件.ppt
- 电子商务:供应链.ppt
- 中国地质大学:现代物流与电子商务.ppt