Skip to content

Commit 62d51fd

Browse files
committed
increase file write buffer size
1 parent 9e4cbe5 commit 62d51fd

File tree

10 files changed

+29
-21
lines changed

10 files changed

+29
-21
lines changed

statediff/indexer/database/file/writer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import (
3131
)
3232

3333
var (
34-
nullHash = common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000")
35-
pipeSize = 65336 // min(linuxPipeSize, macOSPipeSize)
36-
collatedStmtSize = pipeSize * 16
34+
nullHash = common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000")
35+
pipeSize = 65336 // min(linuxPipeSize, macOSPipeSize)
36+
writeBufferSize = pipeSize * 16 * 48
3737
)
3838

3939
// SQLWriter writes sql statements to a file
@@ -54,7 +54,7 @@ func NewSQLWriter(wc io.WriteCloser) *SQLWriter {
5454
return &SQLWriter{
5555
wc: wc,
5656
stmts: make(chan []byte),
57-
collatedStmt: make([]byte, collatedStmtSize),
57+
collatedStmt: make([]byte, writeBufferSize),
5858
flushChan: make(chan struct{}),
5959
flushFinished: make(chan struct{}),
6060
quitChan: make(chan struct{}),
@@ -74,7 +74,7 @@ func (sqw *SQLWriter) Loop() {
7474
select {
7575
case stmt := <-sqw.stmts:
7676
l = len(stmt)
77-
if l+sqw.collationIndex+1 > collatedStmtSize {
77+
if sqw.collationIndex+l > writeBufferSize {
7878
if err := sqw.flush(); err != nil {
7979
panic(fmt.Sprintf("error writing sql stmts buffer to file: %v", err))
8080
}

statediff/indexer/ipld/eth_header.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import (
2020
"encoding/json"
2121
"fmt"
2222

23-
"github.com/ethereum/go-ethereum/common"
24-
25-
"github.com/ethereum/go-ethereum/core/types"
26-
"github.com/ethereum/go-ethereum/rlp"
2723
"github.com/ipfs/go-cid"
2824
node "github.com/ipfs/go-ipld-format"
2925
mh "github.com/multiformats/go-multihash"
26+
27+
"github.com/ethereum/go-ethereum/common"
28+
"github.com/ethereum/go-ethereum/core/types"
29+
"github.com/ethereum/go-ethereum/rlp"
3030
)
3131

3232
// EthHeader (eth-block, codec 0x90), represents an ethereum block header

statediff/indexer/ipld/eth_header_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import (
99
"strconv"
1010
"testing"
1111

12-
"github.com/ethereum/go-ethereum/core/types"
1312
block "github.com/ipfs/go-block-format"
1413
node "github.com/ipfs/go-ipld-format"
1514
"github.com/multiformats/go-multihash"
15+
16+
"github.com/ethereum/go-ethereum/core/types"
1617
)
1718

1819
func TestBlockBodyRlpParsing(t *testing.T) {

statediff/indexer/ipld/eth_log.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package ipld
33
import (
44
"fmt"
55

6-
"github.com/ethereum/go-ethereum/core/types"
7-
"github.com/ethereum/go-ethereum/rlp"
86
"github.com/ipfs/go-cid"
97
node "github.com/ipfs/go-ipld-format"
108
mh "github.com/multiformats/go-multihash"
9+
10+
"github.com/ethereum/go-ethereum/core/types"
11+
"github.com/ethereum/go-ethereum/rlp"
1112
)
1213

1314
// EthLog (eth-log, codec 0x9a), represents an ethereum block header

statediff/indexer/ipld/eth_log_trie.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package ipld
33
import (
44
"fmt"
55

6-
"github.com/ethereum/go-ethereum/core/types"
7-
"github.com/ethereum/go-ethereum/rlp"
86
"github.com/ipfs/go-cid"
97
"github.com/multiformats/go-multihash"
8+
9+
"github.com/ethereum/go-ethereum/core/types"
10+
"github.com/ethereum/go-ethereum/rlp"
1011
)
1112

1213
// EthLogTrie (eth-tx-trie codec 0x9p) represents

statediff/indexer/ipld/eth_parser.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ import (
2323
"io"
2424
"io/ioutil"
2525

26+
"github.com/ipfs/go-cid"
27+
"github.com/multiformats/go-multihash"
28+
2629
"github.com/ethereum/go-ethereum/common"
2730
"github.com/ethereum/go-ethereum/core/types"
2831
"github.com/ethereum/go-ethereum/rlp"
29-
"github.com/ipfs/go-cid"
30-
"github.com/multiformats/go-multihash"
3132
)
3233

3334
// FromBlockRLP takes an RLP message representing

statediff/indexer/ipld/eth_parser_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import (
2121
"path/filepath"
2222
"testing"
2323

24+
"github.com/stretchr/testify/require"
25+
2426
"github.com/ethereum/go-ethereum/core/types"
2527
"github.com/ethereum/go-ethereum/rlp"
2628
"github.com/ethereum/go-ethereum/statediff/indexer/mocks"
27-
"github.com/stretchr/testify/require"
2829
)
2930

3031
type kind string

statediff/indexer/ipld/eth_receipt.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import (
2121
"fmt"
2222
"strconv"
2323

24-
"github.com/ethereum/go-ethereum/core/types"
2524
"github.com/ipfs/go-cid"
2625
node "github.com/ipfs/go-ipld-format"
2726
mh "github.com/multiformats/go-multihash"
27+
28+
"github.com/ethereum/go-ethereum/core/types"
2829
)
2930

3031
type EthReceipt struct {

statediff/indexer/ipld/eth_tx.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import (
2222
"strconv"
2323
"strings"
2424

25-
"github.com/ethereum/go-ethereum/common/hexutil"
26-
"github.com/ethereum/go-ethereum/core/types"
2725
"github.com/ipfs/go-cid"
2826
node "github.com/ipfs/go-ipld-format"
2927
mh "github.com/multiformats/go-multihash"
28+
29+
"github.com/ethereum/go-ethereum/common/hexutil"
30+
"github.com/ethereum/go-ethereum/core/types"
3031
)
3132

3233
// EthTx (eth-tx codec 0x93) represents an ethereum transaction

statediff/indexer/ipld/trie_node.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import (
2020
"encoding/json"
2121
"fmt"
2222

23-
"github.com/ethereum/go-ethereum/rlp"
2423
"github.com/ipfs/go-cid"
2524
node "github.com/ipfs/go-ipld-format"
25+
26+
"github.com/ethereum/go-ethereum/rlp"
2627
)
2728

2829
const (

0 commit comments

Comments
 (0)