mirror of
				https://github.com/prometheus/prometheus.git
				synced 2025-10-31 08:21:16 +01:00 
			
		
		
		
	TSDB: extend BenchmarkMemPostings_PostingsForLabelMatching to check merge speed
We need to create more postings entries so the merger has some work to do. Not material for the regexp ones as they match so few series. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
		
							parent
							
								
									5b5fee08af
								
							
						
					
					
						commit
						e630ffdbed
					
				| @ -1410,12 +1410,15 @@ func BenchmarkMemPostings_PostingsForLabelMatching(b *testing.B) { | |||||||
| 	slowRegexp := "^" + slowRegexpString() + "$" | 	slowRegexp := "^" + slowRegexpString() + "$" | ||||||
| 	b.Logf("Slow regexp length = %d", len(slowRegexp)) | 	b.Logf("Slow regexp length = %d", len(slowRegexp)) | ||||||
| 	slow := regexp.MustCompile(slowRegexp) | 	slow := regexp.MustCompile(slowRegexp) | ||||||
|  | 	const seriesPerLabel = 10 | ||||||
| 
 | 
 | ||||||
| 	for _, labelValueCount := range []int{1_000, 10_000, 100_000} { | 	for _, labelValueCount := range []int{1_000, 10_000, 100_000} { | ||||||
| 		b.Run(fmt.Sprintf("labels=%d", labelValueCount), func(b *testing.B) { | 		b.Run(fmt.Sprintf("labels=%d", labelValueCount), func(b *testing.B) { | ||||||
| 			mp := NewMemPostings() | 			mp := NewMemPostings() | ||||||
| 			for i := 0; i < labelValueCount; i++ { | 			for i := 0; i < labelValueCount; i++ { | ||||||
| 				mp.Add(storage.SeriesRef(i), labels.FromStrings("label", strconv.Itoa(i))) | 				for j := 0; j < seriesPerLabel; j++ { | ||||||
|  | 					mp.Add(storage.SeriesRef(i*seriesPerLabel+j), labels.FromStrings("__name__", strconv.Itoa(j), "label", strconv.Itoa(i))) | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			fp, err := ExpandPostings(mp.PostingsForLabelMatching(context.Background(), "label", fast.MatchString)) | 			fp, err := ExpandPostings(mp.PostingsForLabelMatching(context.Background(), "label", fast.MatchString)) | ||||||
| @ -1435,6 +1438,18 @@ func BenchmarkMemPostings_PostingsForLabelMatching(b *testing.B) { | |||||||
| 					mp.PostingsForLabelMatching(context.Background(), "label", slow.MatchString).Next() | 					mp.PostingsForLabelMatching(context.Background(), "label", slow.MatchString).Next() | ||||||
| 				} | 				} | ||||||
| 			}) | 			}) | ||||||
|  | 
 | ||||||
|  | 			b.Run("matcher=all", func(b *testing.B) { | ||||||
|  | 				for i := 0; i < b.N; i++ { | ||||||
|  | 					// Match everything. | ||||||
|  | 					p := mp.PostingsForLabelMatching(context.Background(), "label", func(_ string) bool { return true }) | ||||||
|  | 					var sum storage.SeriesRef | ||||||
|  | 					// Iterate through all results to exercise merge function. | ||||||
|  | 					for p.Next() { | ||||||
|  | 						sum += p.At() | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			}) | ||||||
| 		}) | 		}) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user