Opened 9 years ago

Last modified 8 years ago

#3255 closed defect

[PATCH] Use date in commands.txt directory — at Version 5

Reported by: elexis Owned by:
Priority: Must Have Milestone: Alpha 20
Component: Core engine Keywords: patch
Cc: Patch:

Description (last modified by elexis)

Currently the commands.txt files (and ooslog output) are created in a subdirectory of the sim-log directory.

The commands.txt file contains all commands sent by players and is therefore the key file when filing bug reports and replaying previous games visually with #9.

The problem I want to address here is that the subdirectory that contains the commands.txt file has a bad name. It uses the process ID and a sequential number. There are three problems with that:

  1. Old files will be overwritten.
  2. It is not easy to identify the correct directory when filing bugreports.
  3. The visual replay function #9 will be accessible from the main menu at some point. It should then display the correct date and time without relying on a fragile timestamp.

Deeper analysis:

1. Why files will be overwritten

Quoting from: http://en.wikipedia.org/wiki/Process_identifier#Unix-like

Process IDs are usually allocated on a sequential basis, beginning at 0 and rising to a maximum value which varies from system to system. Once this limit is reached, allocation restarts at 300 and again increases.

Therefore pIDs are not random but have a very limited keyspace (4 to 5 figures), which makes it very possible that old files will be overwritten. The sequential number that will be added to the PID will only be added if you play multiple games with the same instance of 0ad. If you reboot and get the same PID, then you overwrite the commands.txt file.

2. Identifying the correct directory

When people want to file a bugreport and the error appeared on the last game they played, then they only have to identify the file with the most recent filedate. Some have already problems with that (Mac users in particular, since that information isn't displayed by default). If the match was some time ago, the timestamp definitely helps identifying the correct file.


Open question: Should we make a subdirectory for the revision, so that the directory won't contain replay logs of different revisions? I.e. .../sim-log/alpha18/2015-05-20_03-38-38/commands.txt? No - that info should be saved to the commands.txt file.

Change History (7)

comment:1 by trompetin17, 9 years ago

if you have 3 or more 0ad open in your machine?

in reply to:  1 comment:2 by elexis, 9 years ago

Replying to trompetin17:

if you have 3 or more 0ad open in your machine?

I think you mean point (1). It can happen that the commands.txt files are overwritten after rebooting when 0ad gets the same PID as some time earlier. The more files are in that directory, the more probable it becomes, since the PID only has 4 to 5 letters.

If the directory is empty, then the chance is 1/99999 = 0,001%. But if you test a lot then you have many files, for example 5000 on my machine. The probability that files will be overwritten is then 5000/99999 = 5% already. This means every 20th file will be overwritten.

It should be fixed for the other two reasons as well.

comment:3 by leper, 9 years ago

Keywords: review removed

Broken in case of multiple instances, incomplete header changes, see discussion on irc.

by elexis, 9 years ago

Now uses sim-log/YYYY-MM-DD_id/commands.txt. Additional info like timestamp should be saved into the commands.txt file (see #3258).

comment:4 by elexis, 9 years ago

Priority: Should HaveNice to Have
Summary: [PATCH] Use date + time in sim-log directory instead of pid[PATCH] Use date in commands.txt directory

comment:5 by elexis, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.