tfausak / rattletrap

:car: Parse and generate Rocket League replays.
https://hackage.haskell.org/package/rattletrap
MIT License
150 stars 21 forks source link

Stop reversing bytes, and stop using binary and binary-bits #227

Closed tfausak closed 3 years ago

tfausak commented 3 years ago

This will fix #188. It will also fix #189.

Currently I expect the build to fail. The replays generated with BitPut don't match what's parsed with BitGet. I suspect that discrepancy will go away once I migrate BitPut away from binary-bits and reverseBytes.

However it does mean that some values are changing. I think that's expected -- they were wrong in the first place. But I should diff the pretty replay JSON between main and this branch to see what exactly changed.

tfausak commented 3 years ago

Once I get the replays to round trip successfully, I should check on the performance of this approach. In theory I think it should be faster than binary-bits, but it may need some encouragement.

tfausak commented 3 years ago

check on the performance

main: 568.275 seconds gh188-byenary: 711.937 seconds

25% slower 😧 Not terribly surprising though, since I'm doing everything bit-by-bit going through Bool.

tfausak commented 3 years ago

2a3d882: 536.077 seconds

Change 1 character, get 25% better performance. 📈

tfausak commented 3 years ago

It may be possible, and perhaps even easy, to continue improving the performance. However these changes are already faster than the status quo so I'm going to merge them.

tfausak commented 3 years ago

I should diff the pretty replay JSON between main and this branch to see what exactly changed.

Oops, forgot to do this.

Using 0fce582eaa1e480a81e390338e28307b3b4ad49c as the "before" commit and fc8e30ab497246853f708b3a58c8c70ed5a10231 as the "after" commit.

Before: 461.983 seconds After: 410.973 seconds (~11% faster)

As expected, the game mode attribute changed:

--- output-old/1ef9-pretty.json 2021-03-12 07:52:03.341221426 -0500
+++ output-new/1ef9-pretty.json 2021-03-12 07:56:33.987964459 -0500
@@ -2848,9 +2848,9 @@
                     "name": "TAGame.GameEvent_TA:GameMode",
                     "value": {
                       "game_mode": {
                         "num_bits": 8,
-                        "word": 128
+                        "word": 1
                       }

Also PlayStation IDs:

--- output-old/2cfe-pretty.json 2021-03-12 07:52:06.333227787 -0500
+++ output-new/2cfe-pretty.json 2021-03-12 07:56:36.935978697 -0500
@@ -354264,68 +354264,68 @@
                     "name": "ProjectX.GRI_X:Reservations",
                     "value": {
                       "reservation": {
                         "name": "messidragon1",
                         "number": {
                           "limit": 7,
                           "value": 5
                         },
                         "unique_id": {
                           "local_id": 0,
                           "remote_id": {
                             "play_station": [
                               "messidragon1",
                               [
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
                                 0,
-                                166,
-                                150,
-                                120,
-                                15,
-                                14,
-                                53,
-                                46,
-                                78
+                                101,
+                                105,
+                                30,
+                                240,
+                                112,
+                                172,
+                                116,
+                                114
                               ]

The new values should actually be accurate, but I'm not sure how to prove that. I don't have any known PlayStation IDs that I can test against. It does seem likely that 1 is a more expected game mode than 128 though.