Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

perf: speed up monetizationstart #115

Merged
merged 3 commits into from
Nov 27, 2019
Merged

Conversation

sentientwaffle
Copy link
Contributor

In ilp-protocol-stream, Streams emit "outgoing_money" events before connection.totalDelivered is updated. This resulted in the extension ignoring the first outgoing_money event, since it mistakenly assumed that no money was delivered.

In my tests, this shortened the time-to-monetizationstart from 2500-2800ms down to 500-700ms.

In ilp-protocol-stream, `Stream`s emit `"outgoing_money"` events before `connection.totalDelivered` is updated. This resulted in the extension ignoring the first `outgoing_money` event, since it mistakenly assumed that no money was delivered.

In my tests, this shortened the time-to-`monetizationstart` from 2500-2800ms down to 500-700ms.
Copy link

@sharafian sharafian left a comment

Choose a reason for hiding this comment

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

Great find!

@sharafian
Copy link

Is this speedup also after applying optimizations like exchange rate and packet size hints or have those not gone in yet? I would be curious if they can get the time down even further

@sentientwaffle
Copy link
Contributor Author

It's without, I think. I tested enabling them and they don't make as much of a different as I expected, so I'm actually looking into that next.

@sharafian
Copy link

Is this fix applicable to the oauth script also? right now the two have different modules that send on streams

@sentientwaffle
Copy link
Contributor Author

I didn't think of that. Yes, I think it is applicable, I'll update the PR.

@sharafian sharafian merged commit 1307ee8 into master Nov 27, 2019
@sharafian sharafian deleted the dj-faster-monetizationstart branch November 27, 2019 23:08
@@ -331,7 +331,8 @@ class StreamAttempt {

return new Promise((resolve, reject) => {
const onMoney = (sentAmount: string) => {
this.onMoney(sentAmount)
// Wait until `setImmediate` so that `connection.totalDelivered` has been updated.
Copy link
Member

Choose a reason for hiding this comment

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

Nice work Mr @sentientwaffle !

Copy link
Member

Choose a reason for hiding this comment

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

Maybe ilp-protocol-stream should be updated to set that beforehand ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since updating the hold may not change the amount that isn't desirable.

Copy link
Member

Choose a reason for hiding this comment

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

Can you elaborate on that?
Note that I'm not a STREAM/ILP expert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, stream could set the amount beforehand, but I think it would qualify as a breaking change (albeit just barely). I've made a note-to-self to include that change the next time I make a breaking stream change. I don't think it warrants one on its own since it's so simple to work around.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, so outgoing_money is when money is actually delivered right? Or am I wrong there?
It's definitely a change but one could reasonably argue it's actually a bug and the current behavior is incorrect. Would it really actually "break" any client code or simply give more correct results ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, outgoing_money is the notification that money has been successfully delivered on a stream.

@sublimator
Copy link
Member

@sentientwaffle
I can't actually replicate your TTS reductions here in Cambodia.
Were you testing against a local server at all ?

@sublimator
Copy link
Member

@sentientwaffle
I replicated against a local ilp-plugin-mini-accounts server

@sentientwaffle
Copy link
Contributor Author

@sublimator Testing against a local server may not work because the packets would arrive so quickly that the delay may be too small to notice. I was testing against coil's staging server.

@sublimator
Copy link
Member

sublimator commented Nov 28, 2019 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants