性能问题

| No Comments | No TrackBacks

记点笔记:High-Performance Server Architecture

性能问题一般因以下四个原因而起:

  1. Data copies(数据复制)
  2. Context switches(上下文切换)
  3. Memory allocation(内存分配)
  4. Lock contention(锁争用)

为避免Data copies,作者使用的方法是间接使用和通过buffer descriptor来代替buffer pointer,每一个buffer descriptor由以下部分构成:

  • A pointer and length for the whole buffer. 一个指向整个buffer的指针和大小。
  • A pointer and length or offset and length for the part of the buffer that's actually used. 一个指向buffer实际使用部分的指针和大小或偏移量及大小。
  • Forward and back pointers to other descriptors in a list. 指向其他描述符的向前及向后的指针列表。
  • a reference count. 一个引用计数。
但是作者并不推荐在所有情况下都这样用做,因为在描述符的链表中穿行是非常痛苦的,这个做法虽然提高了性能但是却比data copies更恶。最好的做法是标记所有较大的对象,比如说数据块,确保他们像上述那样被独立分配,这样他们就不会被复制了。另外也说了一些因避免复制而做出的更坏的事情,比如强制一个上下文切换,分解一个大的IO请求。为避免Data copies,第一个要关心的应该是如何避免额外的操作。

No TrackBacks

TrackBack URL: http://mt.khsing.net/cgi-bin/mt-tb.cgi/131

Leave a comment

About this Entry

This page contains a single entry by Guixing published on May 11, 2010 11:08 AM.

HS: sify.com的构架 was the previous entry in this blog.

WWDC放出的和我想要的 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.