I considered the following experinment: simple C program, that only return 0, but linked with
all libraries that gcc allowed me to link – 207 total. It takes a lot of time to run this programm -2.1 cold start, 0.24 warm. So the next step is write program, also linked with
this heap of libraries, who will fork&exec on request. Idea was, that if it already loaded
libraries, and fork creates idential copy of process, then I will get running first programm
very quickly. But I found no difference, running first program via shell or via second programm, linked with all libraries.
What is my mistake?
EDIT: Yeah, I missed the point of exec. But is it any possible improvement of my idea to speedup starting application. I know about prelink, but it do a bit different idea.
The only advantage of what you’re doing is that it gets all the libraries read from disk into the filesystem cache (same as your “warm start”). Otherwise, what you’re doing is exactly how the shell loads a program (
forkandexec) so I don’t see how you expect it to be faster. The idea that this will “copy” a process is true if you justfork, but you alsoexec.To make a “copying” analogy with the filesystem, it’s like if you took a file that was really slow to generate, copied it, then
rm‘d it and generated it all over again rather than using the copy.