Skip to content

Instantly share code, notes, and snippets.

View zhengtao620's full-sized avatar

郑涛 zhengtao620

  • 滴滴出行
  • 北京海淀
View GitHub Profile
@zhengtao620
zhengtao620 / gist:10154054
Last active August 29, 2015 13:58
应用程序可以通过修改Socket缓存大小来增加TCP的传输性能
[Mogul 1993]显示了在改变发送和接收缓存大小(在单向数据流的应用中,如文件传输,
只需改变发送方的发送缓存和接收方的接收缓存大小)的情况下,位于以太网上的两个
工作 站之间进行文件传输时的一些结果。它表明对以太网而言,默认的4096字节
并不是最理想的大小,将两个缓存增加到16384个字节可以增加约40%左右的吞吐量。
在 [Papadopoulos和 Parulkar 1993]中也有相似的结果。

#对non-lock queue的简单分析#

今天看到 @梁斌penny 在打擂:http://coderpk.com

内容如下:

游戏规则: 比赛由pennyliang,就是本人梁斌同志坐庄,我提交baseline代码(可执行程序),和部分代码,方便统一游戏规则。 10亿数据(每个数据看作一个同志),1个队列,10个线程push,10个线程pop,走完一遍,考察总耗时,耗时最短的获胜。我的代码在我自己机器10亿数据排队进出,耗时1分28秒,内存峰值256MB(CPU16核,真8核那种,Intel(R) Xeon(R) CPU E5540 @ 2.53GHz)

@zhengtao620
zhengtao620 / reverse_array.c
Created July 11, 2012 21:54
A technique for swapping two values, whiche do not need a third temporary storage space
//on the basis of a^a=0
void inplace_swap(int *x, int *y){
*y = *x ^ *y;
*x = *x ^ *y;
*y = *x ^ *y;
}
void reverse_array(int a[], int cnt){
int first, last;