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

🌱 Some more cleanup for field placement #3791

Closed
wants to merge 1 commit into from

Conversation

naveensrinivasan
Copy link
Member

  • Cleanup for fieldplacement in struct

What kind of change does this PR introduce?

(Is it a bug fix, feature, docs update, something else?)

What is the current behavior?

What is the new behavior (if this is a feature change)?**

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

Special notes for your reviewer

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)


- Cleanup for fieldplacement in struct

Signed-off-by: naveensrinivasan <[email protected]>
@naveensrinivasan naveensrinivasan requested a review from a team as a code owner January 13, 2024 16:49
@naveensrinivasan naveensrinivasan requested review from raghavkaul and removed request for a team January 13, 2024 16:49
Copy link

codecov bot commented Jan 13, 2024

Codecov Report

Merging #3791 (4a2af09) into main (497b851) will increase coverage by 3.90%.
Report is 127 commits behind head on main.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3791      +/-   ##
==========================================
+ Coverage   66.61%   70.52%   +3.90%     
==========================================
  Files         230      230              
  Lines       15622    15622              
==========================================
+ Hits        10407    11017     +610     
+ Misses       4599     3932     -667     
- Partials      616      673      +57     

Comment on lines -59 to -63
//
//nolint:govet
type CheckResult struct {
Name string
Version int
Copy link
Member

Choose a reason for hiding this comment

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

similar comment on human-readability. We should decide if we care about this

Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the time, Scorecard is used by non-humans. So it helps to have performance IMO. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

So it helps to have performance IMO. Thoughts?

My first thought is, does it matter? I know we have the linter (and could disable it if the answer is no), but is this a performance bottleneck? Compared to the I/O and API operations we need to wait for anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

The compiler utilizes the L1 cache based on the word size.

https://articles.wesionary.team/simple-data-alignment-technique-to-speed-up-your-struct-in-golang-954c43faa1fe
https://www.ardanlabs.com/blog/2013/07/understanding-type-in-go.html

It helps to make it better.

I understand API Operations.

Copy link
Member

Choose a reason for hiding this comment

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

The reason I ask for benchmarks is it's not quite as simple:
golang/go#10014 (comment)

That seems like it is trying to solve a 1970s problem, namely packing structs to use as little space as possible. The 2010s problem is to put related fields near each other to reduce cache misses

Comment on lines 28 to +32
type RawResults struct {
BinaryArtifactResults BinaryArtifactData
Metadata MetadataData
BranchProtectionResults BranchProtectionsData
CIIBestPracticesResults CIIBestPracticesData
CITestResults CITestData
CodeReviewResults CodeReviewData
PinningDependenciesResults PinningDependenciesData
SecurityPolicyResults SecurityPolicyData
Copy link
Member

Choose a reason for hiding this comment

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

So I know this was alphabetized recently to find the data easier.
#3540

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link

github-actions bot commented Feb 6, 2024

This pull request is stale because it has been open for 10 days with no activity

@github-actions github-actions bot added the Stale label Feb 6, 2024
Copy link
Member

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

Replied to the thread as well. Ultimately it's always a reversible decision, so leaving it up to you.

Comment on lines -59 to -63
//
//nolint:govet
type CheckResult struct {
Name string
Version int
Copy link
Member

Choose a reason for hiding this comment

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

The reason I ask for benchmarks is it's not quite as simple:
golang/go#10014 (comment)

That seems like it is trying to solve a 1970s problem, namely packing structs to use as little space as possible. The 2010s problem is to put related fields near each other to reduce cache misses

@github-actions github-actions bot removed the Stale label Mar 6, 2024
Copy link

This pull request has been marked stale because it has been open for 10 days with no activity

@github-actions github-actions bot added Stale and removed Stale labels Mar 21, 2024
Copy link

github-actions bot commented Apr 2, 2024

This pull request has been marked stale because it has been open for 10 days with no activity

@github-actions github-actions bot added Stale and removed Stale labels Apr 2, 2024
Copy link

This pull request has been marked stale because it has been open for 10 days with no activity

@github-actions github-actions bot added the Stale label Apr 14, 2024
@spencerschrock spencerschrock deleted the naveen/fix/cleanup branch April 15, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants