Skip to content

Instantly share code, notes, and snippets.

#对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)

@rainly
rainly / setup.sql
Created August 30, 2012 09:17 — forked from imperialwicket/setup.sql
PostgreSQL monthly table partitions
--
-- Setup - Add plpgsql, create a parent table, create an initial child table,
-- create the trigger and the initial trigger function.
--
-- We'll need plpgsql, so create it in your db if it's not already available.
CREATE LANGUAGE plpgsql;
-- Create a table to act as parent with the appropriate columns for your data.
CREATE TABLE my_schema.my_data (name varchar(24), create_date timestamp);
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@imperialwicket
imperialwicket / setup.sql
Last active December 8, 2024 22:56
PostgreSQL monthly table partitions
--
-- DEPRECATED GIST
-- **** Moved to a repo: https://github.com/imperialwicket/postgresql-time-series-table-partitions ****
--
-- You should check the repository, this gist won't receive updates.
--
--
--
--
--
@fabriciocolombo
fabriciocolombo / PostgreSQL read-only user
Created April 24, 2012 20:57
PostgreSQL read-only user
GRANT CONNECT ON DATABASE $dbName TO $user;
GRANT USAGE ON SCHEMA $schema TO $user;
GRANT SELECT ON ALL TABLES IN SCHEMA $schema TO $user;
Default privileges
ALTER DEFAULT PRIVILEGES IN SCHEMA $schema
GRANT SELECT ON TABLES TO $user;
see more at http://www.postgresql.org/docs/9.0/static/sql-alterdefaultprivileges.html
@mmrwoods
mmrwoods / new_linode_centos6.markdown
Created February 7, 2012 11:39
Make me a new CentOS linode

Make me a new CentOS linode

Notes:

  • Instructions written for CentOS 6.3
  • Change, me, myhost, myip etc. to your username, hostname, ip address and so on.
  • Run all commands as root unless otherwise directed.
  • You might want to look at mounting /var and /home on separate partitions.
  • I've just allowed all members of the wheel group to operate as root. This is the height of laziness and highlights the fact that I'm just a developer that's stolen a sysadmin's
@mmrwoods
mmrwoods / mysql
Created January 20, 2012 13:49
MySQL maintenance crontab file
# note: MySQL_maintenance.pl can be obtained from http://danbuettner.net/mysql-tools/
# check, optimise and repair MySQL databases (extended check on Sunday, quick every other day)
15 3 * * 0 root nice -n 19 /usr/local/sbin/MySQL_maintenance.pl --check-type=extended --optimize --repair --exclude-dbs=information_schema
15 3 * * 1-6 root nice -n 19 /usr/local/sbin/MySQL_maintenance.pl --check-type=quick --optimize --repair --exclude-dbs=information_schema > /dev/null
# dump all mysql databases once every 24 hours
15 4 * * * root nice -n 19 mysqldump --opt --all-databases --allow-keywords | gzip -9 > /var/local/backup/mysql/mysql_all.sql.gz
@mmrwoods
mmrwoods / postgres
Created January 20, 2012 13:47
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
@kaichen
kaichen / Gemfile
Created January 9, 2012 03:35
play-with-em
source :rubygems
gem "eventmachine", "0.12.10"
gem "rack"
@quietlynn
quietlynn / 12306.user.js
Created January 3, 2012 12:01
12306 Auto Query => A javascript snippet to help you book ticket
/*
12306 Auto Query => A javascript snippet to help you book tickets online.
Copyright (C) 2011-2012 Jingqin Lynn
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes Sizzle.js