refactor: performance improvements in batch message processing, synchronized cache access and audible message notifications.

Increase audible timeout on DefaultMessageNotifier.java, don't send in-thread notification based on last audible notification.

Create a batch message receive job to handle up to 20 chunked messages at a time per job instead of singular or open group poll amount

Remove synchronized access to recipient cache and replace with a concurrent cache that's lock free from perf tracing monitor contention
This commit is contained in:
Harris
2021-09-29 15:29:24 +10:00
parent 5a290ddf68
commit e036344c76
13 changed files with 700 additions and 52 deletions

View File

@@ -97,7 +97,7 @@ public class DefaultMessageNotifier implements MessageNotifier {
private static final int SUMMARY_NOTIFICATION_ID = 1338;
private static final int PENDING_MESSAGES_ID = 1111;
private static final String NOTIFICATION_GROUP = "messages";
private static final long MIN_AUDIBLE_PERIOD_MILLIS = TimeUnit.SECONDS.toMillis(2);
private static final long MIN_AUDIBLE_PERIOD_MILLIS = TimeUnit.SECONDS.toMillis(5);
private static final long DESKTOP_ACTIVITY_PERIOD = TimeUnit.MINUTES.toMillis(1);
private volatile static long visibleThread = -1;
@@ -440,9 +440,12 @@ public class DefaultMessageNotifier implements MessageNotifier {
private void sendInThreadNotification(Context context, Recipient recipient) {
if (!TextSecurePreferences.isInThreadNotifications(context) ||
ServiceUtil.getAudioManager(context).getRingerMode() != AudioManager.RINGER_MODE_NORMAL)
ServiceUtil.getAudioManager(context).getRingerMode() != AudioManager.RINGER_MODE_NORMAL ||
(System.currentTimeMillis() - lastAudibleNotification) < MIN_AUDIBLE_PERIOD_MILLIS)
{
return;
} else {
lastAudibleNotification = System.currentTimeMillis();
}
Uri uri = null;