Skip to content

Conversation

@mpilman
Copy link
Contributor

@mpilman mpilman commented Jul 11, 2019

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:

grep ProcessMetrics *.xml | tail -1

won't necessary work as one would expect as the last trace-file in the list might not be the newest one.

@alexmiller-apple
Copy link
Contributor

I checked wavefront tailer, and they just slurp all XML files, which is probably what others do as well.

Copy link
Contributor

@ajbeamon ajbeamon left a 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.
@mpilman mpilman force-pushed the features/lexicographical-ordered-traces branch from 3666b10 to c26c68d Compare July 22, 2019 18:45
// 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));
Copy link
Contributor

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.

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());
Copy link
Contributor

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.

mpilman and others added 5 commits July 22, 2019 14:16
…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.
@ajbeamon
Copy link
Contributor

@fdb-build test this please

@ajbeamon ajbeamon merged commit 6e078a4 into apple:master Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make trace files lexicographically ordered

5 participants