Skip to content

Sort events by time in console #2327

@rvolosatovs

Description

@rvolosatovs

Summary

Console should sort events by time field

Why do we need this?

To give sensible log data to the users.

What is already there? What do you see now?

Seems that events are printed in the same order they arrive, which is not necessarily correct and confuses the user.

2020-04-09-14:50:29-screenshot

You can see, for example, join-request being accepted before it's received, which does not make sense.

What is missing? What do you want to see?

Events sorted by time in the console for clarity.

How do you propose to implement this?

Let A be the list of events presented in the console, let e be the event received.
If tail(A).time <= e.time, A = A ++ e, repeat with next e.
Otherwise, use binary search to find the index at which to insert e and do so. Note, it may be beneficial to only search over n last elements, where n<len(A), since in most cases, the insertion index i will be close to the tail.
Note(2), just looping in reverse order over A in order to find i is most probably also fine, however, once we start batching events and introduce more and more events, this may become problematic and using log(n) search algorithm may prove to be beneficial, it's also very straight-forward to implement. We could start with binary search over last 32 events perhaps and if not found, go to next "chunk" of events.
We should probably consider limiting the amount of events presented in the console as well, which can influence the choice of algorithm and it's parameters.

Can you do this yourself and submit a Pull Request?

I could, but I guess @bafonins is better suited for the job.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions