Skip to content

Conversation

@BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Oct 8, 2020

Improve send time performances why removing usage of workers to send events.

On some devices heavy delay were experienced when sending events ( 5s, 6s, 20s...). It's touching some devices and not others and is still a bit random.

Workers by them selves are adding a bit of delay before launching, and in addition we have to rely on database to get up to date localEchos, and such transactions are sometime very slow

Example of improvement of send time (top is with worker, bottom is with new implementation)
image

The current implem just uses a sender thread, that consumes send tasks in order.
Media messages are still using workers

In addition some improvement have been made on timeline with broader support of UI local echos

** Known Limitation

  • The first message sent in an encrypted room will still take long to be sent, improvment for that is coming in another PR

@BillCarsonFr BillCarsonFr marked this pull request as ready for review October 9, 2020 08:28
@BillCarsonFr BillCarsonFr requested review from bmarty and ganfra October 9, 2020 08:34
@BillCarsonFr BillCarsonFr force-pushed the feature/bca/perf_better_send_time branch 2 times, most recently from 9664417 to 301ff39 Compare October 9, 2020 13:51
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a first static review. That's amazing work!
Will try to use the code during the week-end

.let { sendEvent(it) }
}

// For test only
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remove this comment :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

private val queuedTaskFactory: QueuedTaskFactory,
private val taskExecutor: TaskExecutor,
private val memento: QueueMemento
) : Thread("SENDER_THREAD_SID_${sessionParams.credentials.sessionId()}") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested the signout, if there are unsent Events?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the session is closed, the send processor will be interrupted thus pending messages won't be sent.

* reschedule them (and only them) on next restart
*/
internal class QueueMemento @Inject constructor(context: Context,
sessionParams: SessionParams,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can inject @sessionid instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* Info that need to be persisted by the sender thread
* With polymorphic moshi parsing
*/
interface TaskInfo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

) : TaskInfo

@JsonClass(generateAdapter = true)
data class FallbackTaskInfo(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all those 3 data classes should have internal modifier I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@bmarty bmarty force-pushed the feature/bca/perf_better_send_time branch from 27b1812 to dc8a6cc Compare October 20, 2020 19:42
@bmarty bmarty merged commit c88c2a1 into develop Oct 20, 2020
@bmarty bmarty deleted the feature/bca/perf_better_send_time branch October 20, 2020 20:12
@BillCarsonFr
Copy link
Member Author

Fixes #516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants