I wrote a electron app for a device from aliexpress (simple spectrum analyzer), and I feed the data to the app through some dlls etc. That is not that important, but just so you know what it is.
Important is, that it goes to the app as JSON and the app renders it using lightning chart.js.
My questions is, how much CPU should real-time app like this take? Mine sits around 19% on Ryzen5 2600, which to me seems like a lot and most of the CPU is taken by the event handler in the renderer process alone, even if I remove the rendering part on the chart component and just transfer the data to the renderer from my forked process through the main process the usage is high. I am new to javascript so I tried doing 30s performance snapshot from devtools and I am not sure if it helped me or not. Summary of performance recording
Is there a better solution to transfer large data from forked process to the renderer without compromising on security by turning nodeIntegration on? The data are a Buffer of 65k bytes which I then convert to the JSON in the forked process and pass through all the IPC to the renderer. I need the forked process so the app is not blocked if there is connection issue between the device and the app.
Related
I'd like to learn to analyze my meteor and node services' performance and memory usage better than just trying to log various thing to console. I've read couple articles about memory management in Node and some baby steps about analyzing the memory dumps with Chrome developer tools.
The question is, how do I get those memory dumps from my apps in the first place?
This memory and performance analysis is done on the server side service. As far as I know, the memory dumps got from Chrome browser are client side memory dumps.
It seems that this node package
https://github.com/bnoordhuis/node-heapdump
can be used to collect heapdumps on server side. Still need to figure out how to properly use it and then time to analyze those dumps.
At the moment I am just writing a single heapdump every time I start my app, but maybe more sophisticated writing method is needed to actually get something done.
I'm running electron on linux server for web scraping. And currently I'm running new electron command for each task. But it results in high cpu usage. Now thinking about running single electron instance, and create new BrowserWindow for each task. It will take some time to adapt the code base for this style, so I wanted to ask here first. Will it make a difference in cpu usage, and how much?
Basically, creating a new NodeJS process will result in re-parsing your application's code, which will highly affect your CPU usage. Creating only a new BrowserWindow will only create a new renderer process, which is way more efficient.
If your application is packaged, e.g. with electron-packager, then creating a new instance will also affect your CPU usage like creating another NodeJS process, because that packaged (aka compiled) application has a copy of NodeJS in it, which is enough to run your code, but still affects the CPU usage.
But the decision depends on how you use the server. If you only run the Electron application to carry out the tasks that have been defined by you, adapting your working code would have no to only a low benefit. If you want to release this application and/or that server is used by some other tasks, e.g. a web server, it would be a real benefit if you adapt your code.
Running multiple instances of the main nodejs process with the default configuration is not actually supported or tested. You'll find that any features that persists data to disk either don't work, or don't work as expected (ie. localstorage, indexeddb, sessions, etc).
https://github.com/electron/electron/issues/2493
You can work around this by changing the data directory for each instance so they don't trample over each other but this is likely to use a lot of disk space and you'd need a way to keep track of all these data directories.
A single main process with multiple renderers is nearly always the answer.
My employer is in a crossroads now:
We've got an offer to create app for a large multinational company, interested in monitoring of a large fleet of vehicles simultaneously on a map. I'm talking about 5000 at the time. We tried to do that in our current web based app and it chokes due to quanity of objects, despite our efforts to optimize code. My question is: can we gain some performance boost if we convert our web based app into a desktop one via nodejs`s modules like node-webkit or atom-shell. Does a desktop app has a better access to a system resources? Web page is frozen beyond help and even gives me a message to mercy kill it, because processing is taken too long, but in a task manager it only uses about 18% of CPU and 2 GB of ram out of 16 GB.
No that wont help. Your code still runs in a webkit browser.
The trick is to not show all 5000 objects at a time.
Showing 5000 pins on a map is not useful to the user anyways, group markers that are close together (https://developers.google.com/maps/articles/toomanymarkers?hl=en);
as the user zooms in you can then show a more and more detailed view.
I've written an app which is handling videos. As we know, video processing takes a huge amount of memory while dealing with HD resolution. My App always seemed to crash. But actually I am 100% sure, that there is no memory leak in my code. Instruments is showing no leak.
At the beginning I am startin up one OpenGLES view and the video engine. For a very short time the memory consumption is high, but falling down to normal level after the initializations are done. I am always getting memory warnings during this period. Normally this is no problem. But if I have a lot of apps in suspended mode running, the App seems to be crashing. Watching into the crash log and using the debugger shows up, that I am only running out of memory.
My customers are flooding my support mail with "app is crashing" mails. But I do know, that they have too much Apps running in the background, so there is no memory left to go. I think it's bad style programing saying the customer that he has to close Background tasks before running the app.
According to this post this is a common problem.
My question is: Is it possible to tell the OS that one needs a lot of memory so the OS should terminate some suspended Apps? This memory stuff makes me crazy, because it's no bug I could fix.
No. It is not possible to affect anything outside of your sandbox without API calls. None exist for affecting other processes in the public API.
Have you tried to minimize your memory usage? In my experience once a memory warning it thrown apps can be more likely to have problems once they are in the background, even when memory usages drops.
If you are using OpenGLES and textures, if you haven't already compress your textures. What is the specific cause of your memory allocation spike?
I have a web application that hangs under high loads. I'm not going to go into the specifics of the code because I really just want some troubleshooting advice and tooling recommendations.
It's a web app, so each request get's a thread. Under a high load test, the app begins to consume all of the cpu, while becoming unresponsive. I suspect that the request threads are hanging in the new code that we are testing. Due to the fact of the cpu consumption, I'm assuming this must be on my app side. My understanding, which could be wrong, is that total cpu consumption indicated my first troubleshooting efforts should be in looking at the code that's consuming those cycles.
What are some tools and/or methods for inspecting which threads are hanging and on what lines of code? Again, I can easily force the app into the problematic behavior.
I've found and been trying out visualvm. Seems like the perfect tool. Still open for suggestions though. I looked at eclipse TPTP and it seems to be end-of-life-ing as well as requiring a more heavy weight deployment.
You can insert logging messages at starting a thread and closing a thread. Then you start the application and inspect the output while penetrating the code.
Another way is to look for memory leaks. If you are sure you haven't one, you can extend the virtual memory of your JVM.
#chad: do you have Database in whole picture...you may want to start by looking what is happening at DB side...you can very well look into DB locks, current sessions etc.