Optimize memory usage for Http Adapter #1161

Merged
merged 1 commit into from Aug 23, 2016

Conversation

Projects
None yet
2 participants
@romainneutron
Contributor

romainneutron commented Aug 18, 2016

$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

This comment has been minimized.

Show comment
Hide comment
@ruflin

ruflin Aug 19, 2016

Owner

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).

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

This comment has been minimized.

Show comment
Hide comment
@romainneutron

romainneutron Aug 19, 2016

Contributor

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

Contributor

romainneutron commented Aug 19, 2016

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

This comment has been minimized.

Show comment
Hide comment
@ruflin

ruflin Aug 19, 2016

Owner

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

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

2 checks passed

codecov/project 85.21% (+0.00%) compared to 9ef242b
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ruflin

This comment has been minimized.

Show comment
Hide comment
@ruflin

ruflin Aug 23, 2016

Owner

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

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 romainneutron:optimize-memory branch Aug 23, 2016

@romainneutron

This comment has been minimized.

Show comment
Hide comment
@romainneutron

romainneutron Aug 23, 2016

Contributor

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

Contributor

romainneutron commented Aug 23, 2016

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

@ruflin

This comment has been minimized.

Show comment
Hide comment
@ruflin

ruflin Aug 23, 2016

Owner

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

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