Skip to content

Instantly share code, notes, and snippets.

package main
import (
"log"
"github.com/gin-gonic/gin"
)
func main() {
engine := gin.Default()
diff --git a/build/build_win.ninja.template b/build/build_win.ninja.template
index 3edfb6a4..0f8cb372 100644
--- a/build/build_win.ninja.template
+++ b/build/build_win.ninja.template
@@ -1,12 +1,12 @@
rule cc
- command = ninja -t msvc -- $cc /nologo /showIncludes /FC @${out}.rsp /c ${in} /Fo${out}
+ command = ninja -t msvc -- $cc /nologo /showIncludes /FC @${out}.rsp /c ${in} /Fo${out} /source-charset:utf-8 /execution-charset:utf-8
description = CC ${out}
rspfile = ${out}.rsp

Three system configuration parameters must be set to support a large number of open files and TCP connections with large bursts of messages. Changes can be made using the /etc/rc.d/rc.local or /etc/sysctl.conf script to preserve changes after reboot.

1. /proc/sys/fs/file-max: The maximum number of concurrently open files.

fs.file-max = 1000000

2. /proc/sys/net/ipv4/tcp_max_syn_backlog: Maximum number of remembered connection requests, which are still did not receive an acknowledgment from connecting client. The default value is 1024 for systems with more than 128Mb of memory, and 128 for low memory machines.

net.ipv4.tcp_max_syn_backlog = 3240000

3. /proc/sys/net/core/somaxconn: Limit of socket listen() backlog, known in userspace as SOMAXCONN. Defaults to 128.

net.core.somaxconn = 3240000

dotnet core 诊断

managed 侧未捕获异常

目前可以通过查看 stdout/stderr 的栈排查。

unmanage 侧异常

需要使用 lldb 看 core 文件。建议在 docker 镜像 su21/dotnet 内重现 然后用 镜像内的 lldb 以及符号排查。 SceneServer/SceneServer/debugcore 是一个看 coredump 的辅助脚本。

卡死问题

using System;
using System.Text;
using Consul;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using System.Threading;
@patricksuo
patricksuo / solarized_for_xshell.xcs
Created August 14, 2018 14:35 — forked from solicomo/solarized_for_xshell.xcs
Solarized Light/Dark Theme of XShell
[Names]
count=2
name1=Solarized Dark
name0=Solarized Light
[Solarized Light]
text(bold)=586e75
magenta(bold)=6c71c4
text=657b83
white(bold)=fdf6e3
green=859900
@patricksuo
patricksuo / empty.s
Last active November 12, 2018 03:38
PID
// gist 不支持空文件

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

package reflectimport ( "runtime"
"sync"
"unsafe"
)
type Caller struct {
v Value
//readonly cache
numIn int
func BuyHandler(buyRequest BuyRequest) {
for i:=0; i<MaxRetry; i++ {
needRetry := func() (retry bool) {
defer func() {
if err := recover(); err != nil {
if _, isTxConflic := err.(ErrTransactionConflic); isTxConflic {
retry = true;
}