Merge pull request #16436 from prymitive/slicelabels
	
		
			
	
		
	
	
		
			
				
	
				buf.build / lint and publish (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Go tests (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / More Go tests (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Go tests with previous Go version (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / UI tests (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Go tests on Windows (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Mixins tests (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for common architectures (0) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for common architectures (1) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for common architectures (2) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (0) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (1) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (10) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (11) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (2) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (3) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (4) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (5) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (6) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (7) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (8) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (9) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Check generated parser (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / golangci-lint (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / fuzzing (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / codeql (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Stale Check / stale (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Lock Threads / action (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Report status of build Prometheus for all architectures (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Publish main branch artifacts (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Publish release artefacts (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Publish UI on npm Registry (push) Has been cancelled
				
					Details
				
			
		
	
				
					
				
			
				
	
				buf.build / lint and publish (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Go tests (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / More Go tests (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Go tests with previous Go version (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / UI tests (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Go tests on Windows (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Mixins tests (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for common architectures (0) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for common architectures (1) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for common architectures (2) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (0) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (1) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (10) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (11) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (2) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (3) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (4) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (5) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (6) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (7) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (8) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Build Prometheus for all architectures (9) (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Check generated parser (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / golangci-lint (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / fuzzing (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / codeql (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Stale Check / stale (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				Lock Threads / action (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Report status of build Prometheus for all architectures (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Publish main branch artifacts (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Publish release artefacts (push) Has been cancelled
				
					Details
				
			
		
			
				
	
				CI / Publish UI on npm Registry (push) Has been cancelled
				
					Details
				
			
		
	Use stringlabels by default
This commit is contained in:
		
						commit
						2e9ab9cc62
					
				|  | @ -18,8 +18,8 @@ jobs: | ||||||
|       - uses: ./.github/promci/actions/setup_environment |       - uses: ./.github/promci/actions/setup_environment | ||||||
|         with: |         with: | ||||||
|           enable_npm: true |           enable_npm: true | ||||||
|       - run: make GOOPTS=--tags=stringlabels GO_ONLY=1 SKIP_GOLANGCI_LINT=1 |       - run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1 | ||||||
|       - run: go test --tags=stringlabels ./tsdb/ -test.tsdb-isolation=false |       - run: go test ./tsdb/ -test.tsdb-isolation=false | ||||||
|       - run: make -C documentation/examples/remote_storage |       - run: make -C documentation/examples/remote_storage | ||||||
|       - run: make -C documentation/examples |       - run: make -C documentation/examples | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -14,10 +14,8 @@ build: | ||||||
|         all: |         all: | ||||||
|             - netgo |             - netgo | ||||||
|             - builtinassets |             - builtinassets | ||||||
|             - stringlabels |  | ||||||
|         windows: |         windows: | ||||||
|             - builtinassets |             - builtinassets | ||||||
|             - stringlabels |  | ||||||
|     ldflags: | |     ldflags: | | ||||||
|         -X github.com/prometheus/common/version.Version={{.Version}} |         -X github.com/prometheus/common/version.Version={{.Version}} | ||||||
|         -X github.com/prometheus/common/version.Revision={{.Revision}} |         -X github.com/prometheus/common/version.Revision={{.Revision}} | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| // See the License for the specific language governing permissions and
 | // See the License for the specific language governing permissions and
 | ||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| //go:build !stringlabels && !dedupelabels
 | //go:build slicelabels
 | ||||||
| 
 | 
 | ||||||
| package labels | package labels | ||||||
| 
 | 
 | ||||||
|  | @ -453,7 +453,7 @@ func (b *ScratchBuilder) Add(name, value string) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // UnsafeAddBytes adds a name/value pair, using []byte instead of string.
 | // UnsafeAddBytes adds a name/value pair, using []byte instead of string.
 | ||||||
| // The '-tags stringlabels' version of this function is unsafe, hence the name.
 | // The default version of this function is unsafe, hence the name.
 | ||||||
| // This version is safe - it copies the strings immediately - but we keep the same name so everything compiles.
 | // This version is safe - it copies the strings immediately - but we keep the same name so everything compiles.
 | ||||||
| func (b *ScratchBuilder) UnsafeAddBytes(name, value []byte) { | func (b *ScratchBuilder) UnsafeAddBytes(name, value []byte) { | ||||||
| 	b.add = append(b.add, Label{Name: string(name), Value: string(value)}) | 	b.add = append(b.add, Label{Name: string(name), Value: string(value)}) | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| // See the License for the specific language governing permissions and
 | // See the License for the specific language governing permissions and
 | ||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| //go:build stringlabels
 | //go:build !slicelabels && !dedupelabels
 | ||||||
| 
 | 
 | ||||||
| package labels | package labels | ||||||
| 
 | 
 | ||||||
|  | @ -70,7 +70,7 @@ func (ls Labels) IsZero() bool { | ||||||
| 
 | 
 | ||||||
| // MatchLabels returns a subset of Labels that matches/does not match with the provided label names based on the 'on' boolean.
 | // MatchLabels returns a subset of Labels that matches/does not match with the provided label names based on the 'on' boolean.
 | ||||||
| // If on is set to true, it returns the subset of labels that match with the provided label names and its inverse when 'on' is set to false.
 | // If on is set to true, it returns the subset of labels that match with the provided label names and its inverse when 'on' is set to false.
 | ||||||
| // TODO: This is only used in printing an error message
 | // TODO: This is only used in printing an error message.
 | ||||||
| func (ls Labels) MatchLabels(on bool, names ...string) Labels { | func (ls Labels) MatchLabels(on bool, names ...string) Labels { | ||||||
| 	b := NewBuilder(ls) | 	b := NewBuilder(ls) | ||||||
| 	if on { | 	if on { | ||||||
|  | @ -292,6 +292,7 @@ func Equal(ls, o Labels) bool { | ||||||
| func EmptyLabels() Labels { | func EmptyLabels() Labels { | ||||||
| 	return Labels{} | 	return Labels{} | ||||||
| } | } | ||||||
|  | 
 | ||||||
| func yoloBytes(s string) []byte { | func yoloBytes(s string) []byte { | ||||||
| 	return unsafe.Slice(unsafe.StringData(s), len(s)) | 	return unsafe.Slice(unsafe.StringData(s), len(s)) | ||||||
| } | } | ||||||
|  | @ -364,7 +365,7 @@ func Compare(a, b Labels) int { | ||||||
| 	return +1 | 	return +1 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Copy labels from b on top of whatever was in ls previously, reusing memory or expanding if needed.
 | // CopyFrom will copy labels from b on top of whatever was in ls previously, reusing memory or expanding if needed.
 | ||||||
| func (ls *Labels) CopyFrom(b Labels) { | func (ls *Labels) CopyFrom(b Labels) { | ||||||
| 	ls.data = b.data // strings are immutable
 | 	ls.data = b.data // strings are immutable
 | ||||||
| } | } | ||||||
|  | @ -434,11 +435,11 @@ func (ls Labels) DropMetricName() Labels { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // InternStrings is a no-op because it would only save when the whole set of labels is identical.
 | // InternStrings is a no-op because it would only save when the whole set of labels is identical.
 | ||||||
| func (ls *Labels) InternStrings(intern func(string) string) { | func (ls *Labels) InternStrings(_ func(string) string) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // ReleaseStrings is a no-op for the same reason as InternStrings.
 | // ReleaseStrings is a no-op for the same reason as InternStrings.
 | ||||||
| func (ls Labels) ReleaseStrings(release func(string)) { | func (ls Labels) ReleaseStrings(_ func(string)) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Builder allows modifying Labels.
 | // Builder allows modifying Labels.
 | ||||||
|  | @ -603,7 +604,7 @@ func (b *ScratchBuilder) Add(name, value string) { | ||||||
| 	b.add = append(b.add, Label{Name: name, Value: value}) | 	b.add = append(b.add, Label{Name: name, Value: value}) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Add a name/value pair, using []byte instead of string to reduce memory allocations.
 | // UnsafeAddBytes adds a name/value pair using []byte instead of string to reduce memory allocations.
 | ||||||
| // The values must remain live until Labels() is called.
 | // The values must remain live until Labels() is called.
 | ||||||
| func (b *ScratchBuilder) UnsafeAddBytes(name, value []byte) { | func (b *ScratchBuilder) UnsafeAddBytes(name, value []byte) { | ||||||
| 	b.add = append(b.add, Label{Name: yoloString(name), Value: yoloString(value)}) | 	b.add = append(b.add, Label{Name: yoloString(name), Value: yoloString(value)}) | ||||||
|  | @ -631,7 +632,7 @@ func (b *ScratchBuilder) Labels() Labels { | ||||||
| 	return b.output | 	return b.output | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Write the newly-built Labels out to ls, reusing an internal buffer.
 | // Overwrite will write the newly-built Labels out to ls, reusing an internal buffer.
 | ||||||
| // Callers must ensure that there are no other references to ls, or any strings fetched from it.
 | // Callers must ensure that there are no other references to ls, or any strings fetched from it.
 | ||||||
| func (b *ScratchBuilder) Overwrite(ls *Labels) { | func (b *ScratchBuilder) Overwrite(ls *Labels) { | ||||||
| 	size := labelsSize(b.add) | 	size := labelsSize(b.add) | ||||||
|  | @ -644,7 +645,7 @@ func (b *ScratchBuilder) Overwrite(ls *Labels) { | ||||||
| 	ls.data = yoloString(b.overwriteBuffer) | 	ls.data = yoloString(b.overwriteBuffer) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Symbol-table is no-op, just for api parity with dedupelabels.
 | // SymbolTable is no-op, just for api parity with dedupelabels.
 | ||||||
| type SymbolTable struct{} | type SymbolTable struct{} | ||||||
| 
 | 
 | ||||||
| func NewSymbolTable() *SymbolTable { return nil } | func NewSymbolTable() *SymbolTable { return nil } | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| // See the License for the specific language governing permissions and
 | // See the License for the specific language governing permissions and
 | ||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| //go:build !stringlabels && !dedupelabels
 | //go:build slicelabels
 | ||||||
| 
 | 
 | ||||||
| package labels | package labels | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| // See the License for the specific language governing permissions and
 | // See the License for the specific language governing permissions and
 | ||||||
| // limitations under the License.
 | // limitations under the License.
 | ||||||
| 
 | 
 | ||||||
| //go:build stringlabels
 | //go:build !slicelabels && !dedupelabels
 | ||||||
| 
 | 
 | ||||||
| package labels | package labels | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -77,13 +77,13 @@ func TestNoDeadlock(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| func labelsWithHashCollision() (labels.Labels, labels.Labels) { | func labelsWithHashCollision() (labels.Labels, labels.Labels) { | ||||||
| 	// These two series have the same XXHash; thanks to https://github.com/pstibrany/labels_hash_collisions
 | 	// These two series have the same XXHash; thanks to https://github.com/pstibrany/labels_hash_collisions
 | ||||||
| 	ls1 := labels.FromStrings("__name__", "metric", "lbl1", "value", "lbl2", "l6CQ5y") | 	ls1 := labels.FromStrings("__name__", "metric", "lbl", "HFnEaGl") | ||||||
| 	ls2 := labels.FromStrings("__name__", "metric", "lbl1", "value", "lbl2", "v7uDlF") | 	ls2 := labels.FromStrings("__name__", "metric", "lbl", "RqcXatm") | ||||||
| 
 | 
 | ||||||
| 	if ls1.Hash() != ls2.Hash() { | 	if ls1.Hash() != ls2.Hash() { | ||||||
| 		// These ones are the same when using -tags stringlabels
 | 		// These ones are the same when using -tags slicelabels
 | ||||||
| 		ls1 = labels.FromStrings("__name__", "metric", "lbl", "HFnEaGl") | 		ls1 = labels.FromStrings("__name__", "metric", "lbl1", "value", "lbl2", "l6CQ5y") | ||||||
| 		ls2 = labels.FromStrings("__name__", "metric", "lbl", "RqcXatm") | 		ls2 = labels.FromStrings("__name__", "metric", "lbl1", "value", "lbl2", "v7uDlF") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if ls1.Hash() != ls2.Hash() { | 	if ls1.Hash() != ls2.Hash() { | ||||||
|  |  | ||||||
|  | @ -6372,13 +6372,13 @@ func TestHeadCompactionWhileAppendAndCommitExemplar(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| func labelsWithHashCollision() (labels.Labels, labels.Labels) { | func labelsWithHashCollision() (labels.Labels, labels.Labels) { | ||||||
| 	// These two series have the same XXHash; thanks to https://github.com/pstibrany/labels_hash_collisions
 | 	// These two series have the same XXHash; thanks to https://github.com/pstibrany/labels_hash_collisions
 | ||||||
| 	ls1 := labels.FromStrings("__name__", "metric", "lbl1", "value", "lbl2", "l6CQ5y") | 	ls1 := labels.FromStrings("__name__", "metric", "lbl", "HFnEaGl") | ||||||
| 	ls2 := labels.FromStrings("__name__", "metric", "lbl1", "value", "lbl2", "v7uDlF") | 	ls2 := labels.FromStrings("__name__", "metric", "lbl", "RqcXatm") | ||||||
| 
 | 
 | ||||||
| 	if ls1.Hash() != ls2.Hash() { | 	if ls1.Hash() != ls2.Hash() { | ||||||
| 		// These ones are the same when using -tags stringlabels
 | 		// These ones are the same when using -tags slicelabels
 | ||||||
| 		ls1 = labels.FromStrings("__name__", "metric", "lbl", "HFnEaGl") | 		ls1 = labels.FromStrings("__name__", "metric", "lbl1", "value", "lbl2", "l6CQ5y") | ||||||
| 		ls2 = labels.FromStrings("__name__", "metric", "lbl", "RqcXatm") | 		ls2 = labels.FromStrings("__name__", "metric", "lbl1", "value", "lbl2", "v7uDlF") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if ls1.Hash() != ls2.Hash() { | 	if ls1.Hash() != ls2.Hash() { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue