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

CSE Machine: canAvoidInstr is too slow #1698

Open
martin-henz opened this issue Apr 27, 2024 · 0 comments
Open

CSE Machine: canAvoidInstr is too slow #1698

martin-henz opened this issue Apr 27, 2024 · 0 comments
Labels
critical Fixing this is mission-critical Enhancement New feature or request

Comments

@martin-henz
Copy link
Member

The canAvoidInstr function is extremely inefficient and slows down the deployment each time by almost one hour!

@RichDom2185 and @sayomaki commented:

the code is not very efficient at all, it seems; we can just early return instead of iterating through the entire control every single step of the cse machine

I'm pretty sure this alone accounts for most of the 40minutes

same thing for the switch case logic, lots of unnecessary computation

@sayomaki :
consider using javascript's Array.some() or Array.every() instead

@RichDom2185 :
yes that also works, no need for a for loop, though I think the logic can be improved further

because the same computation is being repeated at every step

it should have been memoised

just create a new field in the control item and calculate it once only instead of calculating n times for each item where n is the number of control items

@martin-henz martin-henz added Enhancement New feature or request critical Fixing this is mission-critical labels Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical Fixing this is mission-critical Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant