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

Move int64s to top of struct to resolve alignment issue on ARM #2521

Merged
merged 3 commits into from
Jul 10, 2019

Conversation

ethanadams
Copy link
Collaborator

@ethanadams ethanadams commented Jul 10, 2019

What:
Move int64s used in atomic operations to top of struct
Why:
Resolves alignment issue on ARM (golang/go#23345)

Please describe the tests:

  • Test 1:
  • Test 2:

Please describe the performance impact:

Code Review Checklist (to be filled out by reviewer)

  • Does the PR describe what changes are being made?
  • Does the PR describe why the changes are being made?
  • Does the code follow our style guide?
  • Does the code follow our testing guide?
  • Is the PR appropriately sized? (If it could be broken into smaller PRs it should be)
  • Does the new code have enough tests? (every PR should have tests or justification otherwise. Bug-fix PRs especially)
  • Does the new code have enough documentation that answers "how do I use it?" and "what does it do?"? (both source documentation and higher level, diagrams?)
  • Does any documentation need updating?
  • Do the database access patterns make sense?

@ethanadams ethanadams added Request Code Review Code review requested Reviewer Can Merge If all checks have passed, non-owner can merge PR labels Jul 10, 2019
@cla-bot cla-bot bot added the cla-signed label Jul 10, 2019
@@ -44,8 +44,8 @@ func newInfo(path string) (*InfoDB, error) {
dbutil.Configure(db, mon)

infoDb := &InfoDB{db: db}
infoDb.pieceinfo = pieceinfo{infoDb, spaceUsed{sync.Once{}, 0}}
infoDb.bandwidthdb = bandwidthdb{infoDb, bandwidthUsed{sync.RWMutex{}, time.Time{}, 0}}
infoDb.pieceinfo = pieceinfo{infoDb, spaceUsed{0, sync.Once{}}}
Copy link
Member

Choose a reason for hiding this comment

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

okay for this PR buuuut

definitely a strong preference to not create structs with unnamed, positional fields. always always use named fields in struct creation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

used int64
once sync.Once
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment why it's in a different order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -22,9 +22,9 @@ type bandwidthdb struct {
}

type bandwidthUsed struct {
used int64
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment why it's in a different order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@jenlij jenlij left a comment

Choose a reason for hiding this comment

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

Looks fine, but what do you mean by an alignment issue?

@ethanadams ethanadams merged commit f06aec0 into master Jul 10, 2019
@ethanadams ethanadams deleted the ethan/arm-64bit-atomics branch July 10, 2019 17:47
littleskunk pushed a commit that referenced this pull request Jul 10, 2019
* move int64s to top of struct to resolve alignment issue on ARM

(cherry picked from commit f06aec0)
@wthorp
Copy link
Contributor

wthorp commented Jul 10, 2019

Looks fine, but what do you mean by an alignment issue?

The's a known issue with certain 'atomic' methods on 64-bit datatypes on certain ARM processers.
https://golang.org/pkg/sync/atomic/#pkg-note-BUG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed Request Code Review Code review requested Reviewer Can Merge If all checks have passed, non-owner can merge PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants