Warning, /frameworks/kinit/README.md is written in an unsupported language. File is not indexed.
0001 # KInit 0002 0003 Helper library to speed up start of applications on KDE workspaces 0004 0005 ## Introduction 0006 0007 kdeinit is a process launcher somewhat similar to the famous init used for 0008 booting UNIX. 0009 0010 It launches processes by forking and then loading a dynamic library which 0011 should contain a 'kdemain(...)' function. 0012 0013 Using kdeinit to launch KDE applications makes starting a typical KDE 0014 applications 2.5 times faster (100ms instead of 250ms on a P-III 500) It 0015 reduces memory consumption by approx. 350Kb per application. 0016 0017 0018 ## How it works 0019 0020 kdeinit is linked against all libraries a standard KDE application needs. With 0021 this technique starting an application becomes much faster because now only the 0022 application itself needs to be linked whereas otherwise both the application as 0023 well as all the libraries it uses need to be linked. 0024 0025 0026 ## Startup Speed 0027 0028 Starting an application linked against libqt, libkdecore and libkdeui in the 0029 conventional way takes approx. 150ms on a Pentium III - 500Mhz. Starting the 0030 same application via kdeinit takes less than 10ms. 0031 0032 (application without KApplication constructor, the KApplication constructor 0033 requires an extra 100ms in both cases) 0034 0035 0036 ## Memory Usage 0037 0038 An application linked against libqt, libkdecore and libkdeui started in the 0039 conventional way requires about 498Kb memory. (average of 10 instances) If the 0040 same application is started via kdeinit it requires about 142Kb. A difference 0041 of 356Kb (application without KApplication constructor) 0042 0043 If we take the KApplication constructor into account, an application started in 0044 the conventional way takes about 679Kb memory while the same application 0045 started via kdeinit requires about 380Kb. Here the difference is somewhat less, 0046 299Kb. This seems to be caused by the fact that the dynamic linker does "lazy 0047 linking". We can force the linker to link everything at startup by specifying 0048 "LD\_BIND\_NOW=true". When kdeinit is started with this option on, kdeinit is 0049 back to its full efficiency, an application with a KApplication constructor now 0050 uses 338Kb of memory. A difference of 341Kb with the normal case. 0051 0052 0053 ## Adapting programs to use kdeinit 0054 0055 The source code of a program does not require any change to take advantage of 0056 kdeinit, only the build system needs to be adjusted: 0057 0058 First you need to find the KF5Init package: 0059 0060 find_package(KF5Init 5.0.0 REQUIRED) 0061 0062 Then, instead of declaring your executable and the libraries it links to like this: 0063 0064 add_executable(myexe ${myexe_SRCS}) 0065 0066 target_link_libraries(myexe ...) 0067 0068 You must use: 0069 0070 kf5_add_kdeinit_executable(myexe ${myexe_SRCS}) 0071 0072 # Note the different target name 0073 target_link_libraries(kdeinit_myexe ...) 0074 0075 0076 ## Disadvantages 0077 0078 The process name of applications started via kdeinit is "kdeinit". This problem 0079 can be corrected to a degree by changing the application name as shown by 'ps'. 0080 However, applications like `killall` will only see "kdeinit" as process name. 0081 To workaround this, use `kdekillall`, from [kde-dev-scripts][], for applications 0082 started via kdeinit. 0083 0084 [kde-dev-scripts]: https://commits.kde.org/kde-dev-scripts 0085