Skip to content

feat: cache generation and sequence to reduce TSM filename parsing#26905

Merged
davidby-influx merged 8 commits intomaster-1.xfrom
DSB_cache_gen_level
Oct 16, 2025
Merged

feat: cache generation and sequence to reduce TSM filename parsing#26905
davidby-influx merged 8 commits intomaster-1.xfrom
DSB_cache_gen_level

Conversation

@davidby-influx
Copy link
Copy Markdown
Contributor

Parsing TSM filenames for generation and level is a large CPU
cost in the compaction planner. Because these file names do
not change except through an explicit TSMReader.Rename()
call, we can cache generation and level on creation and
rename to avoid CPU load.

Fixes #26794

}
if t.parseFileNameFunc != nil {
if t.generation, t.sequence, err = t.parseFileNameFunc(path); err != nil {
return fmt.Errorf("failed parsing filename %q for generation and sequence numbers: %w", path, err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This error adds context that the same error in NewTSMReader does not. I think the context here is redundant because the error from DefaultParseFileName (the only one we use) includes the filename.

I would remove the name from this context, but add that the parsing error occurred during TSMReader.Rename.

// that does not involve compaction planning, and was not created by the FileStore
t.generation, t.sequence, err = t.parseFileNameFunc(t.Path())
if err != nil {
return nil, err
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might be a good idea to add context that the parse filename error occurred during the NewTSMReader call.

Comment on lines +447 to +451
if t.parseFileNameFunc != nil {
if t.generation, t.sequence, err = t.parseFileNameFunc(path); err != nil {
return fmt.Errorf("failed parsing filename %q for generation and sequence numbers: %w", path, err)
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We may even want to refactor this chunk of code into

Comment on lines +276 to +283
if nil != t.parseFileNameFunc {
// If parseFileNameFunc is nil, we are in a test or another TSMReader use
// that does not involve compaction planning, and was not created by the FileStore
t.generation, t.sequence, err = t.parseFileNameFunc(t.Path())
if err != nil {
return nil, err
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We may want to refactor this chunk of code into it's own method, something like TSMReader.parseFileName. We repeat the same basic code twice and it might be nice to have a "safe" wrapper around parseFileNameFunc.

Copy link
Copy Markdown
Member

@gwossum gwossum left a comment

Choose a reason for hiding this comment

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

LGTM

@davidby-influx davidby-influx merged commit 8b1696a into master-1.x Oct 16, 2025
9 checks passed
@davidby-influx davidby-influx deleted the DSB_cache_gen_level branch October 16, 2025 16:00
davidby-influx added a commit that referenced this pull request Oct 16, 2025
…26905)

Parse TSM file names only on creation or rename and cache
the generation and level, instead of parsing them for those
values repeatedly

Fixes #26794
Fixes #26907
---------

Co-authored-by: Geoffrey Wossum <gwossum@influxdata.com>
(cherry picked from commit 8b1696a)
davidby-influx added a commit that referenced this pull request Oct 16, 2025
…26905) (#26913)

Parse TSM file names only on creation or rename and cache
the generation and level, instead of parsing them for those
values repeatedly

Fixes #26794
Fixes #26907
---------


(cherry picked from commit 8b1696a)

Co-authored-by: Geoffrey Wossum <gwossum@influxdata.com>
devanbenz pushed a commit that referenced this pull request Feb 5, 2026
…26905)

Parse TSM file names only on creation or rename and cache
the generation and level, instead of parsing them for those
values repeatedly

Fixes #26794

---------

Co-authored-by: Geoffrey Wossum <gwossum@influxdata.com>
(cherry picked from commit 8b1696a)
devanbenz added a commit that referenced this pull request Feb 5, 2026
…26905) (#27189)

Parse TSM file names only on creation or rename and cache
the generation and level, instead of parsing them for those
values repeatedly

Fixes #26794

---------


(cherry picked from commit 8b1696a)

Co-authored-by: davidby-influx <72418212+davidby-influx@users.noreply.github.com>
Co-authored-by: Geoffrey Wossum <gwossum@influxdata.com>
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.

2 participants