Skip to content
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

v1: require message index entries be sorted? #241

Open
wkalt opened this issue Feb 23, 2022 · 3 comments
Open

v1: require message index entries be sorted? #241

wkalt opened this issue Feb 23, 2022 · 3 comments
Labels
feature New feature or request

Comments

@wkalt
Copy link
Contributor

wkalt commented Feb 23, 2022

This enables a reader to do a binary search over the message index. Insertion sort can be used to sort the section in place performantly, under the assumption it is already mostly ordered.

@wkalt wkalt added the feature New feature or request label Feb 23, 2022
@defunctzombie
Copy link
Contributor

The downside is that if your logTime does go out of order, you now need to do more work to keep this sorted array. Work that the robot maybe doesn't need to do and its easy for a reader to do.

@jameskuszmaul-brt
Copy link
Contributor

On a per-topic basis, I'd expect that most writers could probably enforce ordering? I.e., a message sent at t=1s in topic /foo can probably be guaranteed to be logged before a message sent at t=2s also on /foo. But a message sent at t=2s on /bar may be present before any /foo messages in the log.

I've also seen logfiles specs that state that messages, even across topics, will not be out of order by more than a certain amount of time, which allows the reader to only have to read ahead by a certain amount to sort.

@wkalt
Copy link
Contributor Author

wkalt commented Mar 2, 2022

well, to be clear this concerns the order of the entries in the index, not in the file itself.

The file can have out of order messages, though it could potentially violate some expectations of consuming applications. I agree they will generally be ordered or almost totally ordered.

The question here is whether the array of <timestamp, uint64> tuples in the Message Index record should be sorted.

An array already has to be maintained for these, so it's just a question of whether the array is sorted before being written out to disk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

No branches or pull requests

3 participants