add some performance measure for commit calls

pull/1783/head
Audric Ackermann 3 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 .",
"grunt": "grunt",
"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",
"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",

@ -37,6 +37,7 @@ import { IMAGE_JPEG } from '../types/MIME';
import { FSv2 } from '../fileserver';
import { fromBase64ToArray, toHex } from '../session/utils/String';
import { SessionButtonColor } from '../components/session/SessionButton';
import { perfEnd, perfStart } from '../session/utils/Performamce';
export const getCompleteUrlForV2ConvoId = async (convoId: string) => {
if (convoId.match(openGroupV2ConversationIdRegex)) {
@ -254,7 +255,10 @@ export function showRemoveModeratorsByConvoId(conversationId: string) {
export async function markAllReadByConvoId(conversationId: string) {
const conversation = getConversationController().get(conversationId);
perfStart(`markAllReadByConvoId-${conversationId}`);
await conversation.markReadBouncy(Date.now());
perfEnd(`markAllReadByConvoId-${conversationId}`, 'markAllReadByConvoId');
}
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
profileKey = window.textsecure.storage.get('profileKey');
if (!profileKey) {
window.log.warn('our profileKey not found');
window.log.info('our profileKey not found');
return;
}
const currentAttachmentPath = ourConvo.getAvatarPath();

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

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

@ -16,6 +16,7 @@ import { ECKeyPair } from './keypairs';
import { handleConfigurationMessage } from './configMessage';
import { ConversationTypeEnum } from '../models/conversation';
import { removeMessagePadding } from '../session/crypto/BufferPadding';
import { perfEnd, perfStart } from '../session/utils/Performamce';
export async function handleContentMessage(envelope: EnvelopePlus) {
try {
@ -300,9 +301,14 @@ export async function innerHandleContentMessage(
plaintext: ArrayBuffer
): Promise<void> {
try {
perfStart(`SignalService.Content.decode-${envelope.id}`);
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);
perfEnd(`isBlocked-${envelope.id}`, 'isBlocked');
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
if (shouldDropBlockedUserMessage(content)) {
@ -322,16 +328,24 @@ export async function innerHandleContentMessage(
if (content.dataMessage.profileKey && content.dataMessage.profileKey.length === 0) {
content.dataMessage.profileKey = null;
}
perfStart(`handleDataMessage-${envelope.id}`);
await handleDataMessage(envelope, content.dataMessage);
perfEnd(`handleDataMessage-${envelope.id}`, 'handleDataMessage');
return;
}
if (content.receiptMessage) {
perfStart(`handleReceiptMessage-${envelope.id}`);
await handleReceiptMessage(envelope, content.receiptMessage);
perfEnd(`handleReceiptMessage-${envelope.id}`, 'handleReceiptMessage');
return;
}
if (content.typingMessage) {
perfStart(`handleTypingMessage-${envelope.id}`);
await handleTypingMessage(envelope, content.typingMessage as SignalService.TypingMessage);
perfEnd(`handleTypingMessage-${envelope.id}`, 'handleTypingMessage');
return;
}
if (content.configurationMessage) {
@ -343,10 +357,16 @@ export async function innerHandleContentMessage(
return;
}
if (content.dataExtractionNotification) {
perfStart(`handleDataExtractionNotification-${envelope.id}`);
await handleDataExtractionNotification(
envelope,
content.dataExtractionNotification as SignalService.DataExtractionNotification
);
perfEnd(
`handleDataExtractionNotification-${envelope.id}`,
'handleDataExtractionNotification'
);
return;
}
} catch (e) {

@ -122,7 +122,7 @@ export async function dropSnodeFromPath(snodeEd25519: string) {
export async function getOnionPath(toExclude?: Snode): Promise<Array<Snode>> {
let attemptNumber = 0;
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...`
);
// eslint-disable-next-line no-await-in-loop

@ -630,7 +630,7 @@ export async function incrementBadSnodeCountOrDrop({
} catch (e) {
window?.log?.warn(
'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
// 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,
reducers: {
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;
},
},

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