From 5efa65cd92e63c9eba8fdfd6b935463c314b4ad7 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 27 Mar 2024 05:09:55 +0100 Subject: [PATCH] Defer up to maxEntrySize flushes by default Batching flushes has performance benefits in terms of throughput. Keeping the flush size at maxEntrySize makes the flush times more consistent, as the journal's syncs will be amortized to fit writing maxEntrySize'd entries. JIRA: CONTROLLER-2108 Change-Id: Ie385738f65d9503fdeeed6a9e0b5ced37fde7fd3 Signed-off-by: Robert Varga --- .../akka/segjournal/SegmentedFileJournal.java | 3 +-- .../src/test/resources/SegmentedFileJournalTest.conf | 1 - .../src/main/resources/initial/factory-akka.conf | 10 ++++++---- .../src/test/resources/segmented.conf | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/opendaylight/md-sal/sal-akka-segmented-journal/src/main/java/org/opendaylight/controller/akka/segjournal/SegmentedFileJournal.java b/opendaylight/md-sal/sal-akka-segmented-journal/src/main/java/org/opendaylight/controller/akka/segjournal/SegmentedFileJournal.java index 41a6add0ed..b9320998c9 100644 --- a/opendaylight/md-sal/sal-akka-segmented-journal/src/main/java/org/opendaylight/controller/akka/segjournal/SegmentedFileJournal.java +++ b/opendaylight/md-sal/sal-akka-segmented-journal/src/main/java/org/opendaylight/controller/akka/segjournal/SegmentedFileJournal.java @@ -45,7 +45,6 @@ public class SegmentedFileJournal extends AsyncWriteJournal { public static final String STORAGE_MAX_SEGMENT_SIZE = "max-segment-size"; public static final int STORAGE_MAX_SEGMENT_SIZE_DEFAULT = STORAGE_MAX_ENTRY_SIZE_DEFAULT * 8; public static final String STORAGE_MAX_UNFLUSHED_BYTES = "max-unflushed-bytes"; - public static final int STORAGE_MAX_UNFLUSHED_BYTES_DEFAULT = 0; public static final String STORAGE_MEMORY_MAPPED = "memory-mapped"; private static final Logger LOG = LoggerFactory.getLogger(SegmentedFileJournal.class); @@ -67,7 +66,7 @@ public class SegmentedFileJournal extends AsyncWriteJournal { maxEntrySize = getBytes(config, STORAGE_MAX_ENTRY_SIZE, STORAGE_MAX_ENTRY_SIZE_DEFAULT); maxSegmentSize = getBytes(config, STORAGE_MAX_SEGMENT_SIZE, STORAGE_MAX_SEGMENT_SIZE_DEFAULT); - maxUnflushedBytes = getBytes(config, STORAGE_MAX_UNFLUSHED_BYTES, STORAGE_MAX_UNFLUSHED_BYTES_DEFAULT); + maxUnflushedBytes = getBytes(config, STORAGE_MAX_UNFLUSHED_BYTES, maxEntrySize); if (config.hasPath(STORAGE_MEMORY_MAPPED)) { storage = config.getBoolean(STORAGE_MEMORY_MAPPED) ? StorageLevel.MAPPED : StorageLevel.DISK; diff --git a/opendaylight/md-sal/sal-akka-segmented-journal/src/test/resources/SegmentedFileJournalTest.conf b/opendaylight/md-sal/sal-akka-segmented-journal/src/test/resources/SegmentedFileJournalTest.conf index e391a0dd5d..8fce93b097 100644 --- a/opendaylight/md-sal/sal-akka-segmented-journal/src/test/resources/SegmentedFileJournalTest.conf +++ b/opendaylight/md-sal/sal-akka-segmented-journal/src/test/resources/SegmentedFileJournalTest.conf @@ -8,7 +8,6 @@ akka { root-directory = "target/segmented-journal" max-entry-size = 8M max-segment-size = 32M - max-unflushed-bytes = 256K memory-mapped = false } } diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf index 00be0551f6..9834e08ea8 100644 --- a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf @@ -163,8 +163,9 @@ odl-cluster-data { max-entry-size = 16M # Maximum size of a segment max-segment-size = 128M - # Maximum number of bytes that are written without synchronizing storage - max-unflushed-bytes = 1M + # Maximum number of bytes that are written without synchronizing storage. Defaults to max-entry-size. + # Set to <= 0 to flush immediately. + #max-unflushed-bytes = 1M # Map each segment into memory. Defaults to true, use false to keep a heap-based # buffer instead. memory-mapped = true @@ -183,8 +184,9 @@ odl-cluster-data { max-entry-size = 512K # Maximum size of a segment max-segment-size = 1M - # Maximum number of bytes that are written without synchronizing storage - max-unflushed-bytes = 128K + # Maximum number of bytes that are written without synchronizing storage. Defaults to max-entry-size. + # Set to <= 0 to flush immediately. + #max-unflushed-bytes = 128K # Map each segment into memory. Note that while this can improve performance, # it will also place additional burden on system resources. memory-mapped = false diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf index a21cc3e178..7a0b83212f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf @@ -28,7 +28,6 @@ Member1 { root-directory = "target/segmented-journal" max-entry-size = 8M max-segment-size = 32M - max-unflushed-bytes = 256K memory-mapped = false } } -- 2.36.6