Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
mydump: set read block buffer size to BlockSize * 5
Browse files Browse the repository at this point in the history
  • Loading branch information
lonng committed Dec 30, 2018
1 parent eb011cd commit c15fa92
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lightning/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func NewConfig() *Config {
App: Lightning{
RegionConcurrency: runtime.NumCPU(),
TableConcurrency: 8,
IOConcurrency: 2,
IOConcurrency: 5,
CheckRequirements: true,
},
TiDB: DBStore{
Expand Down
2 changes: 2 additions & 0 deletions lightning/config/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const (
ReadBlockSize int64 = 64 * _K
MinRegionSize int64 = 256 * _M

BufferSizeScale = 5

// kv import
KVMaxBatchSize int64 = 200 * _G
)
4 changes: 2 additions & 2 deletions lightning/metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ var (
prometheus.HistogramOpts{
Namespace: "lightning",
Name: "chunk_parser_read_block_seconds",
Help: "time needed to chunk parser read a block",
Help: "time needed for chunk parser read a block",
Buckets: prometheus.ExponentialBuckets(0.001, 3.1622776601683795, 10),
},
)
ChunkParserReadRowSecondsHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "lightning",
Name: "chunk_parser_read_row_seconds",
Help: "time needed to chunk parser read a row",
Help: "time needed for chunk parser read a row",
Buckets: prometheus.ExponentialBuckets(0.001, 3.1622776601683795, 10),
},
)
Expand Down
5 changes: 3 additions & 2 deletions lightning/mydump/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/pkg/errors"

"github.com/pingcap/tidb-lightning/lightning/config"
"github.com/pingcap/tidb-lightning/lightning/metric"
"github.com/pingcap/tidb-lightning/lightning/worker"
)
Expand Down Expand Up @@ -54,7 +55,7 @@ type Row struct {
func NewChunkParser(reader io.Reader, blockBufSize int64, ioWorkers *worker.RestoreWorkerPool) *ChunkParser {
return &ChunkParser{
reader: reader,
blockBuf: make([]byte, blockBufSize),
blockBuf: make([]byte, blockBufSize*config.BufferSizeScale),
remainBuf: &bytes.Buffer{},
appendBuf: &bytes.Buffer{},
ioWorkers: ioWorkers,
Expand Down Expand Up @@ -92,7 +93,7 @@ func (parser *ChunkParser) readBlock() error {
// limit IO concurrency
w := parser.ioWorkers.Apply()
n, err := parser.reader.Read(parser.blockBuf)
defer parser.ioWorkers.Recycle(w)
parser.ioWorkers.Recycle(w)

switch err {
case io.ErrUnexpectedEOF, io.EOF:
Expand Down
7 changes: 6 additions & 1 deletion tidb-lightning.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ table-concurrency = 8
# region-concurrency changes the concurrency number of data. It is set to the number of logical CPU cores by default and needs no configuration.
# In mixed configuration, you can set it to 75% of the size of logical CPU cores.
# region-concurrency default to runtime.NumCPU()

# region-concurrency =
# io-concurrency controls the maximum io concurrent
# io-concurrency = 2
# Excessive IO concurrency causes an increase in IO latency because the disk
# internal buffer is frequently refreshed causing a cache miss. For different
# disk media, concurrency has different effects on IO latency, which can be
# adjusted according to monitoring.
# io-concurrency = 5

# logging
level = "info"
Expand Down

0 comments on commit c15fa92

Please sign in to comment.