Why do Electron applications boot faster the second time?

Asked

Viewed 67 times

0

I’m working with the Electron right now and I noticed something very interesting. Always the first time I open my application with Electron, it takes a long time to boot the window. But the next few times it won’t take even 1 second to load. What’s happening?

  • 2

    I will try to formulate the answer as soon as I find some detail in the bugreport, but the problem of Electron, as well as Chrome and Opera, is because this is a "flaw" of Chromium, always had this problem, to start it is slow, but when it starts the first time it leaves something semi ready (which I do not remember if it is a cache or mapping) that causes the next times it starts fast, however if you log out or restart the PC then it happens again.

  • @Guilhermenascimento ok I’m waiting.

1 answer

-2

I’ll assume you’re using windows. The computer on the dial, it’s like a newly qualified driver trying to make a trip he doesn’t know about. This driver MAKES the trip, but has its difficulties: Make the trip slower, maybe 50 or 60kmh, look at all the signs, to avoid getting lost, Pay attention to everything everywhere, but does not decorate anything. Finally, he completes his IDA trip. On the way back, he returns faster, he already knows the road. He has more confidence no longer walks to 50kmh . Besides, he already knows a little bit about the road. Suppose that with the passing of the days he is making many trips to this destination as if he were an alternative transport driver. At a certain point in his work, the driver driving to 50kmh in fear of getting lost, will be driving to 140kmh, practically with eyes closed. He’s not afraid of a hole, he’s not afraid of animals, he knows where the speed bumps are, he knows everything that can happen during the journey. traces that remain in his memory generated a kind of mental map. and he is no longer afraid. because it became routine. now that fate is a sport for him.

In Windows we have the file Pagefile.sys ( windows paging file ). Every time you open a program the first time, you scan the slots on your hard drive, let’s say SLOWLY because your files are fragmented (broken/divided) into hundreds of geographic sectors on the hard drive. This causes what we call SYSTEM SLOWDOWN. In fact, it is looking for the pieces of files that may be distant from each other. he copies some traces(memories) of the location of these pieces of files. the second time he opens, he already knows where they are. However, if you open this program many times... it will defragment this file ( paste the parts, merge , put next ) and do a kind of compression and put inside the file PAGEFILE.SYS usually located in the unit " C: PAGEFILE.SYS " If you increase the usage frequency a lot. it ends up gathering all the files. VERY CLOSE TO EACH OTHER. ie in this file pagefile.sys and every time you open the program, it opens the pagefile.sys file and there you find your program. it no longer sacrifices itself to open.

The pagefile works as if it were an extra ram memory. you can increase or decrease. Do the tests yourself: It’s a long step. Go on the icon "Computer" and click with right mouse side

Click on Estates ( a screen with the title will appear SYSTEM PROPERTIES )

In the item Performance click on Button Settings

in the window that opens ( Performance options ) click on the tab ADVANCED

in the item Virtual memory, click on ALTER

in the window that opens, ( virtual memory ) mark the <radio> tamanho personalizado

To avoid fragmented file, in inputs "Initial size (MB) and Maximum size MB " put twice your RAM memory into Megabits. for example: If Voce has 2gb of ram ( put 4,000 ). if it has 4gb ( 8,000 ). give ok on everything.

restart the computer. and see if it improved performance. then test without paging tbm. and finally, you can let system manage.

Read more on : https://en.wikipedia.org/wiki/Memory_paging and https://support.microsoft.com/pt-br/help/2160852/ram-virtual-memory-pagefile-and-memory-management-in-windows and https://canaltech.com.br/windows/o-que-e-e-como-gerenciar-a-memoria-virtual-do-windows/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.