option

package
v1.12.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 0 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultDecoderBufferSize is the initial buffer size of StreamDecoder
	DefaultDecoderBufferSize uint = 4 * 1024

	// DefaultEncoderBufferSize is the initial buffer size of Encoder
	DefaultEncoderBufferSize uint = 4 * 1024

	// DefaultAstBufferSize is the initial buffer size of ast.Node.MarshalJSON()
	DefaultAstBufferSize uint = 4 * 1024

	// LimitBufferSize indicates the max pool buffer size, in case of OOM.
	// See issue https://github.com/bytedance/sonic/issues/614
	LimitBufferSize uint = 1024 * 1024
)
View Source
var (
	// Default value(3) means the compiler only inline 3 layers of nested struct.
	// when the depth exceeds, the compiler will recurse
	// and compile subsequent structs when they are decoded
	DefaultMaxInlineDepth = 3

	// Default value(1) means `Pretouch()` will be recursively executed once,
	// if any nested struct is left (depth exceeds MaxInlineDepth)
	DefaultRecursiveDepth = 1
)

Functions

This section is empty.

Types

type CompileOption

type CompileOption func(o *CompileOptions)

CompileOption is a function used to change DefaultCompileOptions.

func WithCompileMaxInlineDepth added in v1.4.0

func WithCompileMaxInlineDepth(depth int) CompileOption

WithCompileMaxInlineDepth sets the max depth of inline compile in decoder and encoder.

For large nested struct, try to set smaller depth to reduce compiling time.

func WithCompileRecursiveDepth

func WithCompileRecursiveDepth(loop int) CompileOption

WithCompileRecursiveDepth sets the loop times of recursive pretouch in both decoder and encoder, for both concrete type and its pointer type.

For deep nested struct (depth exceeds MaxInlineDepth), try to set more loops to completely compile, thus reduce JIT unstability in the first hit.

type CompileOptions

type CompileOptions struct {
	// the maximum depth for compilation inline
	MaxInlineDepth int

	// the loop times for recursively pretouch
	RecursiveDepth int
}

CompileOptions includes all options for encoder or decoder compiler.

func DefaultCompileOptions

func DefaultCompileOptions() CompileOptions

DefaultCompileOptions set default compile options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL