po-devs/po-server-goodies

Make tournaments use less file access!

Closed this issue · 5 comments

Commands such as /leaderboard read the whole file everytime.

One fact about programming is that file access is a lot lot slower than any memory operation. Yet in tours.js there's plenty file access in plenty of place.

The information should be kept in memory and only written when necessary, and especially you shouldn't need to use getFileContent so often.

memoryhash.js can be seen as an example of having an object in memory that can be read whenever and saved/load from file easily. (An improvement of memory hash.js would be saving the hash once a minute at most for example). Anyway it limits the need to use file access greatly.

I was planning to convert everything required for tours.js to JSON which would only need to use a few files (currently it uses at least 30 including score files for each individual tier). Also the script file is quite long, I might work on reducing it when I got more time (probably next week).

The problem isn't the number of files, it's the repeated reading/writing into files.

Moreover if you reduce to only a few files, I hope they don't become too big because then we would have another problem (writing big files or converting data to big json takes time). If you join everything into one file and you keep the same number of times you read / write whole files, you'll have a massive lag problem.

No really, all is described in the issue OP. ^^

this shouldn't be as much of an issue as of 16ecb3e (it only writes when necessary now)

This is great ! :)

Assuming this is mostly done