COVESA / vsomeip

An implementation of Scalable service-Oriented MiddlewarE over IP
Mozilla Public License 2.0
1.01k stars 647 forks source link

improve vsomeip sluggish connect (maintain 3.1.x branch) #671

Open joeyoravec opened 1 month ago

joeyoravec commented 1 month ago

fixes COVESA/vsomeip#669

As described in issue https://github.com/COVESA/vsomeip/issues/669 the train logic should aggregate Service Discovery, but does not currently. This leads to very low performance on systems offering 1000s of EventGroups.

This PR has similar content to #670 but backported to 3.1.20.3 and containing one additional important fix for that older version. I'm leaving this PR in draft status to gather feedback. The key difference when backporting is:

Ensure departure timer does not go negative

There is a calculation 3.1.20 in implementation/endpoints/include/buffer.hpp that results in a negative number in case the timer is already expired:

void update_departure_time_and_stop_departure() {
    departure_ = departure_timer_->expires_from_now();

We need to implement a floor() so the departure is either in the future, or zero meaning ready to depart, but never negative. Like:

departure_ = departure_timer_->expires_from_now();
if (departure_.count() < 0) {
    departure_ = std::chrono::nanoseconds::zero();
}

In case the value goes negative then other calculations fail. That large negative number is kept and used for the next calculated departure time, breaking that one too.

goncaloalmeida commented 2 weeks ago

@joeyoravec is this ready to review or are you still working on this?

joeyoravec commented 2 weeks ago

@joeyoravec is this ready to review or are you still working on this?

I've left this in draft so it's clear that this is not ready for merge. Yes this "works" and is worth reviewing. However I read that COVESA ended all support for https://github.com/COVESA/vsomeip/tree/maintain/3.1 since Apr 2023. If nothing is getting merged to that branch then this backport might only be relevant for users who want to cherry-pick to their own branches.