betcode-org / betfair

betfairlightweight - Betfair API-NG python wrapper (with streaming)
MIT License
419 stars 147 forks source link

history / version #536

Closed liampauling closed 9 months ago

liampauling commented 10 months ago

@petedmarsh I am currently testing this branch, in regards to the socket code I am actually seeing an increase in latency compared to v2.18.0. Both instances doing the same thing, on the same VM / libraries etc, has me a bit baffled...

petedmarsh commented 10 months ago

That's interesting, how are you measuring the latency?

On Wed, 13 Sept 2023, 16:12 Liam, @.***> wrote:

@petedmarsh https://github.com/petedmarsh I am currently testing this branch, in regards to the socket code I am actually seeing an increase in latency compared to v2.18.0. Both instances doing the same thing, on the same VM / libraries etc, has me a bit baffled...

— Reply to this email directly, view it on GitHub https://github.com/betcode-org/betfair/pull/536#issuecomment-1717715850, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJDC6WV6ENE75FJCK3HBPTX2G5MTANCNFSM6AAAAAA4O2HMWE . You are receiving this because you were mentioned.Message ID: @.***>

liampauling commented 10 months ago

MarketBook.publish_time_epoch vs my clock at point of order submission

petedmarsh commented 10 months ago

OK so it's also worse for me on Linux, I ran the benchmark and tested on Windows, please revert that change. I believe I can make it work on Windows and Linux.

petedmarsh commented 10 months ago

Linux benchmark numbers for me:

                                                    Benchmarks, repeat=5, number=5
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃                                       Benchmark ┃ Min     ┃ Max     ┃ Mean    ┃ Min (+)         ┃ Max (+)         ┃ Mean (+)        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ Original Client Code vs socket.makefile version │ 1.160   │ 1.357   │ 1.204   │ 1.808 (-1.6x)   │ 1.829 (-1.3x)   │ 1.819 (-1.5x)   │
└─────────────────────────────────────────────────┴─────────┴─────────┴─────────┴─────────────────┴─────────────────┴─────────────────┘
liampauling commented 10 months ago

I don't understand why though, surely it should be quicker, might try and have a look as the latency distribution is weird

petedmarsh commented 10 months ago

@liampauling I believe I know why this was faster on Windows, slower on Linux (and OSX), and I believe I have a simple fix that makes an improvement cross-platform.

I have tested this on Windows and OSX, I can check Linux later, could you run this benchmark:

https://gist.github.com/petedmarsh/0a2775ec706156b892d40a67cb017bef

If you can verify it's positive for you too then I will raise the fix with a full explanation.