[TESTS] TSDB: Faster WAL benchmarks#16440
Merged
bboreham merged 2 commits intoprometheus:mainfrom Apr 22, 2025
Merged
Conversation
Less garbage collection. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Use the Builder abstraction instead of going via a map. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
machine424
approved these changes
Apr 17, 2025
Member
There was a problem hiding this comment.
Ran
diff --git a/tsdb/head_test.go b/tsdb/head_test.go
index 0e9fac18b..1e5d17c9a 100644
--- a/tsdb/head_test.go
+++ b/tsdb/head_test.go
@@ -436,6 +436,9 @@ func BenchmarkLoadWLs(b *testing.B) {
b.ResetTimer()
+ // hash
+ fmt.Println(b.Name(), testutil.DirHash(b, dir))
+
// Load the WAL.
for i := 0; i < b.N; i++ {
opts := DefaultHeadOptions()
diff --git a/util/testutil/directory.go b/util/testutil/directory.go
index 38dabd183..108a04f50 100644
--- a/util/testutil/directory.go
+++ b/util/testutil/directory.go
@@ -131,7 +131,7 @@ func NewTemporaryDirectory(name string, t T) (handler TemporaryDirectory) {
}
// DirHash returns a hash of all files attributes and their content within a directory.
-func DirHash(t *testing.T, path string) []byte {
+func DirHash(t testing.TB, path string) []byte {
hash := sha256.New()
err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
require.NoError(t, err)
@@ -149,14 +149,16 @@ func DirHash(t *testing.T, path string) []byte {
_, err = io.WriteString(hash, strconv.Itoa(int(info.Size())))
require.NoError(t, err)
- _, err = io.WriteString(hash, info.Name())
- require.NoError(t, err)
+ //_, err = io.WriteString(hash, info.Name())
+ //require.NoError(t, err)
- modTime, err := info.ModTime().GobEncode()
- require.NoError(t, err)
+ //modTime, err := info.ModTime().GobEncode()
+ //require.NoError(t, err)
- _, err = hash.Write(modTime)
- require.NoError(t, err)
+ //_, err = hash.Write(modTime)
+ //
+ //
+ // require.NoError(t, err)
return nil
})
require.NoError(t, err)on both for some cases and it seems we still produce the same segments.
lgtm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before:
After:
It makes even more of a difference if you push the number of series up.