Decrypt and process messages in batches.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-09-14 10:00:34 -04:00
parent 9987ebb3c0
commit e39b9169b9
4 changed files with 18 additions and 9 deletions

View file

@ -299,8 +299,7 @@ NSString *const OWSBatchMessageProcessingJobFinderExtensionGroup = @"OWSBatchMes
{
AssertIsOnMainThread();
const NSUInteger kMaxBatchSize = 10;
NSArray<OWSBatchMessageProcessingJob *> *jobs = [self.finder nextJobsForBatchSize:kMaxBatchSize];
NSArray<OWSBatchMessageProcessingJob *> *jobs = [self.finder nextJobsForBatchSize:kIncomingMessageBatchSize];
OWSAssert(jobs);
if (jobs.count < 1) {
self.isDrainingQueue = NO;

View file

@ -294,8 +294,7 @@ NSString *const OWSMessageProcessingJobFinderExtensionGroup = @"OWSMessageProces
{
AssertIsOnMainThread();
const NSUInteger kMaxBatchSize = 10;
NSArray<OWSMessageProcessingJob *> *jobs = [self.finder nextJobsForBatchSize:kMaxBatchSize];
NSArray<OWSMessageProcessingJob *> *jobs = [self.finder nextJobsForBatchSize:kIncomingMessageBatchSize];
OWSAssert(jobs);
if (jobs.count < 1) {
self.isDrainingQueue = NO;

View file

@ -8,6 +8,8 @@
NS_ASSUME_NONNULL_BEGIN
extern const NSUInteger kIncomingMessageBatchSize;
@class TSNetworkManager;
@class TSStorageManager;
@class OWSSignalServiceProtosEnvelope;

View file

@ -45,6 +45,15 @@
NS_ASSUME_NONNULL_BEGIN
// We need to use a consistent batch size throughout
// the incoming message pipeline (i.e. in the
// "decrypt" and "process" steps), or the pipeline
// doesn't flow smoothly.
//
// We want a value that is just high enough to yield
// perf benefits. The right value is probably 5-15.
const NSUInteger kIncomingMessageBatchSize = 10;
@interface TSMessagesManager ()
@property (nonatomic, readonly) id<OWSCallMessageHandler> callMessageHandler;
@ -1087,13 +1096,13 @@ NS_ASSUME_NONNULL_BEGIN
}
case OWSSignalServiceProtosGroupContextTypeDeliver: {
if (body.length == 0 && attachmentIds.count < 1) {
DDLogWarn(@"%@ ignoring empty incoming message from: %@ for group: %@ with timestampe: %lu",
DDLogWarn(@"%@ ignoring empty incoming message from: %@ for group: %@ with timestamp: %lu",
self.tag,
envelopeAddress(envelope),
groupId,
(unsigned long)timestamp);
} else {
DDLogDebug(@"%@ incoming message from: %@ for group: %@ with timestampe: %lu",
DDLogDebug(@"%@ incoming message from: %@ for group: %@ with timestamp: %lu",
self.tag,
envelopeAddress(envelope),
groupId,
@ -1111,19 +1120,19 @@ NS_ASSUME_NONNULL_BEGIN
break;
}
default: {
DDLogWarn(@"%@ Ignoring unknown group message type:%d", self.tag, (int)dataMessage.group.type);
DDLogWarn(@"%@ Ignoring unknown group message type: %d", self.tag, (int)dataMessage.group.type);
}
}
thread = gThread;
} else {
if (body.length == 0 && attachmentIds.count < 1) {
DDLogWarn(@"%@ ignoring empty incoming message from: %@ with timestampe: %lu",
DDLogWarn(@"%@ ignoring empty incoming message from: %@ with timestamp: %lu",
self.tag,
envelopeAddress(envelope),
(unsigned long)timestamp);
} else {
DDLogDebug(@"%@ incoming message from: %@ with timestampe: %lu",
DDLogDebug(@"%@ incoming message from: %@ with timestamp: %lu",
self.tag,
envelopeAddress(envelope),
(unsigned long)timestamp);