Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trigger ability for batcher #833

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LukasPukenis
Copy link
Contributor

@LukasPukenis LukasPukenis commented Sep 26, 2024

Add triggering ability to batcher so it could
evaluate deadlines and thresholds on demand.

The approach is simple - any activity on sent
or received data on any peer will trigger the batcher.

This is built on assumption that triggering on incoming
data would sync the batchers between two devices. However
triggering only between two devices would leave other devices
unsynced, thus simplified approach works even better
to "sync the clocks" across all the nodes.

Side effects:
consider having 3 interconnected peers: A, B and C.
Peer C is idling and A streams data to B.
Now A and B is each triggered on every packet and in turn
send premature keepalives to C at T_new=T_orig-threshold.

Triggering will happen mostly on wg_consolidate() which happens
every second.

☑️ Definition of Done checklist

  • Commit history is clean (requirements)
  • README.md is updated
  • Functionality is covered by unit or integration tests

@LukasPukenis LukasPukenis force-pushed the LLT-5026-trigger-batching-incomming branch 3 times, most recently from 78bc0dd to a095124 Compare September 26, 2024 13:09
@LukasPukenis LukasPukenis force-pushed the LLT-5026-trigger-batching-incomming branch from a095124 to f9deae5 Compare October 8, 2024 12:10
@LukasPukenis LukasPukenis changed the base branch from main to LLT-5657 October 8, 2024 12:16
@LukasPukenis LukasPukenis force-pushed the LLT-5026-trigger-batching-incomming branch 3 times, most recently from 70350bd to 2fd8506 Compare October 10, 2024 10:20
@LukasPukenis LukasPukenis reopened this Oct 10, 2024
@LukasPukenis LukasPukenis changed the base branch from LLT-5657 to main October 10, 2024 10:25
@LukasPukenis LukasPukenis force-pushed the LLT-5026-trigger-batching-incomming branch 15 times, most recently from 04186aa to 2f45064 Compare October 10, 2024 11:33
@LukasPukenis LukasPukenis marked this pull request as ready for review October 10, 2024 11:33
@LukasPukenis LukasPukenis requested a review from a team as a code owner October 10, 2024 11:33
@LukasPukenis LukasPukenis force-pushed the LLT-5026-trigger-batching-incomming branch 2 times, most recently from e9e7abd to d16f812 Compare October 10, 2024 11:40
@LukasPukenis LukasPukenis force-pushed the LLT-5026-trigger-batching-incomming branch 7 times, most recently from a8a34d8 to ff018a6 Compare October 10, 2024 12:29
Add triggering ability to batcher so it could
evaluate deadlines and thresholds on demand.

The approach is simple - any activity on sent
or received data on any peer will trigger the batcher.

This is built on assumption that triggering on incoming
data would sync the batchers between two devices. However
triggering only between two devices would leave other devices
unsynced, thus simplified approach works even better
to "sync the clocks" across all the nodes.

Side effects:
consider having 3 interconnected peers: A, B and C.
Peer C is idling and A streams data to B.
Now A and B is each triggered on every packet and in turn
send premature keepalives to C at T_new=T_orig-threshold.

Triggering will happen mostly on wg_consolidate() which happens
every second.

Signed-off-by: Lukas Pukenis <[email protected]>
@LukasPukenis LukasPukenis force-pushed the LLT-5026-trigger-batching-incomming branch from ff018a6 to 56f88a0 Compare October 10, 2024 12:32
@@ -37,56 +50,76 @@ where
Self {
actions: HashMap::new(),
notify_add: tokio::sync::Notify::new(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could import it? The code seems to be a bit cluttered with this fully qualified tokio:sync:Notify

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I personally like not to import stuff that's only used once in the file, it simplifies things since there's less to think about what we import and what we use from the imports. In this case there's no import of Notify so it's clear it might be only occasionally used.

Of course, this is more of a matter of discipline, I could use tokio::sync::Notify multiple times no problem :)

@@ -15,7 +15,7 @@ use telio_task::{task_exec, BoxAction, Runtime, Task};
use telio_utils::{
dual_target, repeated_actions, telio_log_debug, telio_log_warn, DualTarget, RepeatedActions,
};

use telio_wg::NetworkActivityGetter;
Copy link
Contributor

Choose a reason for hiding this comment

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

Some newlines around it would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe cargo fmt should deal with it

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you removing it? Comment just after a bracket looks weird imho.

Comment on lines +822 to +824
if let (Some(tx_ts), Some(rx_ts)) = (s.get_tx_ts(), s.get_rx_ts()) {
self.network_activity_ts = Some(TxRxTimestampPair { tx_ts, rx_ts });
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, why do you need to store it? Couldn't you just run this methods in get_ts?

}
}

if tx_has_changed || rx_has_changed {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, shouldn't it be only rx_has_changed ? And is SessionKeeper the best entity to handle the triggering? I thought it should be also done when the connection is in Relayed state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From real life experiments both sending and receiving data causes the drainage for a while, thus we care about both of those things happening.

Now about the SessionKeeper - it is the best place since it was the one used for keepalives(both batched and non-batched). Batcher is only being used inside of it. For now only because we dealt with direct keepalives that were handled in SessionKeeper.

I would say that SessionKeeper outlived it's purpose and probably warrant a rename at this point though :).

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.

2 participants