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

cleanup: Use Go 1.19 atomic types #5792

Merged
merged 4 commits into from Oct 23, 2023
Merged

Conversation

ohill
Copy link
Contributor

@ohill ohill commented Oct 20, 2023

Summary

Go 1.19 introduced types like atomic.Uint64, atomic.Int32, atomic.Bool, that provide automatic alignment for 32-bit platforms, plus extra safety to ensure access to the underlying value only uses atomic methods. This converts nearly all the calls to atomic to use these types. It also catches a few places where non-atomic and atomic access were mixed together.

Test Plan

Removed TestAtomicVariablesAlignment

    sed -E -i -e 's/atomic.Load(Int32|Uint64|Uint32|Int64)\(&([^\)]+)\)/\2.Load()/g' \
          -e 's/atomic.Store(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+)\)/\2.Store(\3)/g' \
          -e 's/atomic.CompareAndSwap(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+), ([^,]+)\)/\2.CompareAndSwap(\3, \4)/g' \
          -e 's/atomic.Add(Int32|Uint64|Uint32|Int64)\(&([^,]+), ([^,]+)\)/\2.Add(\3)/g' *.go
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #5792 (d0f706d) into master (6c482ab) will decrease coverage by 0.01%.
Report is 4 commits behind head on master.
The diff coverage is 73.82%.

@@            Coverage Diff             @@
##           master    #5792      +/-   ##
==========================================
- Coverage   55.55%   55.54%   -0.01%     
==========================================
  Files         474      474              
  Lines       66850    66848       -2     
==========================================
- Hits        37138    37133       -5     
- Misses      27188    27190       +2     
- Partials     2524     2525       +1     
Files Coverage Δ
cmd/tealdbg/cdtSession.go 66.29% <100.00%> (ø)
crypto/merklearray/worker.go 100.00% <100.00%> (ø)
data/pools/transactionPool.go 51.45% <100.00%> (ø)
ledger/bulletin.go 92.30% <100.00%> (-1.93%) ⬇️
network/netidentity.go 100.00% <100.00%> (ø)
network/netprio.go 72.00% <100.00%> (ø)
network/p2pNetwork.go 65.43% <100.00%> (ø)
rpcs/blockService.go 74.33% <100.00%> (ø)
rpcs/ledgerService.go 53.12% <100.00%> (ø)
util/condvar/timedwait.go 100.00% <100.00%> (ø)
... and 10 more

... and 13 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

.golangci.yml Outdated Show resolved Hide resolved
data/pools/transactionPool.go Show resolved Hide resolved
ledger/bulletin.go Show resolved Hide resolved
rpcs/blockService.go Outdated Show resolved Hide resolved
Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

Basically the same questions as Jason had

Copy link
Contributor

@cce cce left a comment

Choose a reason for hiding this comment

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

Seems to have possibly fixed some bugs with handling of atomics

ledger/eval/prefetcher/prefetcher.go Show resolved Hide resolved
network/p2pNetwork.go Show resolved Hide resolved
network/wsNetwork.go Show resolved Hide resolved
shared/pingpong/pingpong.go Show resolved Hide resolved
@algorandskiy algorandskiy merged commit 40c16e5 into algorand:master Oct 23, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants