-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Write-Ahead Logging](https://sqlite.org/wal.html) is both much more performant in general, and more suited to our particular access patterns. With a simple throughput performance test, it improves performance by a factor of 5-20x depending on the sync flag. version | throughput -------------------------------|------------- mode=journal sync=normal (*)| 11 htlc/s mode=journal sync=full| 7 htlc/s mode=wal sync=normal| 248 htlc/s mode=wal sync=full (**)| 62 htlc/s (*) previous setting (**) new setting I went with a conservative new setting of wal+full sync, which is both 5x more performant, and more secure than what we had before. > In WAL mode when synchronous is NORMAL (1), the WAL file is synchronized before each checkpoint and the database file is synchronized after each completed checkpoint and the WAL file header is synchronized when a WAL file begins to be reused after a checkpoint, but no sync operations occur during most transactions. With synchronous=FULL in WAL mode, an additional sync operation of the WAL file happens after each transaction commit. The extra WAL sync following each transaction help ensure that transactions are durable across a power loss. Transactions are consistent with or without the extra syncs provided by synchronous=FULL. If durability is not a concern, then synchronous=NORMAL is normally all one needs in WAL mode. Co-authored-by: Bastien Teinturier <[email protected]>
- Loading branch information
Showing
5 changed files
with
171 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
eclair-core/src/test/scala/fr/acinq/eclair/integration/PerformanceIntegrationSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Copyright 2019 ACINQ SAS | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package fr.acinq.eclair.integration | ||
|
||
import akka.testkit.TestProbe | ||
import com.typesafe.config.ConfigFactory | ||
import fr.acinq.bitcoin.SatoshiLong | ||
import fr.acinq.eclair.MilliSatoshiLong | ||
import fr.acinq.eclair.channel._ | ||
import fr.acinq.eclair.payment._ | ||
import fr.acinq.eclair.payment.receive.MultiPartHandler.ReceivePayment | ||
import fr.acinq.eclair.payment.send.MultiPartPaymentLifecycle.PreimageReceived | ||
import fr.acinq.eclair.payment.send.PaymentInitiator | ||
import fr.acinq.eclair.router.Router | ||
import org.scalatest.Ignore | ||
|
||
import java.util.UUID | ||
import java.util.concurrent.Executors | ||
import scala.concurrent.duration._ | ||
import scala.concurrent.{Await, ExecutionContext, Future} | ||
import scala.jdk.CollectionConverters._ | ||
|
||
/** | ||
* Created by PM on 12/07/2021. | ||
*/ | ||
|
||
@Ignore | ||
class PerformanceIntegrationSpec extends IntegrationSpec { | ||
|
||
test("start eclair nodes") { | ||
val commonPerfTestConfig = ConfigFactory.parseMap(Map( | ||
"eclair.max-funding-satoshis" -> 100_000_000, | ||
"eclair.max-accepted-htlcs" -> Channel.MAX_ACCEPTED_HTLCS, | ||
"eclair.file-backup.enabled" -> false, | ||
).asJava) | ||
|
||
instantiateEclairNode("A", ConfigFactory.parseMap(Map("eclair.node-alias" -> "A", "eclair.server.port" -> 29730).asJava).withFallback(commonPerfTestConfig).withFallback(commonFeatures).withFallback(commonConfig)) // A's channels are private | ||
instantiateEclairNode("B", ConfigFactory.parseMap(Map("eclair.node-alias" -> "B", "eclair.server.port" -> 29731).asJava).withFallback(commonPerfTestConfig).withFallback(commonFeatures).withFallback(commonConfig)) | ||
} | ||
|
||
test("connect nodes") { | ||
// A---B | ||
|
||
val eventListener = TestProbe() | ||
nodes.values.foreach(_.system.eventStream.subscribe(eventListener.ref, classOf[ChannelStateChanged])) | ||
|
||
connect(nodes("A"), nodes("B"), 100_000_000 sat, 0 msat) | ||
|
||
// confirming the funding tx | ||
generateBlocks(6) | ||
|
||
within(60 seconds) { | ||
eventListener.expectMsgType[ChannelStateChanged](60 seconds).currentState == NORMAL | ||
} | ||
} | ||
|
||
test("wait for channels") { | ||
// Channels should now be available in the router | ||
val sender = TestProbe() | ||
awaitCond({ | ||
sender.send(nodes("A").router, Router.GetRoutingState) | ||
val routingState = sender.expectMsgType[Router.RoutingState] | ||
routingState.channels.nonEmpty | ||
}, 60 seconds) | ||
} | ||
|
||
def sendPayment()(implicit ec: ExecutionContext): Future[PaymentSent] = Future { | ||
val sender = TestProbe() | ||
val amountMsat = 100_000.msat | ||
// first we retrieve a payment hash from B | ||
sender.send(nodes("B").paymentHandler, ReceivePayment(Some(amountMsat), "1 coffee")) | ||
val pr = sender.expectMsgType[PaymentRequest] | ||
// then we make the actual payment | ||
sender.send(nodes("A").paymentInitiator, PaymentInitiator.SendPayment(amountMsat, pr, fallbackFinalExpiryDelta = finalCltvExpiryDelta, routeParams = integrationTestRouteParams, maxAttempts = 1)) | ||
val paymentId = sender.expectMsgType[UUID] | ||
sender.expectMsgType[PreimageReceived] | ||
val ps = sender.expectMsgType[PaymentSent] | ||
assert(ps.id == paymentId) | ||
ps | ||
} | ||
|
||
test("send a large number of htlcs A->B") { | ||
val SENDERS_COUNT = 16 | ||
val PAYMENTS_COUNT = 3_000 | ||
val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(SENDERS_COUNT)) | ||
val start = System.currentTimeMillis() | ||
val futures = (0 until PAYMENTS_COUNT).map(_ => sendPayment()(ec)) | ||
implicit val dummyEc: ExecutionContext = ExecutionContext.Implicits.global | ||
val f = Future.sequence(futures) | ||
Await.result(f, 1 hour) | ||
val end = System.currentTimeMillis() | ||
val duration = end - start | ||
println(s"$PAYMENTS_COUNT payments in ${duration}ms ${PAYMENTS_COUNT * 1000 / duration}htlc/s (senders=$SENDERS_COUNT)") | ||
} | ||
|
||
} |