aboutsummaryrefslogtreecommitdiff
path: root/go/analysis/passes/fieldalignment/fieldalignment.go
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2023-03-15 13:19:36 -0400
committerDan Willemsen <dwillemsen@google.com>2023-03-15 14:18:08 -0400
commit09c5a32afc5b66f28f166a68afe1fc71afbf9b73 (patch)
tree194d7b0e539d014393564a256bec571e18d6533a /go/analysis/passes/fieldalignment/fieldalignment.go
parentf10932f763d058b0dcb3acfb795c869996fef47b (diff)
parent031fc75960d487b0b15db12fb328676236a3a39c (diff)
downloadgolang-x-tools-master.tar.gz
Upgrade golang-x-tools to v0.7.0HEADmastermain
Not using external_updater this time to switch to the new upstream tags. Test: treehugger Change-Id: I31488b4958a366ed7f183bb387d3e1446acc13ae
Diffstat (limited to 'go/analysis/passes/fieldalignment/fieldalignment.go')
-rw-r--r--go/analysis/passes/fieldalignment/fieldalignment.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/go/analysis/passes/fieldalignment/fieldalignment.go b/go/analysis/passes/fieldalignment/fieldalignment.go
index 78afe94ab..aff663046 100644
--- a/go/analysis/passes/fieldalignment/fieldalignment.go
+++ b/go/analysis/passes/fieldalignment/fieldalignment.go
@@ -23,7 +23,7 @@ import (
const Doc = `find structs that would use less memory if their fields were sorted
This analyzer find structs that can be rearranged to use less memory, and provides
-a suggested edit with the optimal order.
+a suggested edit with the most compact order.
Note that there are two different diagnostics reported. One checks struct size,
and the other reports "pointer bytes" used. Pointer bytes is how many bytes of the
@@ -41,6 +41,11 @@ has 24 pointer bytes because it has to scan further through the *uint32.
struct { string; uint32 }
has 8 because it can stop immediately after the string pointer.
+
+Be aware that the most compact order is not always the most efficient.
+In rare cases it may cause two variables each updated by its own goroutine
+to occupy the same CPU cache line, inducing a form of memory contention
+known as "false sharing" that slows down both goroutines.
`
var Analyzer = &analysis.Analyzer{