4

Pretty much everyday when I first bring up Mathematica, it takes a very long time. Subsequently, if I close it down and reopen, it is very quick. This is on my home computer (version 13.2), but the same strange behavior, sometimes minutes long, also happens on some of the computers at my college (various versions 12.*).

I started the application and immediately invoked: FE`Evaluate[FEPrivate`$StartTimes]//Column:

Initializing kernel connections...->1.594
Initializing cell styles...->2.547
Initializing fonts...->6.985
Initializing menus...->6.985
Initializing defaults notebook...->12.391
Initializing defaults clipboards...->13.797
Initializing internal preferences...->13.844
Initializing kernels...->14.891
Opening Welcome Screen...->24.141
Initializing toolbars...->24.156
Preloading Favorites...->24.578
Handling CommandLineOptions...->24.578
Opening Files...->24.578
Do Startup Action...->24.578
Closing Splash Screen...->26.297
Finished->26.297

and the next time, right away:

Initializing kernel connections...->0.5
Initializing cell styles...->0.657
Initializing fonts...->0.829
Initializing menus...->0.844
Initializing defaults notebook...->1.063
Initializing defaults clipboards...->1.438
Initializing internal preferences...->1.485
Initializing kernels...->1.657
Opening Welcome Screen...->3.938
Initializing toolbars...->3.938
Preloading Favorites...->4.313
Handling CommandLineOptions...->4.313
Opening Files...->4.313
Do Startup Action...->4.313
Closing Splash Screen...->5.079
Finished->5.079

Explanations and/or workarounds would be greatly appreciated.

Thank you.

Aharon Naiman
  • 1,173
  • 6
  • 13
  • Is Mathematica installed on a mechanical hard drive or SSD? Also, do you start Mathematica immediately after first logging in, or only after the computer has been running for a while? – Lukas Lang Feb 19 '23 at 15:19
  • HDD. And the computer has usually been running. Thanx. – Aharon Naiman Feb 19 '23 at 16:55
  • 1
    Can you check the disk activity during a slow & fast launch? I would expect the disk to be over-utilized during a slow startup, and less so during a fast startup. – Lukas Lang Feb 19 '23 at 18:05
  • 2
    Windows will cache files that are read and written to during a session. If I run a copy of Mathematica from a local HDD (aka spinning rust), the first time in the session takes 10.9 seconds. The second instance, 2.9 seconds. Caching on SSDs matter less, but the same is true. – ihojnicki Feb 19 '23 at 18:47
  • @LukasLang, thanx, I will check that, but only tomorrow or the next time that I have not used Mma for a while. Regarding caching, the thing is that this happens over two separate sessions. – Aharon Naiman Feb 19 '23 at 21:02
  • The caches are flushed when the machine is rebooted. They can also be flushed mid-session, since it is all RAM based. There could be something else in play (anti-virus, anti-malware, etc...) but there is not enough data to make any additional suggestions. – ihojnicki Feb 19 '23 at 22:24
  • To clarify something regarding the caching: the caching @ihojnicki mentioned is performed by Windows, not Mathematica. So it doesn't matter that you restart Mathematica: As long as Windows is running (and nothing else needs the RAM), Windows will likely keep some files in the cache, thereby speeding up subsequent launches of Mathematica sessions – Lukas Lang Feb 19 '23 at 23:49
  • I see this on linux machines all the time. It may be another issue, but a Windows virus scanner is not the only thing slowing it down. – garrett mitchener Apr 07 '23 at 14:37

1 Answers1

2

Not an answer, but comparable figures from my PC

FE`Evaluate[FEPrivate`$StartTimes] // InputForm
(* Out[3]//InputForm 
 {"Initializing kernel connections..." -> 1.21, 
 "Initializing cell styles..." -> 1.36, 
 "Initializing fonts..." -> 1.53, "Initializing menus..." -> 
 1.53, "Initializing defaults notebook..." -> 2.1, 
 "Initializing defaults clipboards..." -> 2.26, 
 "Initializing internal preferences..." -> 2.26, 
"Initializing kernels..." -> 2.39, 
"Opening Welcome Screen..." -> 5.32, 
"Initializing toolbars..." -> 7.37, 
"Preloading Favorites..." -> 7.6, 
"Handling CommandLineOptions..." -> 7.6, 
"Opening Files..." -> 7.6,
"Do Startup Action..." -> 7.6, 
"Closing Splash Screen..." -> 7.61,
"Finished" -> 7.61} *)

$Version ("13.1.0 for Linux x86 (64-bit) (June 16, 2022)" )

I wonder if you have a virus checker scanning some of the files on first use?

Another possibility I've seen with some programs is that they are trying to access a slow (or inaccessible) remote resource. Perhaps you can see if you have set Mathematica to access something on start up that might be slow on first use.

mikado
  • 16,741
  • 2
  • 20
  • 54
  • Thank you. How would I check whether the virus checker is scanning some of the files? Also, can the output I provided hint at a possible slow or inaccessible resource? It seems that everything is about 5 times as slow. – Aharon Naiman Feb 19 '23 at 21:05
  • @AharonNaiman could you temporarily disable virus scanning and see if start up was faster? I'm not sure when Mathematica looks for user defined start up files (or what these are precisely) but you might check what has been specified. (I'm afraid that my advice was a bit generic, rather than Mathematica-specific). – mikado Feb 19 '23 at 21:57
  • I did as you suggested, and the startup time dropped from 26 to 20 seconds, nowhere near the 5 seconds for subsequent startups. So the virus scanning is partly "guilty" as you surmised, and perhaps the balance is due to caching and disk usage, as suggested by Lucas Lang and ihojnicki. However, I do not know what to do about the caching and disk usage, especially as this happen on other computers (at the college) as well. – Aharon Naiman Feb 21 '23 at 12:39