-
Notifications
You must be signed in to change notification settings - Fork 394
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
Tzachi shared node phase2 #1370
Tzachi shared node phase2 #1370
Conversation
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Signed-off-by: Tzachi Dar <tzachi.dar@gmail.com>
Just getting back to this. Has anyone tested this on a rig yet? If so, on a Pi, Edison, or both? |
So I take it this is still untested on any production rigs? |
Correct, it is tested on a rig, getting production data and controlling a pump, but another pump is actually closing the rig. |
How is review going? Will it help if I split this into smaller prs? |
I think the next step is to install it on a rig controlling a live pump and make sure it still works correctly. I had done such testing against #1359, but it sounds like you abandoned that, so I'm unclear whether any of this code has been tested or not. I haven't gotten back to it since you closed #1359: have you had any chance to do any live testing since then? |
#1359 was merged into dev as part of #1361. This PR moves 4 operations (for example oref0-meal) to the shared node. Since these operations can be categorized as programs that read input files and write output files I think that the best way to move on is to create a very small pr that only copies this files. Once we have enough test data, we can run the old code and the new code and make sure that they are exactly the same. Does this sound reasonable? |
Ah, ok, thx. Yes, that is a good test plan, and more thorough than my "just try it on a rig and make sure it still works" method. If you don't have cycles to get the former done, I'll probably be able to do the latter at some point after I finish my taxes. ;-) |
OK, so I'll prepare the scripts needed to collect the data until the end of the week, so we can start collecting. |
Not sure what the next step with this branch is. #1411 addresses the root cause of the performance problems with node, which were a big part of the motivation for this branch. But while the interpreter startup performance with a fixed nodejs interpreter is better, it's still not great, and wouldn't be able to handle calling nodejs scripts in a loop. And there are some medium-to-long-term architectural advantages to having a persistent nodejs process, in the ability to preserve state between loops without using hacky JSON files in ~/myopenaps. |
@jimrandomh OpenAPS architecture is (AFAIK) intentionally based on the functional programming paradigm and thus the logic is designed to be inherently stateless. When discussing this branch / architecture changes originally, I recall the only state that was discussed was retaining in-memory copies of the deserialised files and only reloading files from disk if needed. Having said that, the logic in OpenAPS hasn't been implemented functionally and does direct changes to the data as well as uses globals, so having more logic live in the process would require careful refactoring of the code. OTOH this would probably speed up running the loop to a fraction of the time currently needed and personally I think not relying on the rig running a particular version of the shell would in my opinion be an architectural win. |
@sulkaharo |
@tzachi-dar Ah - I was referring to Jim's notion of expanding more (all?) of OpenAPS run in the persistent process. Related: there's a new Pi Zero 2 out now that apparently has 5x better CPU performance. This comes at a cost of higher battery draw under load, so I'm assuming if people change over to the new Pi in their rigs, the point of these optimisations would be to have the CPU spend less cycles to draw less current, not to enable the loop to run in the first place. |
Extraneous logging when calculating meal.json: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After commenting out extra echo lines, this runs successfully on a rig with all and only the expected output.
@tzachi-dar is this ready to merge to dev from your perspective? Is it still useful after the changes in #1411? |
This PR is ready to be merged from my prespective. |
I'm now running this on all of our rigs, and have not seen any issues so far. If they continue to look good and I don't hear any objections, I'll probably merge it to dev tomorrow. |
I haven't seen any issues related to this branch on any of our rigs. They are all Edisons, and seem to be marginally faster, although it's hard to tell for sure, as they were pretty quick already. |
After merging this, every rig updated to the latest dev will need to have oref0-setup re-run (normally via ~/myopenaps/oref0-runagain.sh) to get the new shared-node setup installed properly so the rig can resume looping. |
Are you sure a setup is needed? |
I don't know the precise conditions under which oref0-setup is required, but I know that I upgraded a few rigs that were on much older versions of dev, and they stopped looping until I re-ran oref0-runagain. I think it's fine to require people to do that manually: we shouldn't expect to be able to just git pull without reinstalling unless the changes are very minor. |
OK, makes sense. |
This reverts commit 912ab07.
This reverts commit 912ab07.
This reverts commit 912ab07. Reverting this commit to allow oref0 algorithm to run in iAPS. Conflicting changes in lib/profile/carbs.js were kept: orenaps/oref0: if (carbRatio < 0.1 || carbRatio > 250) { oref2: if (carbRatio < 3 || carbRatio > 150) {
Revert "Tzachi shared node phase2 (openaps#1370)"
This PR adds 4 more modules to the shared node:
oref0-calculate-iob
oref0-meal
oref0-get-profile
oref0-get-ns-entries
Technically this changes are not complicated, but looking at the PR it seems to touch a lot of files (many of them only have one line changed).
The main reason for the many changes are this:
All files that are touched by this pr (or called from files running by this PR) are moved to strict mode.
Usually, this only means to add strict to the beginning of the file. Sometimes this meant that variables have to be declared in functions. In a few places variables were shared across files, so I had to make sure they are passed as parameters.
There are some functions that have functionality that needs to be moved to the calling function.
This includes the following:
console.log(), console.error() and process.exit()
This 3 functions have been replaced by console_log(), console_error() and process_exit().
The new functions only receive one extra parameter (final_result), that will hold the data to be returned to the calling function.
There are more printings in the code that I did not move to the new paradigm in order not to make this PR even longer.
Obviously, this PR needs a through code review and more testing.