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

Optimize memory usage for Http Adapter #1161

Merged
merged 1 commit into from
Aug 23, 2016

Conversation

romainneutron
Copy link
Contributor

$content = str_replace('\/', '/', $content); consumes a lot of memory, especially with large payloads.

In my import loop, it was consuming 40MB per bulk.

This improves memory consumption

@ruflin
Copy link
Owner

ruflin commented Aug 19, 2016

Thanks for the PR to make the code faster. Can you please update the CHANGELOG.md file? Adding a test to confirm the optimization of this can is quite tricky, but it looks very reasonable :-)

One question that this raised on my side is, why do we have JSON_ELASTICSEARCH at all? I looks like we could replace it everywhere with JSON_UNESCAPED_UNICODE https://github.com/ruflin/Elastica/blob/master/lib/Elastica/JSON.php#L59 My assumption is we needed it for some historical reasons (PHP version compatibility).

@romainneutron
Copy link
Contributor Author

Would you like a test to cover the optimization or the slashes unescaping?
If you would like an optimization demonstration, I'd be glad to share a Blackfire profile

@ruflin
Copy link
Owner

ruflin commented Aug 19, 2016

The changed code is already covered by quite a few other integration tests I assume as it is such a central part. So I worry not too much that it breaks the code. No need to share the Backfire profile, the changes make a lot of sense. I fully trust you here :-)

In case you have an easy test to add feel free to add it, but not required. Only additional thing required is the update to the CHANGELOG.md

@ruflin ruflin merged commit 045ee26 into ruflin:master Aug 23, 2016
@ruflin
Copy link
Owner

ruflin commented Aug 23, 2016

@romainneutron I merged this change as I plan to do a release. I will add the changelog entry.

@romainneutron romainneutron deleted the optimize-memory branch August 23, 2016 11:36
@romainneutron
Copy link
Contributor Author

Thanks a lot, sorry for being a bit slow on this one

@ruflin
Copy link
Owner

ruflin commented Aug 23, 2016

@romainneutron No worries. Thanks a lot for the contribution.

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