-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed bug with mixing headers on map buckets rebalancing; * Added internal option to disable write batching; * Fixed bug in file requests decoding; * Downgrade grpc library version; * All http/2 setting frame options considiration; * Fixed bug in GOAWAY frame processing; * Decreased memory allocation for each connection; * More stream lifecycles capturing; * Fixed conflict with C# grpc server.
- Loading branch information
Showing
50 changed files
with
1,352 additions
and
601 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
debug |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ services: | |
resources: | ||
limits: | ||
cpus: '2' | ||
memory: 3G | ||
memory: 2G |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
package consts | ||
|
||
import "time" | ||
import ( | ||
"math" | ||
"time" | ||
) | ||
|
||
const ( | ||
ChunksBufferSize = 2048 | ||
RecieveBufferSize = 2048 | ||
SendBatchTimeout = time.Millisecond | ||
RecieveBatchTimeout = time.Millisecond | ||
|
||
DefaultInitialWindowSize = 65_535 | ||
DefaultTimeout = 11 * time.Second | ||
DefaultMaxFrameSize = 16384 // Максимальная длина пейлоада фрейма в grpc. У http2 ограничение больше. | ||
DefaultMaxHeaderListSize = math.MaxUint32 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package decoder | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/ozontech/framer/utils/lru" | ||
) | ||
|
||
type Decoder struct { | ||
metaUnmarshaler *SafeMultiValDecoder | ||
|
||
tagsLRU *lru.LRU | ||
methodsLRU *lru.LRU | ||
} | ||
|
||
func NewDecoder() *Decoder { | ||
return &Decoder{ | ||
metaUnmarshaler: NewSafeMultiValDecoder(), | ||
|
||
tagsLRU: lru.New(1024), | ||
methodsLRU: lru.New(1024), | ||
} | ||
} | ||
|
||
func (decoder *Decoder) Unmarshal(d *Data, b []byte) error { | ||
d.Reset() | ||
|
||
tagB, b := nextLine(b) | ||
d.Tag = decoder.tagsLRU.GetOrAdd(tagB) | ||
|
||
methodB, b := nextLine(b) | ||
d.Method = decoder.methodsLRU.GetOrAdd(methodB) | ||
|
||
metaBytes, b := nextLine(b) | ||
var err error | ||
d.Metadata, err = decoder.metaUnmarshaler.UnmarshalAppend(d.Metadata, metaBytes) | ||
if err != nil { | ||
return fmt.Errorf("meta unmarshal error: %w", err) | ||
} | ||
|
||
d.Message = b | ||
return nil | ||
} | ||
|
||
func nextLine(in []byte) ([]byte, []byte) { | ||
index := bytes.IndexByte(in, '\n') | ||
if index == -1 { | ||
return []byte{}, []byte{} | ||
} | ||
return in[:index], in[index+1:] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package decoder | ||
|
||
import ( | ||
"github.com/mailru/easyjson/jlexer" | ||
"github.com/ozontech/framer/utils/lru" | ||
) | ||
|
||
const ( | ||
kLRUSize = 1 << 10 | ||
vLRUSize = 1 << 16 | ||
) | ||
|
||
type SafeMultiValDecoder struct { | ||
kLRU *lru.LRU | ||
vLRU *lru.LRU | ||
} | ||
|
||
func NewSafeMultiValDecoder() *SafeMultiValDecoder { | ||
return &SafeMultiValDecoder{ | ||
lru.New(kLRUSize), | ||
lru.New(vLRUSize), | ||
} | ||
} | ||
|
||
func (d *SafeMultiValDecoder) UnmarshalAppend(buf []Meta, bytes []byte) ([]Meta, error) { | ||
in := jlexer.Lexer{Data: bytes} | ||
|
||
in.Delim('{') | ||
for !in.IsDelim('}') { | ||
key := d.kLRU.GetOrAdd(in.UnsafeBytes()) | ||
in.WantColon() | ||
|
||
in.Delim('[') | ||
for !in.IsDelim(']') { | ||
val := d.kLRU.GetOrAdd(in.UnsafeBytes()) | ||
buf = append(buf, Meta{Name: key, Value: val}) | ||
in.WantComma() | ||
} | ||
in.Delim(']') | ||
|
||
in.WantComma() | ||
} | ||
in.Delim('}') | ||
in.Consumed() | ||
|
||
return buf, in.Error() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package decoder | ||
|
||
type Meta struct { | ||
Name string | ||
Value string | ||
} | ||
|
||
type Data struct { | ||
Tag string | ||
Method string // "/" {service name} "/" {method name} | ||
Metadata []Meta | ||
Message []byte | ||
} | ||
|
||
func (d *Data) Reset() { | ||
d.Tag = "" | ||
d.Method = "" | ||
d.Metadata = d.Metadata[:0] | ||
d.Message = d.Message[:0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.