Skip to content

Instantly share code, notes, and snippets.

View garenchan's full-sized avatar
:dependabot:
Focusing

Garen Chan garenchan

:dependabot:
Focusing
View GitHub Profile
@garenchan
garenchan / bt
Last active July 20, 2023 02:48
execsnoop.bt
#!/usr/bin/env bpftrace
#include <linux/sched.h>
BEGIN
{
printf("Trace new processes via exec() syscalls. Hit Ctrl-C to end.\n");
}
tracepoint:syscalls:sys_enter_exec*
@garenchan
garenchan / go
Created May 7, 2022 08:20
go-utils
// 打印traceback
// src/runtime/traceback.go
func traceback2() {
// Everything throw does should be recursively nosplit so it
// can be called even when it's unsafe to grow the stack.
pc := getcallerpc()
sp := getcallersp()
gp := getg()
traceback(pc, sp, 0, gp)
@garenchan
garenchan / increase-open-files.md
Last active July 13, 2018 06:43
increase open files

增大open-files

Ubuntu默认的open files为1024, 可以通过ulimit -n来查看;

在高并发场景下, 网络服务打开的文件描述符可能会超过这个限制, 那么我们需要来增大这个值

临时性增大

执行如下命令, 会增大open files值, 但是重启后会被恢复

@garenchan
garenchan / sysctl.conf
Last active July 13, 2018 04:01
linux web server tuning
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3