Improve cold start performance

This commit is contained in:
Josh Perez 2021-03-04 16:44:57 -05:00 committed by Josh Perez
parent c73e35b1b6
commit d82ce07942
39 changed files with 911 additions and 628 deletions

24
ts/util/messageBatcher.ts Normal file
View file

@ -0,0 +1,24 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { MessageAttributesType } from '../model-types.d';
import { createBatcher } from './batcher';
import { createWaitBatcher } from './waitBatcher';
export const updateMessageBatcher = createBatcher<MessageAttributesType>({
wait: 500,
maxSize: 50,
processBatch: async (messages: Array<MessageAttributesType>) => {
window.log.info('updateMessageBatcher', messages.length);
await window.Signal.Data.saveMessages(messages, {});
},
});
export const saveNewMessageBatcher = createWaitBatcher<MessageAttributesType>({
wait: 500,
maxSize: 30,
processBatch: async (messages: Array<MessageAttributesType>) => {
window.log.info('saveNewMessageBatcher', messages.length);
await window.Signal.Data.saveMessages(messages, { forceSave: true });
},
});