Skip to content

Instantly share code, notes, and snippets.

@lrita
lrita / main.go
Created January 29, 2019 17:25
分布式存储系统可靠性-注解
package main
import (
"fmt"
"math"
)
func C(N, K int64) float64 {
a, b := 1.0, 1.0
if N == 0 {
@lrita
lrita / image.go
Last active September 13, 2018 16:51
// This code is used for testing the cost of mutex contention.
// If there are a lot goroutines fetch a mutex simultaneously,
// those goroutines will be woke up slowly which are waiting for
// the mutex.
package main
import (
"flag"
"image"
"image/color"
// +build !race
package sync1
import "unsafe"
const enabled = false
func Acquire(addr unsafe.Pointer) {}
func Release(addr unsafe.Pointer) {}
# stap -g inject_accept.stp $pid
%{
#include <net/sock.h>
%}
function set_sock_keepalive:long(fd) %{
int err = -1;
int keepalive = 1;
struct socket *sock = sockfd_lookup(STAP_ARG_fd, &err);
if (sock != NULL) {