Le rapport est dédié au thÚme de l'optimisation des performances, mais pas tout à fait à l'optimisation des performances, mais aux péchés de l'optimisation des performances (dans VictoriaMetrics).
Vidéo
Je te dirai ce que c'est plus tard. Tout d'abord, je vais vous parler un peu de moi.
- Je suis Alexander Valyalkin. Mon surnom est valyala.
- Je suis l'auteur de bibliothÚques Go telles que Fasthttp , Fastjson , Quicktemplate . Ces bibliothÚques sont optimisées pour la vitesse.
- .
- timeseries VictoriaMetrics.
? , :
- .
- hardware , , .
- â benchmark games. , benchmarks. production.
, . . , .
Fasthttp, fastjson, VictoriaMetrics. Go . Go. .
Fasthttp. Fasthttp â net/http, , .
Fasthttp , :
- .
- HTTP headers.
- slices maps
key->value
. -
requestCtx
. - DNS .
c . HTTP Go. .
. http . , . , . , . , . . keep-alive, .
? , , / , . . .
, . , HTTP pipelining .
HTTP pipelining â HTTP , .
. . bufio.NewReader bufio.NewWriter. . : , , Write .
, . , , .
pipelining connection. ? â - , . , , , .
? , , . 4 . . . , bufio.Reader
, reader 4- .
4 , . , .
. 4 , . , , «flush». . , . .
https://en.wikipedia.org/wiki/HTTP_pipelining#Implementation_status
https://github.com/TechEmpower/FrameworkBenchmarks/issues/4410
.
, HTTP pipelining head of line blocking. - , , HTTP connection , , . , .
. HTTP pipelining . , , HTTP pipelining, . ? HTTP, 2000- , HTTP pipelining, HTTP pipelining. , HTTP pipelining. HTTP 2.0 . , HTTP pipelineing, HTTP 2.0.
HTTP pipelining â , , Techempower benchmarks . Techempower benchmark â , HTTP . , plaintext. 16 pipelining requests . HTTP pipelining fasthttp
2 .
. . , , , .
â HTTP headers.
Fasthttp HTTP headers . HTTP headers. . headers byte slice . byte slice HTTP headers.
Fasthttp, HTTP header . : «Hello, world!» http http headers.
, http headers. , header «X-Forwarded-For», Fasthttp HTTP header.
? , HTTP , HTTP headers .
â , http . , , . .
slices maps. Fasthttp slices key->value
goâ map' , , . . , query args, cookies.
, . key->value
byte slices.
slice map.
? , slice map â byte slice. kvs â byte slice . capacity , , , . . . slice, . . -. â [:0]
, , , kv.value, - .
slice map, kv.value byte slice slice map. , , .
slice map. slice mapâ . , . .
? , slice maps, , query args cookies, â . slice maps , map Go.
, , slice maps maps. . . slice maps .
, â , . . . query args , slice map , map, map.
. query args , , , slice map â O(N)
, . . , slice. , slice map, .
â , slice map . , slice map - , , , slice map , .
â , , slice map, slice map. , slice map . .
â RequestCtx
. RequestCtx
â , http.ResponseWriter
http.Request
. , RequestHandler
. HTTP .
. . RequestCtx. . ctx.Request
. RequestHandler
RequestCtx
response connection. . . . RequestHandler
RequestCtx
, , , RequestHandler
.
? , RequestCtx
. , , . .
, , . API . , - RequestCtx
RequestHandler
- , , . RequestHandler
. , Fasthttp, . . RequestCtx
, , , .
, â . RequestCtx
- request response body, - . RequestCtx
, . .
â DNS. Fasthttp . resolve DNS . Fasthttp DNS , . . resolving. Fasthttp mapping name ip .
, . resolveHost. dnsCache mapâa. . , , . , locks. , . , .
? DNS resolving.
â , HTTP , DNS . â Kubernetes, pods, IP-. , , Fasthttp , podâ . , .
Fasthttp . Fastjson .
Fastjson â encoding/json. , . , .
"" fastjson:
.
.
integers floats.
. Fastjson Parser, JSON. , , .
. Parser.Parse. value. value . . . value Parser
. foo
. b
. b
.
JSON. v
b
, , v
p
, . . . vv
, , .
? , JSON.
â , API . , , , JSONâ, .
â , , . . . JSON , , , , 1 , JSON, , 2 , . . . 2 .
â unescaping . Fastjson . escape . escape , . . escape , , .
, , escape , . strings.IndexByte â goâ . .
â , escape .
â , , escape , â , , , . .
â floats integer Fastjson.
, , strconv.
? : « strconv
?». , . . edge cases. . . , strconv
. , , , strconv
.
â , 0, .
â , - , .
. VictoriaMetrics Prometheus remote write API . protobufs.
protobuf , Prometheus. , , . .
. protobuf. timeseries, labels samples. label name value. Sample, , timestamp.
. labels name string. byte slice. , , , name. byte slice data string. , . . string . , , . .
. slice labels, . . slice labels. . label , label , label. capacity , , .
, . , , protobuf.
, . , string byte slice, byte slice , name. byte slice, protobuf, , , name , .
. â .
â sync.Pool.
. strconv.FormatInt Go . Int, nSmalls, 99 100. base ( , ) 10. small
, .
? , , 100, .
, , , . . . , , , .
sync.Pool
â .
â . , sync.Pool
byte slice, byte slice'.
â CPUs. (pipeline). pipeline , , , . , . . pipeline .
. , â . , , Meltdown Spectre, - .
. . , â ? API. . ..
Fasthttp , . . . benchmarks. ? - 10 %, . . 10 % 200 %?
. . , 10 %, . Fasthttp , TechEmpower benchmarks. c Fasthttp, net/http
.
Chat télégramme: https://t.me/VictoriaMetrics_ru1