diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/rawdb/freezer.go | 6 | ||||
-rw-r--r-- | core/rawdb/freezer_table.go | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/core/rawdb/freezer.go b/core/rawdb/freezer.go index 67ed87d66..33da53787 100644 --- a/core/rawdb/freezer.go +++ b/core/rawdb/freezer.go @@ -66,8 +66,12 @@ const ( // reserving it for go-ethereum. This would also reduce the memory requirements // of Geth, and thus also GC overhead. type freezer struct { + // WARNING: The `frozen` field is accessed atomically. On 32 bit platforms, only + // 64-bit aligned fields can be atomic. The struct is guaranteed to be so aligned, + // so take advantage of that (https://golang.org/pkg/sync/atomic/#pkg-note-BUG). + frozen uint64 // Number of blocks already frozen + tables map[string]*freezerTable // Data tables for storing everything - frozen uint64 // Number of blocks already frozen instanceLock fileutil.Releaser // File-system lock to prevent double opens } diff --git a/core/rawdb/freezer_table.go b/core/rawdb/freezer_table.go index 673a181e4..d1ece414b 100644 --- a/core/rawdb/freezer_table.go +++ b/core/rawdb/freezer_table.go @@ -73,6 +73,11 @@ func (i *indexEntry) marshallBinary() []byte { // It consists of a data file (snappy encoded arbitrary data blobs) and an indexEntry // file (uncompressed 64 bit indices into the data file). type freezerTable struct { + // WARNING: The `items` field is accessed atomically. On 32 bit platforms, only + // 64-bit aligned fields can be atomic. The struct is guaranteed to be so aligned, + // so take advantage of that (https://golang.org/pkg/sync/atomic/#pkg-note-BUG). + items uint64 // Number of items stored in the table (including items removed from tail) + noCompression bool // if true, disables snappy compression. Note: does not work retroactively maxFileSize uint32 // Max file size for data-files name string @@ -86,7 +91,6 @@ type freezerTable struct { // In the case that old items are deleted (from the tail), we use itemOffset // to count how many historic items have gone missing. - items uint64 // Number of items stored in the table (including items removed from tail) itemOffset uint32 // Offset (number of discarded items) headBytes uint32 // Number of bytes written to the head file |