public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin][RM5794] Excessive CPU usage while browser is idle
3+ messages / 2 participants
[nested] [flat]

* [pgAdmin][RM5794] Excessive CPU usage while browser is idle
@ 2020-09-07 10:29 Aditya Toshniwal <[email protected]>
  2020-09-07 13:18 ` Re: [pgAdmin][RM5794] Excessive CPU usage while browser is idle Akshay Joshi <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Aditya Toshniwal @ 2020-09-07 10:29 UTC (permalink / raw)
  To: pgadmin-hackers

Hi Hackers,

Attached is the patch to stop the indefinite growth of graph dataset. This
has caused excessive CPU usage and the patch will reduce it.

Please review.

-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"


Attachments:

  [application/octet-stream] RM5794.patch (1.6K, 3-RM5794.patch)
  download | inline diff:
diff --git a/web/pgadmin/dashboard/static/js/Graphs.jsx b/web/pgadmin/dashboard/static/js/Graphs.jsx
index ac1c1605f..43333fe71 100644
--- a/web/pgadmin/dashboard/static/js/Graphs.jsx
+++ b/web/pgadmin/dashboard/static/js/Graphs.jsx
@@ -82,21 +82,14 @@ export function statsReducer(state, action) {
   }
 
   Object.keys(action.incoming).forEach(label => {
-    if(state[label]) {
-      if(state[label].length >= X_AXIS_LENGTH) {
-        state[label].unshift();
-      }
-      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],
-      ];
+    let newEle = action.counter ?  action.incoming[label] - action.counterData[label] : action.incoming[label];
+    state[label] = state[label] || [];
+    if(state[label].length >= X_AXIS_LENGTH) {
+      state[label].pop();
     }
+    state[label].unshift(newEle);
   });
-  return newState;
+  return state;
 }
 
 const chartsDefault = {
@@ -263,6 +256,7 @@ export function GraphsWrapper(props) {
   const toStatsLegendRef = useRef();
   const bioStatsLegendRef = useRef();
   const options = useMemo(()=>({
+    normalized: true,
     legendCallback: legendCallback,
     animation: {
       duration: 0,
@@ -385,4 +379,4 @@ GraphsWrapper.propTypes = {
   showTooltip: PropTypes.bool.isRequired,
   showDataPoints: PropTypes.bool.isRequired,
   isDatabase: PropTypes.bool.isRequired,
-};
\ No newline at end of file
+};


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [pgAdmin][RM5794] Excessive CPU usage while browser is idle
  2020-09-07 10:29 [pgAdmin][RM5794] Excessive CPU usage while browser is idle Aditya Toshniwal <[email protected]>
@ 2020-09-07 13:18 ` Akshay Joshi <[email protected]>
  2020-09-09 06:09   ` Re: [pgAdmin][RM5794] Excessive CPU usage while browser is idle Aditya Toshniwal <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Akshay Joshi @ 2020-09-07 13:18 UTC (permalink / raw)
  To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Mon, Sep 7, 2020 at 3:59 PM Aditya Toshniwal <
[email protected]> wrote:

> Hi Hackers,
>
> Attached is the patch to stop the indefinite growth of graph dataset. This
> has caused excessive CPU usage and the patch will reduce it.
>
> Please review.
>
> --
> Thanks,
> Aditya Toshniwal
> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
> <http://edbpostgres.com;
> "Don't Complain about Heat, Plant a TREE"
>


-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [pgAdmin][RM5794] Excessive CPU usage while browser is idle
  2020-09-07 10:29 [pgAdmin][RM5794] Excessive CPU usage while browser is idle Aditya Toshniwal <[email protected]>
  2020-09-07 13:18 ` Re: [pgAdmin][RM5794] Excessive CPU usage while browser is idle Akshay Joshi <[email protected]>
@ 2020-09-09 06:09   ` Aditya Toshniwal <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Aditya Toshniwal @ 2020-09-09 06:09 UTC (permalink / raw)
  To: Akshay Joshi <[email protected]>; +Cc: pgadmin-hackers

Hi,

In the previous patch, I had changed the react state directly, which is not
recommended and can cause unpredictable behavior.
Attached patch changes the previous commit to avoid changing state directly.

Please review.

On Mon, Sep 7, 2020 at 6:48 PM Akshay Joshi <[email protected]>
wrote:

> Thanks, patch applied.
>
> On Mon, Sep 7, 2020 at 3:59 PM Aditya Toshniwal <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> Attached is the patch to stop the indefinite growth of graph dataset.
>> This has caused excessive CPU usage and the patch will reduce it.
>>
>> Please review.
>>
>> --
>> Thanks,
>> Aditya Toshniwal
>> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
>> <http://edbpostgres.com;
>> "Don't Complain about Heat, Plant a TREE"
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Sr. Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>


-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"


Attachments:

  [application/octet-stream] RM5794.part2.patch (1.1K, 3-RM5794.part2.patch)
  download | inline diff:
diff --git a/web/pgadmin/dashboard/static/js/Graphs.jsx b/web/pgadmin/dashboard/static/js/Graphs.jsx
index e8862a109..ad2b3cf92 100644
--- a/web/pgadmin/dashboard/static/js/Graphs.jsx
+++ b/web/pgadmin/dashboard/static/js/Graphs.jsx
@@ -80,15 +80,20 @@ export function statsReducer(state, action) {
     action.counterData = action.incoming;
   }
 
+  let newState = {};
   Object.keys(action.incoming).forEach(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) {
-      state[label].pop();
+    if(state[label]) {
+      newState[label] = [
+        action.counter ?  action.incoming[label] - action.counterData[label] : action.incoming[label],
+        ...state[label].slice(0, X_AXIS_LENGTH-1),
+      ];
+    } else {
+      newState[label] = [
+        action.counter ?  action.incoming[label] - action.counterData[label] : action.incoming[label],
+      ];
     }
-    state[label].unshift(newEle);
   });
-  return state;
+  return newState;
 }
 
 const chartsDefault = {


^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2020-09-09 06:09 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 10:29 [pgAdmin][RM5794] Excessive CPU usage while browser is idle Aditya Toshniwal <[email protected]>
2020-09-07 13:18 ` Akshay Joshi <[email protected]>
2020-09-09 06:09   ` Aditya Toshniwal <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox