-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Make trace files lexicographically ordered #1828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make trace files lexicographically ordered #1828
Conversation
|
I checked wavefront tailer, and they just slurp all XML files, which is probably what others do as well. |
ajbeamon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There exists here a function cleanupTraceFiles which is sorting the trace files, and this can get much simpler if the filenames are lexicographic. I think we should also update that.
Let's also add a release note indicating the change to the trace file name format.
This resolves apple#1825 The basic idea is that we prefix every sequence number with its with, separated by a dot. That way the filename length isn't increased drastically (unlike using a fixed whidth number with 0-padding) and the file names will be lexicographically ordered.
3666b10 to
c26c68d
Compare
flow/FileTraceLogWriter.cpp
Outdated
| // this should be enough - if not we could make the base larger... | ||
| ASSERT(index > 0 && index < 10); | ||
|
|
||
| int indexWidth = int(::floor(log10f(float(index)) + 1.0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index is currently an int, so the maximum it could be is ~2B. I suppose if we wanted to support all of that range, we could do that by removing the + 1.0 from indexWidth to start at 0, and then stick with the characters 0-9. Or, if we want to support an extended range, we should also increase the size of index. It seems unlikely to me that it will be necessary, but I'm fine either way. If we do support the extended range, we should update the comment above that suggests making the base larger.
flow/FileTraceLogWriter.cpp
Outdated
| lastError(errno); | ||
| if (errno == EEXIST) | ||
| finalname = format("%s.%d.%s", basename.c_str(), ++index, extension.c_str()); | ||
| finalname = format("%s.%c.%d.%s", basename.c_str(), indexWidthC, ++index, extension.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we are incrementing index here, indexWidthC may need to change as well.
Co-Authored-By: A.J. Beamon <[email protected]>
Co-Authored-By: A.J. Beamon <[email protected]>
…mpilman/foundationdb into features/lexicographical-ordered-traces
there can be at most 2^32 files with a distinct index. Therefore `log10(index) < 10` - this means base 10 is good enough.
Co-Authored-By: A.J. Beamon <[email protected]>
|
@fdb-build test this please |
This resolves #1825
The basic idea is that we prefix every sequence number with its with,
separated by a dot. That way the filename length isn't increased
drastically (unlike using a fixed whidth number with 0-padding)
and the file names will be lexicographically ordered.
The main motivation for this case is to make it easier to investigate issues
in traces through the command-line. Without this change a command like this:
won't necessary work as one would expect as the last trace-file in the list might not be the newest one.