Skip to content

Instantly share code, notes, and snippets.

jinhua luo kingluo

Block or report user

Report or block kingluo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Cargo.toml
[package]
name = "tokio-psql"
version = "0.1.0"
authors = ["Jinhua Luo <home_king@163.com>"]
edition = "2018"
[dependencies]
futures-preview = "=0.3.0-alpha.19"
tokio = "0.2.0-alpha.6"
tokio-postgres= { git = "https://github.com/sfackler/rust-postgres" }
View Main.java
package foo.bar.flinkapp;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
View ngx-process-events-time.sxx
#!/usr/bin/env stap++
global exec_begin
global stats
probe @pfunc(ngx_epoll_process_events)
{
exec_begin = gettimeofday_us()
}
View gist:3a11af38c5ecf09fbb34a01c111523ad

1. 先安装systemtap和kernel-devel

yum install systemtap kernel-devel

2. 安装debuginfo

  • 找到内核版本和glibc版本
View test1 performance
$ time luajit /tmp/test.lua
real 0m4.923s
user 0m4.912s
sys 0m0.020s
@kingluo
kingluo / sample-bt-off-cpu
Created Jan 13, 2016
modified sample-bt-off-cpu for postgresql
View sample-bt-off-cpu
#!/usr/bin/env perl
# Copyright (C) Yichun Zhang (agentzh)
# Thanks Brendan Gregg for the inspiration given here:
# http://dtrace.org/blogs/brendan/2011/07/08/off-cpu-performance-analysis/
use 5.006001;
use strict;
use warnings;
@kingluo
kingluo / cython.markdown
Last active Nov 27, 2017
python vs cython
View cython.markdown

case1:字节码执行

同样的python代码,经过cython编译后运行,一般情况下也比用python解释器运行要快。

因为python解释代码,本质上就是一个for/switch,对字节码的逐条执行,相比机器语言, 使得CPU无法预判指令分支,也破坏指令缓存的局部化。

p1.py

@kingluo
kingluo / schedule.c
Created Jul 24, 2015
schedule performance between goroutine and pthread
View schedule.c
king@debian:~$ time ./a.out
real 0m10.261s
user 0m3.040s
sys 0m17.312s
king@debian:~$ time go run pthread.go
real 0m4.017s
user 0m5.444s
View simulate_cpu_busy.diff
--- testpq.go 2015-07-17 16:18:53.616212373 +0800
+++ testpq2.go 2015-07-17 16:03:03.420162955 +0800
@@ -8,6 +8,9 @@
_ "github.com/lib/pq"
)
+//#include <unistd.h>
+import "C"
+
func query(db *sql.DB, tstart time.Time, tend time.Time) {
@kingluo
kingluo / c.c
Created Jul 8, 2015
cgo good example
View c.c
#include "c.h"
#include "_cgo_export.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct A* echo(void) {
const char* p = "hello world";
GoString p2;
p2.p = (char*)p;
You can’t perform that action at this time.