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

[Link event damping] Add concurrent queue. #1297

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

Ashish1805
Copy link
Contributor

@Ashish1805 Ashish1805 marked this pull request as draft September 28, 2023 09:37
Copy link
Collaborator

@kcudnik kcudnik left a comment

Choose a reason for hiding this comment

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

Unmanageable to review, too many changes, too many files affected in 1 pr, low code quality, not following existing file standards, many new classes, each new class can be a separate code review, new port custom range attributes seems better to be added in SAI repo instead of here, causing to implement custom Metadata where SAI generates that automatically

SWSS_LOG_ENTER();

std::lock_guard<std::mutex> mutex_lock(mutex_);
if (queue_.empty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

All { should start in new line

Copy link
Collaborator

@kcudnik kcudnik left a comment

Choose a reason for hiding this comment

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

Give up on this review address comments

// size.
static constexpr size_t kUnlimited = 0;

std::mutex mutex_;
Copy link
Collaborator

Choose a reason for hiding this comment

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

All members should be prefixed m_

SWSS_LOG_ENTER();

std::lock_guard<std::mutex> mutex_lock(mutex_);
return queue_.empty();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Empty line before review


sai_object_id_t vid;
bool rid_to_vid_mapping_found =
vid_translator_->tryTranslateRidToVid(data.port_id, vid);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Big lump of code totally unreadable

@Ashish1805
Copy link
Contributor Author

@Ashish1805
Copy link
Contributor Author

Unmanageable to review, too many changes, too many files affected in 1 pr, low code quality, not following existing file standards, many new classes, each new class can be a separate code review, new port custom range attributes seems better to be added in SAI repo instead of here, causing to implement custom Metadata where SAI generates that automatically

Thanks @kcudnik for taking a look.

On the issue of port custom attribute, this is added in sairedis.h in sonic-sairedis as per agreed upon in HLD https://github.com/sonic-net/SONiC/blob/master/doc/link_event_damping/Link-event-damping-HLD.md#sairedis-api

In the existing sonic-sairedis code, I see there are mix of different standards followed. I couldn't find a guideline or doc for sonic standard code, can you please share them Or if you suggest any existing code file that can be a good reference for sonic standard?

Thank you.

@kcudnik
Copy link
Collaborator

kcudnik commented Sep 29, 2023

Unmanageable to review, too many changes, too many files affected in 1 pr, low code quality, not following existing file standards, many new classes, each new class can be a separate code review, new port custom range attributes seems better to be added in SAI repo instead of here, causing to implement custom Metadata where SAI generates that automatically

Thanks @kcudnik for taking a look.

On the issue of port custom attribute, this is added in sairedis.h in sonic-sairedis as per agreed upon in HLD https://github.com/sonic-net/SONiC/blob/master/doc/link_event_damping/Link-event-damping-HLD.md#sairedis-api

In the existing sonic-sairedis code, I see there are mix of different standards followed. I couldn't find a guideline or doc for sonic standard code, can you please share them Or if you suggest any existing code file that can be a good reference for sonic standard?

Thank you.

I keep the standard in this entire repo, there is no specific documents but 90% of files are kept in very good shape, please take a look on more files and point me to the one you were looking to, I pointed you more obvious issues

@mikeberesford
Copy link

Unmanageable to review, too many changes, too many files affected in 1 pr, low code quality, not following existing file standards, many new classes, each new class can be a separate code review, new port custom range attributes seems better to be added in SAI repo instead of here, causing to implement custom Metadata where SAI generates that automatically

Thanks @kcudnik for taking a look.
On the issue of port custom attribute, this is added in sairedis.h in sonic-sairedis as per agreed upon in HLD https://github.com/sonic-net/SONiC/blob/master/doc/link_event_damping/Link-event-damping-HLD.md#sairedis-api
In the existing sonic-sairedis code, I see there are mix of different standards followed. I couldn't find a guideline or doc for sonic standard code, can you please share them Or if you suggest any existing code file that can be a good reference for sonic standard?
Thank you.

I keep the standard in this entire repo, there is no specific documents but 90% of files are kept in very good shape, please take a look on more files and point me to the one you were looking to, I pointed you more obvious issues

I'd (strongly) suggest that SONiC adopt a published coding standard, and perhaps we can help with that. As an example (admitting bias here!) Google publishes https://google.github.io/styleguide/ - I'm not suggesting that SONiC adopt this guide, just listing it as an example. Having this will both prevent back-and-forth and will help reduce load on reviewers.

@kcudnik
Copy link
Collaborator

kcudnik commented Sep 29, 2023

Yes, we will adopt or create some standard at some point but not at such big reviews, usually anyone is adding couple linea of code and not many classes and changing 45 files, one by one is able to adopt code

@Ashish1805 Ashish1805 force-pushed the ledamping branch 2 times, most recently from 2c9b338 to 6cce3ba Compare September 30, 2023 01:27
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lguohan do we allow each file to have different license?

Copy link
Contributor

Choose a reason for hiding this comment

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

no

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you saying none of the files that we are trying to upstream can have license?

cc: @mikeberesford @bhagatgit

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we have a license for entire repo not per single file

Choose a reason for hiding this comment

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

@lguohan @kcudnik Can you provide more details on the licensing.
On repos that have multiple contributors, does this mean that the contributor that started the repo would add license and others would not ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Addressed the review comments. Build issue is because of spell checker (aspellcheck.pl) failing due to it complaining about LLC in "Google LLC" in the copyright header. Not sure why LLC is causing spell check issue though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kcudnik We are still getting the licensing header issue resolved internally. Given that it is taking time, I have started generating the remaining commits to this PR. Can you please review them too? I dont know if I was supposed to generated separate PR for each commit or all the commits can be generated in same PR. Given these commits are dependent, generating multiple commits in same PRs sounds reasonable. Thanks.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Think you will hav3 still multiple classes and many many code in one pr, I would advise to have separate pr for specific modules

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to confirm, what do you mean exactly by separate PR here? Does it mean each commit should have its own PR, for example: commit 1 in PR https://github.com/sonic-net/sonic-sairedis/pull/XXXX, commit 2 in https://github.com/sonic-net/sonic-sairedis/pull/YYYY, commit 3 in https://github.com/sonic-net/sonic-sairedis/pull/ZZZZ, and so on?

Or you are saying multiple commits in this same PR is ok but each commit should not have multiple classes?

A lot of code depend on each other. For example: commit 2 in this PR depends on commit 1 in the PR. So, if we generate separate separate PR for each commits, they will not compile since dependency will not be present.

Copy link
Collaborator

Choose a reason for hiding this comment

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

no, not the commit, but if you are planning to add many big classes, it make sense to add each class separately, since we squash later all the commits to 1 commit on master, and if you add 40 files in one commit that will be overkill and unmanagable

@Ashish1805 Ashish1805 marked this pull request as ready for review October 3, 2023 18:37
syncd/ConcurrentQueue.h Outdated Show resolved Hide resolved
syncd/ConcurrentQueue.h Outdated Show resolved Hide resolved
syncd/ConcurrentQueue.h Outdated Show resolved Hide resolved
syncd/ConcurrentQueue.h Outdated Show resolved Hide resolved
syncd/ConcurrentQueue.h Outdated Show resolved Hide resolved
syncd/ConcurrentQueue.h Outdated Show resolved Hide resolved
@Ashish1805
Copy link
Contributor Author

@kcudnik I was wondering which tool do you use or will recommend to use to format the syncd code during development? Manually formatting the files one by one is time consuming and prone to missing the formatting.

I am mainly looking for formatter that helps to format: 1) { starts in new line, 2) space formatting for each line, 3) width for each line for code and comments, etc. Thanks.

@kcudnik
Copy link
Collaborator

kcudnik commented Oct 12, 2023

@kcudnik I was wondering which tool do you use or will recommend to use to format the syncd code during development? Manually formatting the files one by one is time consuming and prone to missing the formatting.

I am mainly looking for formatter that helps to format: 1) { starts in new line, 2) space formatting for each line, 3) width for each line for code and comments, etc. Thanks.

i dont use any specific tool, i put { in new line manually, and i use formating spacing in vim select code and press "="

@Ashish1805 Ashish1805 force-pushed the ledamping branch 3 times, most recently from 3987c8c to ad1b181 Compare October 21, 2023 02:59
Ashish1805 pushed a commit to Ashish1805/sonic-sairedis that referenced this pull request Oct 21, 2023
- Class to handle the port state change event callback from SAI and
  sending the events to syncd main thread for processing by link event
  damper.

Depends on: sonic-net#1297

HLD: sonic-net/SONiC#1071
…ing.

- This queue will be used to enqueue the port state change events by
  NotificationHandler and dequeued by syncd main thread and processed in
  link event damping logic.

HLD: sonic-net/SONiC#1071
Ashish1805 pushed a commit to Ashish1805/sonic-sairedis that referenced this pull request Oct 23, 2023
- Class to handle the port state change event callback from SAI and
  sending the events to syncd main thread for processing by link event
  damper.

Depends on: sonic-net#1297

HLD: sonic-net/SONiC#1071
Ashish1805 pushed a commit to Ashish1805/sonic-sairedis that referenced this pull request Oct 23, 2023
- Class to handle the port state change event callback from SAI and
  sending the events to syncd main thread for processing by link event
  damper.

Depends on: sonic-net#1297

HLD: sonic-net/SONiC#1071
syncd/ConcurrentQueue.h Show resolved Hide resolved
@Ashish1805 Ashish1805 changed the title [Link event damping] Syncd changes for link event damping. [Link event damping] Add concurrent queue. Oct 24, 2023
@kcudnik
Copy link
Collaborator

kcudnik commented Oct 24, 2023

HLD: sonic-net/SONiC#1071

@kcudnik kcudnik merged commit 1ef16ee into sonic-net:master Oct 24, 2023
13 checks passed
Ashish1805 pushed a commit to Ashish1805/sonic-sairedis that referenced this pull request Oct 24, 2023
- Class to handle the port state change event callback from SAI and
  sending the events to syncd main thread for processing by link event
  damper.

Depends on: sonic-net#1297

HLD: sonic-net/SONiC#1071
Ashish1805 pushed a commit to Ashish1805/sonic-sairedis that referenced this pull request Nov 7, 2023
- Class to handle the port state change event callback from SAI and
  sending the events to syncd main thread for processing by link event
  damper.

Depends on: sonic-net#1297

HLD: sonic-net/SONiC#1071
Ashish1805 pushed a commit to Ashish1805/sonic-sairedis that referenced this pull request Nov 14, 2023
- Class to handle the port state change event callback from SAI and
  sending the events to syncd main thread for processing by link event
  damper.

Depends on: sonic-net#1297

HLD: sonic-net/SONiC#1071
Ashish1805 pushed a commit to Ashish1805/sonic-sairedis that referenced this pull request Nov 16, 2023
- Class to handle the port state change event callback from SAI and
  sending the events to syncd main thread for processing by link event
  damper.

Depends on: sonic-net#1297

HLD: sonic-net/SONiC#1071
kcudnik pushed a commit that referenced this pull request Nov 16, 2023
- Class to handle the port state change event callback from SAI and
  sending the events to syncd main thread for processing by link event
  damper.

Depends on: #1297

HLD: sonic-net/SONiC#1071
prsunny pushed a commit to sonic-net/sonic-swss that referenced this pull request Jun 4, 2024
What I did
Added support for link event damping in SWSS.

Required Syncd PR: sonic-net/sonic-sairedis#1297
CLI PR: sonic-net/sonic-utilities#3001
HLD: https://github.com/sonic-net/SONiC/blob/master/doc/link_event_damping/Link-event-damping-HLD.md

Why I did it

How I verified it
Use the config interface damping CLI to set the port attributes on the switch and observe that Syncd processes link event damping parameters.
henrymao-zz pushed a commit to canonical/sonic-swss that referenced this pull request Jun 23, 2024
What I did
Added support for link event damping in SWSS.

Required Syncd PR: sonic-net/sonic-sairedis#1297
CLI PR: sonic-net/sonic-utilities#3001
HLD: https://github.com/sonic-net/SONiC/blob/master/doc/link_event_damping/Link-event-damping-HLD.md

Why I did it

How I verified it
Use the config interface damping CLI to set the port attributes on the switch and observe that Syncd processes link event damping parameters.
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.

5 participants