-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
Improved loop for getAllQueries #2114
Conversation
Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
Does this output in chunks instead of one big output suggest adding |
The problem here is not exactly how the page outputs the result. The problem is how much memory the page needs during the process. The old code holds ALL data in memory during the entire The new code outputs one record at a time. |
Yes, hence my question because this is now chunked. |
For PHP this won't change anything. As far as I know, Lighttpd automatically uses |
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/pi-hole-ftl-v5-14-web-v5-11-and-core-v5-9-released/53529/1 |
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/all-queries-are-not-working/54711/7 |
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/dreaded-php-memory-error-persists/55790/2 |
By submitting this pull request, I confirm the following:
git rebase
)git commit --signoff
)What does this PR aim to accomplish?:
This PR reduces the memory needed by
api_db.php?getAllQueries
to process every requested record.How does this PR accomplish the above?:
The current code used to generate and return the request adds all records into a single array. This array grows for each record (and there are many many records).
Only at the end (and if memory holds up), it transforms the entire array into JSON and sends all at once as a string.
The new code outputs each record as a string immediately.
This way, there is no array and the memory for each iteration is always the same.
The web server is responsible for sending the "text stream", nothing else needs to change.
What documentation changes (if any) are needed to support this PR?:
None.