Skip to content
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

High cpu usage on tab switch #26

Open
Gamesh opened this issue Oct 30, 2014 · 16 comments
Open

High cpu usage on tab switch #26

Gamesh opened this issue Oct 30, 2014 · 16 comments

Comments

@Gamesh
Copy link

Gamesh commented Oct 30, 2014

Firefox console displays warning:
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create

...{Yi=r}var Ii=[].proto?function(t,n){t.proto=n}:function(t,n){for(var e i...
in file d3.v3.min.js.

and indead when you click on a tab cpu spikes to 10-16%, just to switch a tab. on a Quad core i7 CPU.
I don't think that much cpu is needed just to hide and show a div, it should be snappy and fast.

@szepeviktor
Copy link

szepeviktor commented Oct 30, 2014

Yes, this is a problem.
It seems it is an abandoned project.

@szepeviktor
Copy link

JS and that piece of data could be restricted to that tab. E.g. loading it later by AJAX.
So looking at other tabs would be smooth.

@rlerdorf
Copy link
Owner

@cviebrock seems like something for you

@Gamesh
Copy link
Author

Gamesh commented Jan 21, 2015

@szepeviktor i don't think AJAX will solve anything. as the data is already loaded on the page and it loads very fast. The main problem here in my opinion is in javascript that switches the tab it is causing the slow down, not the data itself.

Maybe just stick with $.show() $.hide() and don't do any transitions:

if (!hidden[row]) {
d3.selectAll(row).transition().style('display', 'none');
hidden[row] = true;
d3.select(head).transition().style('color', '#ccc');
} else {
d3.selectAll(row).transition().style('display');
hidden[row] = false;
d3.select(head).transition().style('color', '#000');
}

and if you need odd/even row coloring do it with CSS3

@cviebrock
Copy link
Contributor

I'll take a look ... it's been a while. ;)

@Gamesh
Copy link
Author

Gamesh commented Jan 22, 2015

glad to know that project is up and running again at least :)

@cviebrock
Copy link
Contributor

Tried updating jQuery and d3js to more recent versions, and I still get that error warning. A quick google search turns up this: d3/d3#1805

So, I'd say this is an issue with d3js, perhaps only within Firefox. I don't see those JS warnings in Chrome's console, and the CPU doesn't seem to spike as much as it does in FF.

I did convert the hiding/showing of tabs to use Jquery instead of d3. Do you want to try my branch at https://github.com/cviebrock/opcache-status/tree/update-d3js and see if that helps?

@Gamesh
Copy link
Author

Gamesh commented Jan 23, 2015

tried it and it works great and fast. but d3 still produces an error when clicking through tabs:

TypeError: dataset[this.value] is undefined
http://cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.min.js
Line 1

TypeError: dataset[this.value] is undefined
http://myserverutils/opcache.php
Line 4125

maybe we should ditch d3 entirely? it looks somewhat unstable

@cviebrock
Copy link
Contributor

d3 has been around for quite some time and is used in lots of places, so I don't think it's necessarily unstable. And ditching it would mean no pretty circular graph or partition visualization.

That particular error comes from our code:

https://github.com/cviebrock/opcache-status/blob/update-d3js/opcache.php#L605

I'd have to sit down for a few hours and figure out what's actually going on here. I'm sure it could be cleaned up.

@Gamesh
Copy link
Author

Gamesh commented Jan 23, 2015

It's just seems that D3 does pretty much the same thing that jquery does, but also includes ability to draw these graphs. My thought was to use something more lightweight just for graphs and stick with jquery for everything else

@cviebrock
Copy link
Contributor

If you can find something that does this, that'd be great. The circular graphs I think would be easy to do in other JS charting libraries, but I'm not sure anyone else does the partitioning stuff.

@Gamesh
Copy link
Author

Gamesh commented Jan 23, 2015

For partitioning these look very similar, take a look
Google Treemaps
https://google-developers.appspot.com/chart/interactive/docs/gallery/treemap

ZingChart treemap:
http://www.zingchart.com/docs/chart-types/treemap/

Kendo UI treemap
http://demos.telerik.com/kendo-ui/treemap/index

@rlerdorf
Copy link
Owner

Neither Zing nor Kendo are viable since they are commercial.
There are tons of them out there though. See:
http://socialcompare.com/en/comparison/javascript-graphs-and-charts-libraries
You can ignore all the non-opensource ones.

@Gamesh
Copy link
Author

Gamesh commented Jan 25, 2015

what about just using google charts api?

@jamesrwhite
Copy link
Contributor

+1 for Google Charts, they are very nice to work. See: https://developers.google.com/chart/interactive/docs/gallery

@ningt
Copy link

ningt commented Jun 19, 2015

highcharts is also a good alternative. http://www.highcharts.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants