Skip to content

[TASK] Avoid poor scaling of array_search() with very long arrays (#413) #628

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

Merged
merged 2 commits into from
Jun 29, 2024

Conversation

JakeQZ
Copy link
Collaborator

@JakeQZ JakeQZ commented Jun 28, 2024

When there are many many elements in $aStack, starting the delimiter search from the beginning for each loop is very very slow. I addressed this by building a new array rather than modifying $aStack in place and iterating over it in a single pass. The particular 1.6M style string that was giving me trouble went from taking 4 minutes to parse to 5 seconds.

bartbutler and others added 2 commits June 28, 2024 22:29
…413)

When there were many many elements in `$aStack`, starting the delimiter search from the beginning for each loop iteration was very slow.  This is addressed by building a new array, rather than modifying `$aStack` in place, and iterating over it in a single pass.  A particular 1.6M style string is now parsed in 5 seconds rather than 4 minutes.
@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Jun 28, 2024

This set of PRs (this, #627, #623, #624 - in chronological order of original changes) will need rebasing after each other is merged, due to conflict in CHANGELOG.md.

They are the current set of enhancements that can be backported for 8.6. I've created a v8.5.x branch from the current v8.x in case we need to apply any fixes to 8.5.

@oliverklee oliverklee merged commit 9b91918 into v8.x Jun 29, 2024
19 checks passed
@oliverklee oliverklee deleted the merge/413 branch June 29, 2024 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants