Closed rohanpurohit closed 3 years ago
Perfomance testing on RPI (running the application backend)
Alert Button:
timer
at the end of the button, I used justifyContent: 'flex-end'
for the button CSS, mostly looked fine on chrome on my local pc (1280x800 resolution) except for labels like Low Battery
since the text is too short, spacing is not symmetrical (more space on the left side) because of the flex-end
attribute. maybe there is a better way to do this?Should we consider the visual aspects of the UI on RPI (I'm using vnc client with a different resolution maybe that's a factor too?) or simply the resolution of 1280x800
on chrome should be enough?
Correctness regression related to #411 (in the future, PRs like this consisting of very small entirely separate fixes should be split into smaller hotfix PRs so that we don't have to wait for all of them to be fully ready before merging any one of them, and so that we can have more descriptive branch names):
if (backendConnected) { return; }
.useEffect
is now depending on backendConnected
, which is also modified by the BACKEND_CONNECTION_DOWN
and BACKEND_CONNECTION_UP
actions, we should be careful to guard against any circular dependencies which might be coincidentally masked by the code right now - at a minimum, there should be an inline code comment explaining the ways in which a circular dependency may be introduced if someone isn't careful in the future. I would also suggest still checking the potential impact of the changes I suggested in https://github.com/pez-globo/pufferfish-software/issues/411#issuecomment-876695814 (you submitted this PR before I made that comment).Frontend layout:
flex-end
is not the best tool for this. The approach I initially had in mind was to manually change the width of the span which contains the {alert.label}
to one of two constant values, depending on isMuted
; and then we should set a fixed width for the alertTimer
div. If you tried this, what ended up happening?CPU performance measurement:
- Since the
useEffect
is now depending onbackendConnected
, which is also modified by theBACKEND_CONNECTION_DOWN
andBACKEND_CONNECTION_UP
actions, we should be careful to guard against any circular dependencies which might be coincidentally masked by the code right now - at a minimum, there should be an inline code comment explaining the ways in which a circular dependency may be introduced if someone isn't careful in the future. I would also suggest still checking the potential impact of the changes I suggested in Redux is spammed withBACKEND_CONNECTION_UP
actions #411 (comment) (you submitted this PR before I made that comment).
Yes, I'm really concerned about using this, is there a way we could only dispatch the action once without relying on backendConnected
?
Latest changes:
useEffect:
connection loss
actions:
clock
alert button:
Perfomance testing on RPI (running application backend)
In light testing, the visual changes look good to me! I think they're ready to merge. I haven't tested anything related to the useEffect, since you plan to make more changes.
Yes, I'm really concerned about using this, is there a way we could only dispatch the action once without relying on
backendConnected
?
I can't think of any way to do this. Maybe the best we can do is to figure out a formal/informal proof/argument about the dependency relationships around backendConnected
. As a start, we know that the useEffect
will run any time backendConnected
changes. If we can establish a logical relationship between the latest state of backendConnected
, the occurrence of changes to its state, and the occurrence of BACKEND_CONNECTION_UP
and BACKEND_CONNECTION_DOWN
action dispatches, that would be a formal specification we can look at to see whether our design could cause a circular dependency under certain edge cases. Since this logic is mostly about conditionals, maybe you could try to put together a decision table specifying the logical relationship between the input dependencies of the useEffect and the resulting action dispatches?
As a start, we know that the
useEffect
will run any timebackendConnected
changes.
It is clearly a circular dependency as the useEffect
itself is dispatching the actions that change backendConnected
!
If we can establish a logical relationship between the latest state of
backendConnected
, the occurrence of changes to its state, and the occurrence ofBACKEND_CONNECTION_UP
andBACKEND_CONNECTION_DOWN
action dispatches, that would be a formal specification we can look at to see whether our design could cause a circular dependency under certain edge cases. Since this logic is mostly about conditionals, maybe you could try to put together a decision table specifying the logical relationship between the input dependencies of the useEffect and the resulting action dispatches?
Hmm seems complicated to come up with a table, I'll do my best!
I haven't tested anything related to the useEffect, since you plan to make more changes.
what are your thoughts about the current implementation? since we don't really want to keep getClock
I'm thinking either we could defer it for later or come up with something that's acceptable as prototype level code
It is clearly a circular dependency as the
useEffect
itself is dispatching the actions that changebackendConnected
!
Right, at the level of syntax there has to be a circular dependency because the useEffect under certain circumstances will dispatch actions which change backendConnected
. We just have to make sure that our conditionals will break any potential positive feedback loops where dispatching an action causes the useEffect to be run more than once as a result. Negative feedback loops are fine - i.e. the circular dependency is used to suppress the dispatching of actions in a dispatch action -> re-run useEffect -> dispatch action -> re-run useEffect -> ... loop. My intuition is that once we write out the decision table we'll be able to prove that we don't have any positive feedback loops.
what are your thoughts about the current implementation? since we don't really want to keep
getClock
I'm thinking either we could defer it for later or come up with something that's acceptable as prototype level code
It looks good to me - if you're happy with it, I'll try running it on my RPi tomorrow morning (go ahead and add your responses to the 3 questions for records-keeping and that way I can approve immediately if everything looks good to me in testing). You could probably refactor:
} else {
if (backendConnected) return;
as:
} else if (!backendConnected) {
It is clearly a circular dependency as the
useEffect
itself is dispatching the actions that changebackendConnected
!Right, at the level of syntax there has to be a circular dependency because the useEffect under certain circumstances will dispatch actions which change
backendConnected
. We just have to make sure that our conditionals will break any potential positive feedback loops where dispatching an action causes the useEffect to be run more than once as a result. Negative feedback loops are fine - i.e. the circular dependency is used to suppress the dispatching of actions in a dispatch action -> re-run useEffect -> dispatch action -> re-run useEffect -> ... loop. My intuition is that once we write out the decision table we'll be able to prove that we don't have any positive feedback loops.
Oh okay great! so is the PR blocked by decision table or we can write it out later?
what are your thoughts about the current implementation? since we don't really want to keep
getClock
I'm thinking either we could defer it for later or come up with something that's acceptable as prototype level codeIt looks good to me - if you're happy with it, I'll try running it on my RPi tomorrow morning. You could probably refactor:
so there is a clear performance hit when we are using getClock
!
performance on https://github.com/pez-globo/pufferfish-software/pull/412/commits/224fcc13a326a8aaa7010c8e15d3ff2558b0e683:
performance on https://github.com/pez-globo/pufferfish-software/pull/412/commits/9c38c6aaf2da827b9fa093166170a4fd31c5564f:
for records-keeping.
This PR fixes #387 and #411