I found that even if I didn't have any actual code, it would take at least 5 seconds for the program to start. After some debugging, I found an option in SpringApplicatonBuilder class to significantly increase startup speed. The option is logStartupInfo, if I set it to false, then startup time only takes 1 seconds. Then I found when the application tries to print out PID, it use almost 4 seconds. So I think if we are in a container environment, print out PID is not unnecessary. But the problem is this, if I set the option to false, I don't know exactly what the start time is, and maybe other information. Maybe we can make PID logging option as another option?
Comment From: RickyWuCN
some useful information is: Class: SpringApplication Method: prepareContext Code: this.logStartupInfo(context.getParent() == null);
Comment From: wilkinsona
Thanks for the report. I doubt that the PID is the problem as it is included in every log message by default, not just the startup info.
Are you running on macOS? If so, https://thoeni.io/post/macos-sierra-java/ should help.
Comment From: RickyWuCN
Yes, I am using a macbook. I can test this later in a windows.
Comment From: RickyWuCN
It's ok in windows 10. log out PID is not very slow.
Comment From: RickyWuCN
After I update my spring boot version to latest, I saw some warning messge about InetAddress.getLocalHost().getHostName(). So I think the problem is really about that and not the PID.
Comment From: wilkinsona
Thanks for the confirmation. Please refer to https://thoeni.io/post/macos-sierra-java/ for an explanation of how to correct your machine's network configuration.