PHP locks the session file until it is closed. If you have 2 scripts using the same session (i.e. from the same user) then the 2nd script will not finish its call to session_start() until the first script finishes execution.
If you have scripts that run for more than a second and users may be making more than 1 request at a time then it is worth calling session_write_close() as soon as you've finished writing session data.
So part of the reason the demographics page takes a long time to complete is that each AJAX get called synchronously.
I've done some initial coding and you can see the difference. (My vitals load in less than half a second where as before it was waiting until after the 2 seconds the clinical rules needed to complete).
I'm not sure of other unintended consequences this might have though. I've scanned the files where I added session_write_close() to make sure that no attempts to change session variables are made after that point, but I could certainly have missed it.
Like I said, this issue applied to page loads in addition to AJAX, so when you load a new patient with the frames model, the encounters.php in the bottom frame has to wait for the demographics page to finish in the top frame.
Hi,
Just bumping this thread since would be nice to get this incorporated into the 4.1.1 release. (Guessing will help to run the large multi-patient CDR based reports (after ajaxified) concurrently with normal use also)
-brady OpenEMR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(Guessing will help to run the large multi-patient CDR based reports (after ajaxified) concurrently with normal use also)
No, it won't. The mechanism to processes patient reminders would need to wait for each individual batch to complete anyway since each batch uses session variables to keep track of the overall state.
The primary place where it helps is when multiple things are loading in separate frames, or multiple operations (like on the demographics page) are taking place simultaneously.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Only one AJAX call (or page load) can execute at a time when the script calls session_start
http://php.net/manual/en/function.session-start.php
If you have scripts that run for more than a second and users may be making more than 1 request at a time then it is worth calling session_write_close() as soon as you've finished writing session data.
So part of the reason the demographics page takes a long time to complete is that each AJAX get called synchronously.
I've done some initial coding and you can see the difference. (My vitals load in less than half a second where as before it was waiting until after the 2 seconds the clinical rules needed to complete).
https://github.com/yehster/openemr/tree/ajax-sessions-experiment
I'm not sure of other unintended consequences this might have though. I've scanned the files where I added session_write_close() to make sure that no attempts to change session variables are made after that point, but I could certainly have missed it.
Like I said, this issue applied to page loads in addition to AJAX, so when you load a new patient with the frames model, the encounters.php in the bottom frame has to wait for the demographics page to finish in the top frame.
Here is another useful explaination.
http://konrness.com/php5/how-to-prevent-blocking-php-requests/
Hi,
This is very cool. As discussed on github, will be important to document this on the wiki for developers.
-brady
OpenEMR Project
Hi,
Just bumping this thread since would be nice to get this incorporated into the 4.1.1 release. (Guessing will help to run the large multi-patient CDR based reports (after ajaxified) concurrently with normal use also)
-brady
OpenEMR
No, it won't. The mechanism to processes patient reminders would need to wait for each individual batch to complete anyway since each batch uses session variables to keep track of the overall state.
The primary place where it helps is when multiple things are loading in separate frames, or multiple operations (like on the demographics page) are taking place simultaneously.
Hi,
I see what you mean. Still would be nice to get this included in 4.1.1 release to optimize the patient summary screen.
-brady
OpenEMR Project