Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster sheep check #844

Closed
wants to merge 3 commits into from
Closed

Faster sheep check #844

wants to merge 3 commits into from

Conversation

xsebek
Copy link
Member

@xsebek xsebek commented Nov 7, 2022

This seeks to improve the performance of contained sheep checks.

The results were surprising, discuss below. 😕

@kostmo
Copy link
Member

kostmo commented Nov 7, 2022

FYI I just fixed a bug in my own solution and force-pushed my branch, so you may want to rebase. I'll stop force-pushing for now while we look at this PR.

@xsebek
Copy link
Member Author

xsebek commented Nov 7, 2022

@kostmo I am tired of this and it's broken (I was switching between alternatives), but I will write down my notes:

  • checking all sheep makes everything 3x slower and it is unavoidable (while they all live free)

  • following a path and checking for left, right and forward is slower than expected

    • opportunistic going forward if possible would likely speed this up
  • parsing the condition check once makes a huge difference, 2x to 3x speedup

  • checking if there are fences added from both sides results in no lag until the fence is finished

    • this would be best implemented using Location watch command #687
    • here I broke the solution, as I was tired, but I think it worked for me briefly
    • this is an automated version of "say when ready" assuming that the goal is to connect to the original gate

@kostmo I think we should measure the solutions and choose the most correct and fastest one.

Yours was pretty fast, but it only checked one sheep so it did not suffer from the 3x slowdown.

A properly optimized correct solution could run under 5s, but when it's around 10s it at least feels fast enough.

@xsebek xsebek requested a review from byorgey November 7, 2022 03:35
@xsebek xsebek marked this pull request as draft November 7, 2022 03:36
@kostmo
Copy link
Member

kostmo commented Nov 7, 2022

Awesome, thank you for the thorough investigation! I will incorporate these optimizations.

@kostmo kostmo force-pushed the ranching branch 2 times, most recently from 8eb2296 to 56b37a0 Compare November 12, 2022 09:13
@xsebek
Copy link
Member Author

xsebek commented Nov 12, 2022

Closing, as @kostmo implementation is now pretty optimised. 🙂

@xsebek xsebek closed this Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants