Skip to content

Commit

Permalink
freezer: disable compression on hashes and difficulties (#14)
Browse files Browse the repository at this point in the history
* freezer: disable compression on hashes and difficulties

* core/rawdb: address review concerns

* core/rawdb: address review concerns
  • Loading branch information
holiman authored and karalabe committed May 16, 2019
1 parent 331de17 commit 42c746d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/rawdb/freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func newFreezer(datadir string, namespace string) (*freezer, error) {
tables: make(map[string]*freezerTable),
instanceLock: lock,
}
for _, name := range []string{freezerHashTable, freezerHeaderTable, freezerBodiesTable, freezerReceiptTable, freezerDifficultyTable} {
table, err := newTable(datadir, name, readMeter, writeMeter)
for name, disableSnappy := range freezerNoSnappy {
table, err := newTable(datadir, name, readMeter, writeMeter, disableSnappy)
if err != nil {
for _, table := range freezer.tables {
table.Close()
Expand Down
6 changes: 3 additions & 3 deletions core/rawdb/freezer_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ type freezerTable struct {
lock sync.RWMutex // Mutex protecting the data file descriptors
}

// newTable opens a freezer table with default settings - 2G files and snappy compression
func newTable(path string, name string, readMeter metrics.Meter, writeMeter metrics.Meter) (*freezerTable, error) {
return newCustomTable(path, name, readMeter, writeMeter, 2*1000*1000*1000, false)
// newTable opens a freezer table with default settings - 2G files
func newTable(path string, name string, readMeter metrics.Meter, writeMeter metrics.Meter, disableSnappy bool) (*freezerTable, error) {
return newCustomTable(path, name, readMeter, writeMeter, 2*1000*1000*1000, disableSnappy)
}

// newCustomTable opens a freezer table, creating the data and index files if they are
Expand Down
10 changes: 10 additions & 0 deletions core/rawdb/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ const (
freezerDifficultyTable = "diffs"
)

// freezerNoSnappy configures whether compression is disabled for the ancient-tables.
// Hashes and difficulties don't compress well.
var freezerNoSnappy = map[string]bool{
freezerHeaderTable: false,
freezerHashTable: true,
freezerBodiesTable: false,
freezerReceiptTable: false,
freezerDifficultyTable: true,
}

// LegacyTxLookupEntry is the legacy TxLookupEntry definition with some unnecessary
// fields.
type LegacyTxLookupEntry struct {
Expand Down

0 comments on commit 42c746d

Please sign in to comment.