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

Introduce an one-shot timer which runs more often after init() call #340

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

guvenc
Copy link
Collaborator

@guvenc guvenc commented Jul 19, 2023

One shot timer gets kicked after the init() grpc call and sends the ARP requests more often for the first 30 seconds. After that the normal interval is used. (30 seconds)

@github-actions github-actions bot added enhancement New feature or request size/M labels Jul 19, 2023
@guvenc guvenc force-pushed the feature/faster_arp_after_start branch from 0f2218e to e0b0ac5 Compare July 19, 2023 15:56
@guvenc guvenc requested a review from PlagueCZ July 19, 2023 16:59
@guvenc guvenc force-pushed the feature/faster_arp_after_start branch 2 times, most recently from 851de08 to c4557ea Compare July 19, 2023 17:06
src/dp_timers.c Outdated
}

uint64_t dp_timers_get_manage_interval_cycles(void)
{
return dp_timer_manage_interval_cycles;
}

static inline int dp_timers_add(struct rte_timer *timer, int period, rte_timer_cb_t callback)
static inline int dp_timers_add(struct rte_timer *timer, int period, enum rte_timer_type type, rte_timer_cb_t callback)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you are changing the signature, you can change the name to dp_add_timer() as your naming scheme is actually better than mine. I just did not want to make a bug PR out of renaming stuff.

@@ -43,6 +44,7 @@ char* GRPCService::GetUUID()

void GRPCService::SetInitStatus(bool status)
{
dp_timers_kick_one_shot_timer();
Copy link
Contributor

Choose a reason for hiding this comment

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

I am having trouble guessing what the name means, kick is not obvious to me and also one shot timer for what exactly? How about dp_start_oneshot_maintenance_timer or something (or "suick amintenance timer" or similar?

And why is it called here instead in dp_timers_init(), you want to explicitely wait for grpc init? This way we have the 30s and in parallel another one that runs from grpc init 4x5s. I thought you'd simply create a 5s timer, run it 6 times and then switch over to 30s timer instead. If the possibility of running two timers at once (if for example grpc takes 20s before init), then I guess it's not a problem.

src/dp_timers.c Outdated
if (dp_conf_is_ipv6_overlay_enabled()) {
trigger_nd_ra();
trigger_nd_unsol_adv();
}
trigger_garp();

if ((timer->period == SINGLE) && (counter < 4)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this either needs a comment or a define for the 4 (or both). Ideally a define that divides the maintenance timer intervals, like 30s/5s means you run this one 6 times before the proper one starts. But I guess the four is there because gRPC takes some time?

Also maybe separate the callbacks (and call a common inline or something) so we do not have to ask the period to be SINGLE as that seems odd at first sight.

Or set this timer to 5s PERIODIC and after N iterations (4) remove it and re-create it with 30s?

@guvenc
Copy link
Collaborator Author

guvenc commented Jul 20, 2023

Thanks for the comments @PlagueCZ Makes sense. I changed the approach completely now and using the one you suggested "Or set this timer to 5s PERIODIC and after N iterations (4) remove it and re-create it with 30s?"

I wouldnt change the function names in this PR but the other points should be addressed now with the new approach.

@guvenc guvenc force-pushed the feature/faster_arp_after_start branch from c4557ea to 63e087a Compare July 20, 2023 10:44
@github-actions github-actions bot added size/S and removed size/M labels Jul 20, 2023
src/dp_timers.c Outdated
@@ -17,10 +17,13 @@

// how often to perform network maintenance tasks (ND, GARP, ...)
#define TIMER_DP_MAINTENANCE_INTERVAL 30
#define TIMER_DP_MAINTENANCE_STARTUP_INTERVAL 5
#define TIMER_DP_MAINTANANCE_STARTUP_PERIOD 5
Copy link
Contributor

Choose a reason for hiding this comment

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

typo MAINTANANCE/MAINTENANCE

And maybe change _PERIOD to _CYCLES, since period is by definition a time span between cycles, so I would automatically ready it as period 5s

@@ -63,6 +80,11 @@ static inline int dp_timers_add(struct rte_timer *timer, int period, rte_timer_c
return rte_timer_reset(timer, cycles, PERIODICAL, rte_lcore_id(), callback, NULL);
}

void dp_timers_signal_initialization(void)
{
dp_maintenance_interval = TIMER_DP_MAINTENANCE_INTERVAL;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is now quite elegant actually, you made it asynchronous.

cycles = dp_maintenance_interval * rte_get_timer_hz();
rte_timer_reset(timer, cycles, PERIODICAL, rte_lcore_id(), dp_maintenance_timer_cb, NULL);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Now due to the asynchronous implementation though, I think this needs the two-callback imeplementation, otherwise the whole condition will get evaluated for eternity, since interval will be always big and then counter will always be small and there are two unneeded comparisons.

So I would create a startup callbak that does what is above, but then sets the callback to the old function.

Start the maintenance timer with a small interval and after the first
GRPC init call, gracefully increase the interval.

Signed-off-by: Guvenc Gulce <[email protected]>
@guvenc guvenc force-pushed the feature/faster_arp_after_start branch from 63e087a to 937d428 Compare July 20, 2023 11:20
@guvenc
Copy link
Collaborator Author

guvenc commented Jul 20, 2023

Here comes the new version. @PlagueCZ

@github-actions github-actions bot added size/M and removed size/S labels Jul 20, 2023
Copy link
Contributor

@PlagueCZ PlagueCZ left a comment

Choose a reason for hiding this comment

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

Looks great now. I still love the asynchronous change you did.

@guvenc guvenc merged commit 22ac9e6 into main Jul 20, 2023
@guvenc guvenc deleted the feature/faster_arp_after_start branch July 20, 2023 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants