add some performance measure for commit calls

pull/1783/head
Audric Ackermann 4 years ago
parent ca331b95a6
commit a0afd3efe4
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 176 KiB

@ -20,7 +20,7 @@
"start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=$MULTI electron .", "start-swarm-test": "cross-env NODE_ENV=swarm-testing NODE_APP_INSTANCE=$MULTI electron .",
"grunt": "grunt", "grunt": "grunt",
"grunt:dev": "yarn clean-transpile; yarn grunt dev --force", "grunt:dev": "yarn clean-transpile; yarn grunt dev --force",
"icon-gen": "cp images/session/session_icon_1024.png --output=./build/icon.png", "icon-gen": "cp images/session/session_icon_1024.png ./build/icon.png",
"generate": "yarn icon-gen && yarn grunt --force", "generate": "yarn icon-gen && yarn grunt --force",
"build-release": "cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release", "build-release": "cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release",
"build-module-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long", "build-module-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long",

@ -37,6 +37,7 @@ import { IMAGE_JPEG } from '../types/MIME';
import { FSv2 } from '../fileserver'; import { FSv2 } from '../fileserver';
import { fromBase64ToArray, toHex } from '../session/utils/String'; import { fromBase64ToArray, toHex } from '../session/utils/String';
import { SessionButtonColor } from '../components/session/SessionButton'; import { SessionButtonColor } from '../components/session/SessionButton';
import { perfEnd, perfStart } from '../session/utils/Performamce';
export const getCompleteUrlForV2ConvoId = async (convoId: string) => { export const getCompleteUrlForV2ConvoId = async (convoId: string) => {
if (convoId.match(openGroupV2ConversationIdRegex)) { if (convoId.match(openGroupV2ConversationIdRegex)) {
@ -254,7 +255,10 @@ export function showRemoveModeratorsByConvoId(conversationId: string) {
export async function markAllReadByConvoId(conversationId: string) { export async function markAllReadByConvoId(conversationId: string) {
const conversation = getConversationController().get(conversationId); const conversation = getConversationController().get(conversationId);
perfStart(`markAllReadByConvoId-${conversationId}`);
await conversation.markReadBouncy(Date.now()); await conversation.markReadBouncy(Date.now());
perfEnd(`markAllReadByConvoId-${conversationId}`, 'markAllReadByConvoId');
} }
export async function setNotificationForConvoId( export async function setNotificationForConvoId(
@ -354,7 +358,7 @@ export async function uploadOurAvatar(newAvatarDecrypted?: ArrayBuffer) {
// this is a reupload. no need to generate a new profileKey // this is a reupload. no need to generate a new profileKey
profileKey = window.textsecure.storage.get('profileKey'); profileKey = window.textsecure.storage.get('profileKey');
if (!profileKey) { if (!profileKey) {
window.log.warn('our profileKey not found'); window.log.info('our profileKey not found');
return; return;
} }
const currentAttachmentPath = ourConvo.getAvatarPath(); const currentAttachmentPath = ourConvo.getAvatarPath();

@ -45,6 +45,7 @@ import { useDispatch } from 'react-redux';
import { updateConfirmModal } from '../state/ducks/modalDialog'; import { updateConfirmModal } from '../state/ducks/modalDialog';
import { createTaskWithTimeout } from '../session/utils/TaskWithTimeout'; import { createTaskWithTimeout } from '../session/utils/TaskWithTimeout';
import { DURATION, SWARM_POLLING_TIMEOUT } from '../session/constants'; import { DURATION, SWARM_POLLING_TIMEOUT } from '../session/constants';
import { perfEnd, perfStart } from '../session/utils/Performamce';
export enum ConversationTypeEnum { export enum ConversationTypeEnum {
GROUP = 'group', GROUP = 'group',
@ -858,6 +859,8 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
} }
public async commit() { public async commit() {
perfStart(`conversationCommit-${this.attributes.id}`);
// write to DB // write to DB
await updateConversation(this.attributes); await updateConversation(this.attributes);
window.inboxStore?.dispatch( window.inboxStore?.dispatch(
@ -866,6 +869,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
isSelected: false, isSelected: false,
}) })
); );
perfEnd(`conversationCommit-${this.attributes.id}`, 'conversationCommit');
} }
public async addSingleMessage(messageAttributes: MessageAttributesOptionals, setToExpire = true) { public async addSingleMessage(messageAttributes: MessageAttributesOptionals, setToExpire = true) {

@ -35,6 +35,7 @@ import { OpenGroupVisibleMessage } from '../session/messages/outgoing/visibleMes
import { getV2OpenGroupRoom } from '../data/opengroups'; import { getV2OpenGroupRoom } from '../data/opengroups';
import { getMessageController } from '../session/messages'; import { getMessageController } from '../session/messages';
import { isUsFromCache } from '../session/utils/User'; import { isUsFromCache } from '../session/utils/User';
import { perfEnd, perfStart } from '../session/utils/Performamce';
export class MessageModel extends Backbone.Model<MessageAttributes> { export class MessageModel extends Backbone.Model<MessageAttributes> {
public propsForTimerNotification: any; public propsForTimerNotification: any;
@ -73,18 +74,22 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
// Keep props ready // Keep props ready
public generateProps(triggerEvent = true) { public generateProps(triggerEvent = true) {
if (this.isExpirationTimerUpdate()) { const propsForTimerNotification = this.isExpirationTimerUpdate()
this.propsForTimerNotification = this.getPropsForTimerNotification(); ? this.getPropsForTimerNotification()
} else if (this.isGroupUpdate()) { : null;
this.propsForGroupNotification = this.getPropsForGroupNotification(); const propsForGroupNotification = this.isGroupUpdate()
} else if (this.isGroupInvitation()) { ? this.getPropsForGroupNotification()
this.propsForGroupInvitation = this.getPropsForGroupInvitation(); : null;
} else if (this.isDataExtractionNotification()) { const propsForGroupInvitation = this.isGroupInvitation()
this.propsForDataExtractionNotification = this.getPropsForDataExtractionNotification(); ? this.getPropsForGroupInvitation()
} else { : null;
this.propsForSearchResult = this.getPropsForSearchResult(); const propsForDataExtractionNotification = this.isDataExtractionNotification()
this.propsForMessage = this.getPropsForMessage(); ? this.getPropsForDataExtractionNotification()
} : null;
const propsForSearchResult = this.getPropsForSearchResult();
const propsForMessage = this.getPropsForMessage();
const messageProps = { propsForMessage };
if (triggerEvent) { if (triggerEvent) {
window.inboxStore?.dispatch(conversationActions.messageChanged(this)); window.inboxStore?.dispatch(conversationActions.messageChanged(this));
@ -1039,8 +1044,12 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
if (!this.attributes.id) { if (!this.attributes.id) {
throw new Error('A message always needs an id'); throw new Error('A message always needs an id');
} }
perfStart(`messageCommit-${this.attributes.id}`);
const id = await saveMessage(this.attributes); const id = await saveMessage(this.attributes);
this.generateProps(); this.generateProps();
perfEnd(`messageCommit-${this.attributes.id}`, 'messageCommit');
return id; return id;
} }

@ -16,6 +16,7 @@ import { ECKeyPair } from './keypairs';
import { handleConfigurationMessage } from './configMessage'; import { handleConfigurationMessage } from './configMessage';
import { ConversationTypeEnum } from '../models/conversation'; import { ConversationTypeEnum } from '../models/conversation';
import { removeMessagePadding } from '../session/crypto/BufferPadding'; import { removeMessagePadding } from '../session/crypto/BufferPadding';
import { perfEnd, perfStart } from '../session/utils/Performamce';
export async function handleContentMessage(envelope: EnvelopePlus) { export async function handleContentMessage(envelope: EnvelopePlus) {
try { try {
@ -300,9 +301,14 @@ export async function innerHandleContentMessage(
plaintext: ArrayBuffer plaintext: ArrayBuffer
): Promise<void> { ): Promise<void> {
try { try {
perfStart(`SignalService.Content.decode-${envelope.id}`);
const content = SignalService.Content.decode(new Uint8Array(plaintext)); const content = SignalService.Content.decode(new Uint8Array(plaintext));
perfEnd(`SignalService.Content.decode-${envelope.id}`, 'SignalService.Content.decode');
perfStart(`isBlocked-${envelope.id}`);
const blocked = await isBlocked(envelope.source); const blocked = await isBlocked(envelope.source);
perfEnd(`isBlocked-${envelope.id}`, 'isBlocked');
if (blocked) { if (blocked) {
// We want to allow a blocked user message if that's a control message for a known group and the group is not blocked // We want to allow a blocked user message if that's a control message for a known group and the group is not blocked
if (shouldDropBlockedUserMessage(content)) { if (shouldDropBlockedUserMessage(content)) {
@ -322,16 +328,24 @@ export async function innerHandleContentMessage(
if (content.dataMessage.profileKey && content.dataMessage.profileKey.length === 0) { if (content.dataMessage.profileKey && content.dataMessage.profileKey.length === 0) {
content.dataMessage.profileKey = null; content.dataMessage.profileKey = null;
} }
perfStart(`handleDataMessage-${envelope.id}`);
await handleDataMessage(envelope, content.dataMessage); await handleDataMessage(envelope, content.dataMessage);
perfEnd(`handleDataMessage-${envelope.id}`, 'handleDataMessage');
return; return;
} }
if (content.receiptMessage) { if (content.receiptMessage) {
perfStart(`handleReceiptMessage-${envelope.id}`);
await handleReceiptMessage(envelope, content.receiptMessage); await handleReceiptMessage(envelope, content.receiptMessage);
perfEnd(`handleReceiptMessage-${envelope.id}`, 'handleReceiptMessage');
return; return;
} }
if (content.typingMessage) { if (content.typingMessage) {
perfStart(`handleTypingMessage-${envelope.id}`);
await handleTypingMessage(envelope, content.typingMessage as SignalService.TypingMessage); await handleTypingMessage(envelope, content.typingMessage as SignalService.TypingMessage);
perfEnd(`handleTypingMessage-${envelope.id}`, 'handleTypingMessage');
return; return;
} }
if (content.configurationMessage) { if (content.configurationMessage) {
@ -343,10 +357,16 @@ export async function innerHandleContentMessage(
return; return;
} }
if (content.dataExtractionNotification) { if (content.dataExtractionNotification) {
perfStart(`handleDataExtractionNotification-${envelope.id}`);
await handleDataExtractionNotification( await handleDataExtractionNotification(
envelope, envelope,
content.dataExtractionNotification as SignalService.DataExtractionNotification content.dataExtractionNotification as SignalService.DataExtractionNotification
); );
perfEnd(
`handleDataExtractionNotification-${envelope.id}`,
'handleDataExtractionNotification'
);
return; return;
} }
} catch (e) { } catch (e) {

@ -122,7 +122,7 @@ export async function dropSnodeFromPath(snodeEd25519: string) {
export async function getOnionPath(toExclude?: Snode): Promise<Array<Snode>> { export async function getOnionPath(toExclude?: Snode): Promise<Array<Snode>> {
let attemptNumber = 0; let attemptNumber = 0;
while (onionPaths.length < minimumGuardCount) { while (onionPaths.length < minimumGuardCount) {
window?.log?.error( window?.log?.warn(
`Must have at least ${minimumGuardCount} good onion paths, actual: ${onionPaths.length}, attempt #${attemptNumber} fetching more...` `Must have at least ${minimumGuardCount} good onion paths, actual: ${onionPaths.length}, attempt #${attemptNumber} fetching more...`
); );
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop

@ -630,7 +630,7 @@ export async function incrementBadSnodeCountOrDrop({
} catch (e) { } catch (e) {
window?.log?.warn( window?.log?.warn(
'dropSnodeFromPath, got error while patching up... incrementing the whole path as bad', 'dropSnodeFromPath, got error while patching up... incrementing the whole path as bad',
e e.message
); );
// If dropSnodeFromPath throws, it means there is an issue patching up the path, increment the whole path issues count // If dropSnodeFromPath throws, it means there is an issue patching up the path, increment the whole path issues count
// but using the guardNode we got instead of the snodeEd25519. // but using the guardNode we got instead of the snodeEd25519.

@ -0,0 +1,8 @@
export function perfStart(prefix: string) {
performance.mark(`${prefix}-start`);
}
export function perfEnd(prefix: string, measureName: string) {
performance.mark(`${prefix}-end`);
performance.measure(measureName, `${prefix}-start`, `${prefix}-end`);
}

@ -16,7 +16,7 @@ const mentionsInputSlice = createSlice({
initialState: initialMentionsState, initialState: initialMentionsState,
reducers: { reducers: {
updateMentionsMembers(state, action) { updateMentionsMembers(state, action) {
window?.log?.warn('updating mentions input members', action.payload); window?.log?.warn('updating mentions input members length', action.payload?.length);
return action.payload as MentionsInputState; return action.payload as MentionsInputState;
}, },
}, },

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save