Log conversation open time

This commit is contained in:
Fedor Indutny 2022-01-19 16:40:29 -08:00 committed by GitHub
parent f1586578ff
commit 26421b8c18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 15 deletions

View File

@ -114,6 +114,20 @@ jobs:
RUN_COUNT: 100 RUN_COUNT: 100
ELECTRON_ENABLE_STACK_DUMPING: on ELECTRON_ENABLE_STACK_DUMPING: on
- name: Run conversation open benchmarks
run: |
set -o pipefail
rm -rf /tmp/mock
xvfb-run --auto-servernum ts-node \
Mock-Server/scripts/convo-open-test.ts \
./node_modules/.bin/electron . | tee benchmark-convo-open.log || \
(cat /tmp/mock/logs/{app,main}.log && exit 1)
timeout-minutes: 10
env:
NODE_ENV: production
RUN_COUNT: 100
ELECTRON_ENABLE_STACK_DUMPING: on
- name: Clone benchmark repo - name: Clone benchmark repo
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
@ -128,6 +142,7 @@ jobs:
node ./bin/collect.js ../benchmark-startup.log data/startup.json node ./bin/collect.js ../benchmark-startup.log data/startup.json
node ./bin/collect.js ../benchmark-send.log data/send.json node ./bin/collect.js ../benchmark-send.log data/send.json
node ./bin/collect.js ../benchmark-group-send.log data/group-send.json node ./bin/collect.js ../benchmark-group-send.log data/group-send.json
node ./bin/collect.js ../benchmark-convo-open.log data/convo-open.json
npm run build npm run build
git config --global user.email "no-reply@signal.org" git config --global user.email "no-reply@signal.org"
git config --global user.name "Signal Bot" git config --global user.name "Signal Bot"

View File

@ -119,6 +119,8 @@ export class ConversationController {
private _initialPromise: undefined | Promise<void>; private _initialPromise: undefined | Promise<void>;
private _conversationOpenStart = new Map<string, number>();
constructor(private _conversations: ConversationModelCollectionType) {} constructor(private _conversations: ConversationModelCollectionType) {}
get(id?: string | null): ConversationModel | undefined { get(id?: string | null): ConversationModel | undefined {
@ -754,6 +756,20 @@ export class ConversationController {
return this._initialPromise; return this._initialPromise;
} }
onConvoOpenStart(conversationId: string): void {
this._conversationOpenStart.set(conversationId, Date.now());
}
onConvoMessageMount(conversationId: string): void {
const loadStart = this._conversationOpenStart.get(conversationId);
if (loadStart === undefined) {
return;
}
this._conversationOpenStart.delete(conversationId);
this.get(conversationId)?.onOpenComplete(loadStart);
}
private async doLoad(): Promise<void> { private async doLoad(): Promise<void> {
log.info('ConversationController: starting initial fetch'); log.info('ConversationController: starting initial fetch');

View File

@ -420,6 +420,9 @@ export class Message extends React.PureComponent<Props, State> {
}; };
public override componentDidMount(): void { public override componentDidMount(): void {
const { conversationId } = this.props;
window.ConversationController.onConvoMessageMount(conversationId);
this.startSelectedTimer(); this.startSelectedTimer();
this.startDeleteForEveryoneTimerIfApplicable(); this.startDeleteForEveryoneTimerIfApplicable();

View File

@ -1456,15 +1456,15 @@ export class ConversationModel extends window.Backbone
// reducer to trust the message set we just fetched for determining if we have // reducer to trust the message set we just fetched for determining if we have
// the newest message loaded. // the newest message loaded.
const unboundedFetch = true; const unboundedFetch = true;
messagesReset( messagesReset({
conversationId, conversationId,
cleaned.map((messageModel: MessageModel) => ({ messages: cleaned.map((messageModel: MessageModel) => ({
...messageModel.attributes, ...messageModel.attributes,
})), })),
metrics, metrics,
scrollToMessageId, scrollToMessageId,
unboundedFetch unboundedFetch,
); });
} catch (error) { } catch (error) {
setMessagesLoading(conversationId, false); setMessagesLoading(conversationId, false);
throw error; throw error;
@ -1604,14 +1604,14 @@ export class ConversationModel extends window.Backbone
const scrollToMessageId = const scrollToMessageId =
options && options.disableScroll ? undefined : messageId; options && options.disableScroll ? undefined : messageId;
messagesReset( messagesReset({
conversationId, conversationId,
cleaned.map((messageModel: MessageModel) => ({ messages: cleaned.map((messageModel: MessageModel) => ({
...messageModel.attributes, ...messageModel.attributes,
})), })),
metrics, metrics,
scrollToMessageId scrollToMessageId,
); });
} catch (error) { } catch (error) {
setMessagesLoading(conversationId, false); setMessagesLoading(conversationId, false);
throw error; throw error;
@ -5281,6 +5281,19 @@ export class ConversationModel extends window.Backbone
this.set('acknowledgedGroupNameCollisions', groupNameCollisions); this.set('acknowledgedGroupNameCollisions', groupNameCollisions);
window.Signal.Data.updateConversation(this.attributes); window.Signal.Data.updateConversation(this.attributes);
} }
onOpenStart(): void {
log.info(`conversation ${this.idForLogging()} open start`);
window.ConversationController.onConvoOpenStart(this.id);
}
onOpenComplete(startedAt: number): void {
const now = Date.now();
const delta = now - startedAt;
log.info(`conversation ${this.idForLogging()} open took ${delta}ms`);
window.CI?.handleEvent('conversation:open', { delta });
}
} }
window.Whisper.Conversation = ConversationModel; window.Whisper.Conversation = ConversationModel;

View File

@ -1613,13 +1613,21 @@ function reviewMessageRequestNameCollision(
return { type: 'REVIEW_MESSAGE_REQUEST_NAME_COLLISION', payload }; return { type: 'REVIEW_MESSAGE_REQUEST_NAME_COLLISION', payload };
} }
function messagesReset( export type MessageResetOptionsType = Readonly<{
conversationId: string, conversationId: string;
messages: Array<MessageAttributesType>, messages: Array<MessageAttributesType>;
metrics: MessageMetricsType, metrics: MessageMetricsType;
scrollToMessageId?: string, scrollToMessageId?: string;
unboundedFetch?: boolean unboundedFetch?: boolean;
): MessagesResetActionType { }>;
function messagesReset({
conversationId,
messages,
metrics,
scrollToMessageId,
unboundedFetch,
}: MessageResetOptionsType): MessagesResetActionType {
return { return {
type: 'MESSAGES_RESET', type: 'MESSAGES_RESET',
payload: { payload: {

View File

@ -1192,6 +1192,8 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
} }
async onOpened(messageId: string): Promise<void> { async onOpened(messageId: string): Promise<void> {
this.model.onOpenStart();
if (messageId) { if (messageId) {
const message = await getMessageById(messageId); const message = await getMessageById(messageId);