Fixed excessive CPU usage by stopping the indefinite growth of the graph dataset. Fixes #5794

This commit is contained in:
Aditya Toshniwal 2020-09-07 18:23:04 +05:30 committed by Akshay Joshi
parent f8f00b4ecf
commit 8c2e965f6e
2 changed files with 10 additions and 16 deletions

View File

@ -36,3 +36,4 @@ Bug fixes
| `Issue #5766 <https://redmine.postgresql.org/issues/5766>`_ - Fixed string indices must be integers issue for PostgreSQL < 9.3. | `Issue #5766 <https://redmine.postgresql.org/issues/5766>`_ - Fixed string indices must be integers issue for PostgreSQL < 9.3.
| `Issue #5773 <https://redmine.postgresql.org/issues/5773>`_ - Fixed an issue where the application ignores the fixed port configuration value. | `Issue #5773 <https://redmine.postgresql.org/issues/5773>`_ - Fixed an issue where the application ignores the fixed port configuration value.
| `Issue #5775 <https://redmine.postgresql.org/issues/5775>`_ - Ensure that 'setup-web.sh' should work in Debian 10. | `Issue #5775 <https://redmine.postgresql.org/issues/5775>`_ - Ensure that 'setup-web.sh' should work in Debian 10.
| `Issue #5794 <https://redmine.postgresql.org/issues/5794>`_ - Fixed excessive CPU usage by stopping the indefinite growth of the graph dataset.

View File

@ -67,7 +67,6 @@ export function getStatsUrl(sid=-1, did=-1, chart_names=[]) {
* data to get the new state. * data to get the new state.
*/ */
export function statsReducer(state, action) { export function statsReducer(state, action) {
let newState = {};
if(action.reset) { if(action.reset) {
return action.reset; return action.reset;
@ -82,21 +81,14 @@ export function statsReducer(state, action) {
} }
Object.keys(action.incoming).forEach(label => { Object.keys(action.incoming).forEach(label => {
if(state[label]) { let newEle = action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label];
state[label] = state[label] || [];
if(state[label].length >= X_AXIS_LENGTH) { if(state[label].length >= X_AXIS_LENGTH) {
state[label].unshift(); state[label].pop();
}
newState[label] = [
action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label],
...state[label],
];
} else {
newState[label] = [
action.counter ? action.incoming[label] - action.counterData[label] : action.incoming[label],
];
} }
state[label].unshift(newEle);
}); });
return newState; return state;
} }
const chartsDefault = { const chartsDefault = {
@ -263,6 +255,7 @@ export function GraphsWrapper(props) {
const toStatsLegendRef = useRef(); const toStatsLegendRef = useRef();
const bioStatsLegendRef = useRef(); const bioStatsLegendRef = useRef();
const options = useMemo(()=>({ const options = useMemo(()=>({
normalized: true,
legendCallback: legendCallback, legendCallback: legendCallback,
animation: { animation: {
duration: 0, duration: 0,