-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: Reducing memory cost while replaying #765
Conversation
@@ -118,7 +118,7 @@ class JdbcAsyncWriteJournal(config: Config) extends AsyncWriteJournal { | |||
journalDao | |||
.messagesWithBatch(persistenceId, fromSequenceNr, toSequenceNr, journalConfig.daoConfig.replayBatchSize, None) | |||
.take(max) | |||
.mapAsync(1)(reprAndOrdNr => Future.fromTry(reprAndOrdNr)) | |||
.collect { case Success(reprAndOrdNr) => reprAndOrdNr } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has different behaviour than the original logic though, that would fail the stream on a Failure while this filters it out. Better would be to skip this operator/step completely and do the match in runForEach
and throw for Failure there:
.runForeach {
case Success((repr, _)) =>
recoveryCallback(repr)
case Failure(ex) => throw ex
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More effiency, Yay!
[info] Benchmark Mode Cnt Score Error Units
[info] JdbcAsyncJournalBenchmark.originalAsync thrpt 3 581405.864 ± 217516.676 ops/s
[info] JdbcAsyncJournalBenchmark.streamWithCollect thrpt 3 594420.619 ± 29680.962 ops/s
[info] Benchmark Mode Cnt Score Error Units
[info] JdbcAsyncJournalBenchmark.originalAsync thrpt 3 577291.504 ± 51386.930 ops/s
[info] JdbcAsyncJournalBenchmark.streamWithCollect thrpt 3 605493.214 ± 4152.262 ops/s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Push my commit again, because i havn't permission to apply this request change,
272e013
to
9cbe433
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
No References.
Motivation:
Reducing memory cost on replaying query stream
Result
Additional bonus: slight performance improvement.
JMH for this change: https://gist.github.com/Roiocam/aabbf404aa2e1a4e967967e450b0def0