Dynamic loading method and system, device and storage medium
Patent Information
- Application Number
- CN202211407975.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-10
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2042-11-10
AI Technical Summary
但是,这样的解决方法无疑会增大成本,这对于成本控制极其敏感的嵌入式终端设备来说基本是不可接受的
[0018]The dynamic loading method provided in this invention refactors the application and its dependent components, refactoring the application into a fast-start function application and an application delayed loading library, and refactoring the components into fast-start function components and component delayed loading libraries. In response to a startup command, the fast-start function application and the fast-start function components are loaded to start the fast-start function application. After the fast-start function application starts, the application delayed loading library and the component delayed loading library are loaded to start the application delayed loading library. Thus, through this refactoring process, when the application starts, the fast-start function application and the fast-start function components are loaded first, followed by the application delayed loading library and the component delayed loading library, to start the application delayed loading library, thereby starting the non-fast-start function application. This helps reduce application startup time, accelerates the startup of the application's fast-start function, and also helps reduce costs.
Smart Images

Figure CN116302151B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a dynamic loading method and system, device and storage medium. Background Technology
[0002] As the functional and performance requirements of embedded terminal devices continue to increase, embedded programs are becoming more and more complex, with more and more components they depend on (such as shared dynamically loaded library SO files), occupying more and more storage space, and requiring more and more functions to start up quickly.
[0003] However, flash memory in embedded terminal devices has the disadvantages of slow read speed and small capacity, making it difficult to meet the increasingly complex storage capacity requirements of embedded programs. Furthermore, during the startup process of embedded terminal devices, the time spent reading programs from flash memory and mounting the file system also increases with the increase in program size, further increasing the startup time of functions that require fast startup.
[0004] From a hardware perspective, the two major problems of insufficient storage capacity and slow read speed can be solved by designing high-speed memory interfaces, using storage media with faster read speeds, and increasing memory capacity. However, such solutions would undoubtedly increase costs, which is basically unacceptable for embedded terminal devices where cost control is extremely sensitive.
[0005] Therefore, controlling costs while addressing the issues of insufficient storage capacity and slow read speeds becomes extremely important. Summary of the Invention
[0006] The problem solved by the embodiments of the present invention is to provide a dynamic loading method, system, device and storage medium that reduces application startup time, accelerates the startup of application fast startup function, and also helps to reduce costs.
[0007] To address the aforementioned problems, this invention provides a dynamic loading method, comprising: refactoring an application and its dependent components, wherein the application is refactored into a fast-start function application and an application delayed loading library, and the components are refactored into fast-start function components and a component delayed loading library; in response to a startup command, loading the fast-start function application and the fast-start function components to start the fast-start function application; and after the fast-start function application is started, loading the application delayed loading library and the component delayed loading library to start the application delayed loading library.
[0008] Optionally, the steps of refactoring the application and the components it depends on include: obtaining the source files of the application and the components it depends on; obtaining the symbols referenced by the fast startup function and the symbols referenced by non-fast startup functions in the source files during the application's operation, which are used as the fast startup symbol table and the delayed startup symbol table, respectively; and refactoring the application into a fast startup function application and an application delayed loading library based on the fast startup symbol table, the delayed startup symbol table, and the source files, and refactoring the components into fast startup function components and component delayed loading libraries.
[0009] Optionally, the step of refactoring the application and the components that the application depends on further includes: obtaining symbols that are not referenced in the source files during the application's operation, and using them to construct a redundant symbol table; based on the fast-start symbol table, the delayed-start symbol table, and the redundant symbol table, refactoring the application into a fast-start function application and an application delayed-loading library, and refactoring the components into fast-start function components and component delayed-loading libraries.
[0010] Optionally, the steps of refactoring the application into a fast-start function application and an application delayed loading library, and refactoring the components into fast-start function components and component delayed loading libraries, include: constructing a shared dynamic library for the fast-start function application and components based on the fast-start symbol table and the redundant symbol table; constructing an application delayed loading dynamic library and a component delayed loading dynamic library based on the delayed startup symbol table and the redundant symbol table; and loading the fast-start function application and the fast-start function component in response to a startup command, wherein the fast-start function application and the component shared dynamic library are loaded in response to a startup command; and loading the application delayed loading library and the component delayed loading library, wherein the application delayed loading library and the component delayed loading dynamic library are loaded.
[0011] Optionally, the step of obtaining the symbols referenced by the fast startup function and the symbols referenced by non-fast startup functions in the source file during application runtime includes: performing a first compilation process to collect the symbols referenced during application runtime as a runtime symbol table; modifying the application code to retain only the fast startup function; performing a second compilation process to collect the symbols referenced by the fast startup function as the fast startup symbol table; and obtaining the delayed startup symbol table based on the runtime symbol table and the fast startup symbol table.
[0012] Optionally, in the step of refactoring the application and the components it depends on, the fast-start function application and the fast-start component are stored in the root file system; the step of loading the fast-start function application and the fast-start component files in response to a startup command includes: mounting the root file system in response to the startup command; loading the fast-start function application; loading the fast-start component in response to the fast-start function application loading command; and starting the fast-start function application after the fast-start component is loaded.
[0013] Optionally, in the step of refactoring the application and the components it depends on, the application delayed loading library and the component delayed loading library are stored in the delayed loading library file system; the step of loading the application delayed loading library and the component delayed loading library includes: after the fast launch function application starts, the delayed loading library file system is mounted; the application delayed loading library is loaded; in response to the application delayed loading library loading command, the component delayed loading library is loaded; after the component delayed loading library is loaded, the application delayed loading library is started.
[0014] Accordingly, embodiments of the present invention provide a dynamic loading system, comprising: a refactoring module, configured to refactor an application and components dependent on the application, configured to refactor the application into a fast-start function application and an application delayed loading library, and configured to refactor the components into fast-start function components and a component delayed loading library; a fast-start module, configured to load the fast-start function application and the fast-start function components in response to a startup command, so as to start the fast-start function application; and a delayed loading module, configured to load the application delayed loading library and the component delayed loading library after the fast-start function application is started, so as to start the application delayed loading library.
[0015] Accordingly, embodiments of the present invention also provide a device including at least one memory and at least one processor, wherein the memory stores one or more computer instructions, and the one or more computer instructions are executed by the processor to implement the dynamic loading method provided in embodiments of the present invention.
[0016] Accordingly, embodiments of the present invention also provide a storage medium, characterized in that the storage medium stores one or more computer instructions, the one or more computer instructions being used to implement the dynamic loading method provided in embodiments of the present invention.
[0017] Compared with the prior art, the technical solution of the embodiments of the present invention has the following advantages:
[0018] The dynamic loading method provided in this invention refactors the application and its dependent components, refactoring the application into a fast-start function application and an application delayed loading library, and refactoring the components into fast-start function components and component delayed loading libraries. In response to a startup command, the fast-start function application and the fast-start function components are loaded to start the fast-start function application. After the fast-start function application starts, the application delayed loading library and the component delayed loading library are loaded to start the application delayed loading library. Thus, through this refactoring process, when the application starts, the fast-start function application and the fast-start function components are loaded first, followed by the application delayed loading library and the component delayed loading library, to start the application delayed loading library, thereby starting the non-fast-start function application. This helps reduce application startup time, accelerates the startup of the application's fast-start function, and also helps reduce costs. Attached Figure Description
[0019] Figure 1 This is a flowchart illustrating a dynamic loading method;
[0020] Figure 2 yes Figure 1 A schematic diagram of a specific embodiment of the dynamic loading method shown;
[0021] Figure 3 This is a flowchart illustrating an embodiment of the dynamic loading method of the present invention;
[0022] Figure 4 yes Figure 3 A flowchart of an embodiment of step S1;
[0023] Figure 5 yes Figure 4 A flowchart of an embodiment of step S102;
[0024] Figure 6 yes Figure 3 A schematic diagram of a specific embodiment of the dynamic loading method is shown;
[0025] Figure 7 This is a functional block diagram of an embodiment of the dynamic loading system of the present invention;
[0026] Figure 8 This is a hardware structure diagram of a device provided in an embodiment of the present invention. Detailed Implementation
[0027] As can be seen from the background technology, the flash memory of embedded terminal devices currently suffers from slow read speed and small capacity.
[0028] This paper analyzes the reasons for the slow read speed and small capacity of flash memory in current embedded terminal devices by combining a dynamic loading method. Figure 1 This is a flowchart illustrating a dynamic loading method. Figure 2 yes Figure 1 A schematic diagram of a specific embodiment.
[0029] refer to Figure 1 The application startup process includes:
[0030] Step s10: In response to the system startup command, mount the root file system;
[0031] Step s20: Application loading;
[0032] Step s30: In response to the application loading instruction, load the components that the application depends on;
[0033] Step s40: Application starts.
[0034] For example: Figure 2 As shown, after the root system is mounted, the application is loaded; in response to the application loading command, so file A is loaded, which includes loading so file A1, so file A2, and so file A3; in response to the application loading command, so file B is loaded, which includes loading so file B1, so file B2, and so file B3; the application starts.
[0035] During the execution of an embedded application, many symbols in the application itself and its dependent components may not be referenced (in combination with...). Figure 2 These unreferenced symbols have two effects: firstly, they occupy more storage space; secondly, they cause root file system mounting and application loading to take longer.
[0036] To address the aforementioned technical problem, embodiments of the present invention provide a dynamic loading method. (See reference...) Figure 3 The diagram shows a flowchart of an embodiment of the dynamic loading method of the present invention.
[0037] In this embodiment, the dynamic loading method includes the following basic steps:
[0038] Step S1: Refactor the application and the components that the application depends on, to refactor the application into a fast-start function application and an application delayed loading library, and to refactor the components into fast-start function components and component delayed loading libraries.
[0039] Step S2: In response to the startup command, load the fast startup function application and the fast startup function component to start the fast startup function application;
[0040] Step S3: After the application starts using the quick launch function, load the application delayed loading library and the component delayed loading library to start the application delayed loading library.
[0041] The dynamic loading method refactors the application and its dependent components, refactoring the application into a fast-start function application and an application delayed loading library, and refactoring the components into fast-start function components and component delayed loading libraries. In response to a startup command, the fast-start function application and the fast-start function components are loaded to start the fast-start function application. After the fast-start function application starts, the application delayed loading library and the component delayed loading library are loaded to start the application delayed loading library. Thus, through this refactoring process, when the application starts, the fast-start function application and the fast-start function components are loaded first, followed by the application delayed loading library and the component delayed loading library to start the application delayed loading library, thereby starting the non-fast-start function application. This helps reduce application startup time, accelerates the startup of the application's fast-start function, and also helps reduce costs.
[0042] To make the above-mentioned objects, features and advantages of the embodiments of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0043] refer to Figure 3 Step S1: Refactor the application and the components that the application depends on, for refactoring the application into a fast-start function application and an application delayed loading library, and for refactoring the components into fast-start function components and component delayed loading libraries.
[0044] The application and its dependent components are refactored so that when the application starts, the fast-start function application and fast-start function components are loaded first, followed by the application delayed loading library and component delayed loading library, so as to start the non-fast-start function application. This helps to reduce the application startup time and speeds up the startup of the application's fast-start function.
[0045] As an example, the application is used in an embedded device. The application defines the main functions and uses of the embedded system or device and is responsible for interacting with the user.
[0046] As an example, the components that the application depends on refer to components, libraries, or plugins required for the application to load and run, in order to ensure the normal operation of the application.
[0047] In this embodiment, the quick launch function application is an application that performs a specific function within the application. In specific implementations, the quick launch function application can be customized based on actual needs.
[0048] As an example, the fast-start function application is a function in the application that needs to be started and executed with priority, such as an application that performs the main or basic functions of the application; the application delayed loading library is a non-fast-start function application, which is a function with lower priority for startup and execution.
[0049] In one specific embodiment, the embedded device is a smart doorbell, the quick start function is used for sound generation, and the application delayed loading library is used for other functions, such as video functions. In another specific embodiment, the embedded device is a dashcam, the quick start function is used for display, and the application delayed loading library is used for other functions, such as recording and video recording.
[0050] It should be noted that, in this embodiment, during the step of reconstructing the application and the components that the application depends on, the fast launch function application and the fast launch component are stored in the root file system so that, in the subsequent step of loading the fast launch function application and the fast launch function component files in response to the startup command, the root file system can be mounted in response to the startup command.
[0051] It should also be noted that in this embodiment, during the step of refactoring the application and the components that the application depends on, the application delayed loading library and the component delayed loading library are stored in the delayed loading library file system. This means that the application delayed loading library and the component delayed loading library are both planned to be in another file system other than the root file system. When the application starts, the mounting time of the root file system can be reduced, which further accelerates the startup time of the fast startup function application.
[0052] Furthermore, in this embodiment, by refactoring the application and the components that the application depends on, a unified operation is provided for the refactoring of the application and components, which helps to save development and maintenance time.
[0053] Reference Figure 4 , showed Figure 3 A flowchart of an embodiment of step S1.
[0054] In this embodiment, step S1, which involves refactoring the application and the components that the application depends on, includes:
[0055] like Figure 4 As shown, step S101 is executed: obtain the source files of the application and the components that the application depends on.
[0056] Obtain the source files so that the application and components can be refactored based on them.
[0057] like Figure 4 As shown, step S102 is executed: during the application's operation, the symbols referenced by the fast startup function and the symbols referenced by the non-fast startup function in the source file are obtained and used as the fast startup symbol table and the delayed startup symbol table, respectively.
[0058] The fast-start symbol table is used for subsequent construction of fast-start function applications and fast-start function components, and the delayed-start symbol table is used for subsequent construction of application delayed-loading libraries and component delayed-loading libraries.
[0059] Figure 5 yes Figure 4 A flowchart of an embodiment of step S102.
[0060] Specifically, as an example, step S102, which involves obtaining the symbols referenced by the fast startup function and the symbols referenced by non-fast startup functions in the source file during application execution, includes:
[0061] like Figure 5 As shown, step S1021 is executed: the first compilation process is performed to collect the symbols referenced during the application's operation as a runtime symbol table.
[0062] The runtime symbol table contains all symbols referenced during application execution. By obtaining the runtime symbol table, and subsequently the fast startup symbol table, a delayed startup symbol table can be obtained based on the runtime symbol table and the fast startup symbol table.
[0063] Specifically, a compilation environment is constructed and a compiler is invoked to perform the first compilation process, obtaining the first compilation result. Accordingly, based on the first compilation result, the runtime symbol table is obtained.
[0064] like Figure 5 As shown, perform step S1022: Modify the application code to retain only the fast startup function.
[0065] Modify the application code to retain only the fast startup functionality, so that subsequent secondary compilation processing can be performed, thereby facilitating the collection of symbols referenced by the fast startup functionality.
[0066] like Figure 5 As shown, step S1023 is executed: a second compilation process is performed to collect the symbols referenced by the fast startup function as the fast startup symbol table.
[0067] Obtaining the fast startup symbol table is necessary for building application delayed loading libraries and component delayed loading libraries based on the fast startup symbol table. It also facilitates obtaining the delayed startup symbol table based on the fast startup symbol table and the runtime symbol table.
[0068] Specifically, a compilation environment is built and a compiler is invoked to perform a second compilation process to obtain a second compilation result. Accordingly, based on the second compilation result, the fast-start symbol table is obtained.
[0069] like Figure 5 As shown, step S1024 is executed: based on the running symbol table and the fast startup symbol table, the delayed startup symbol table is obtained.
[0070] Specifically, the runtime symbol table is all the symbols referenced during the application's execution. The symbols in the runtime symbol table other than those in the fast startup symbol table constitute the delayed startup symbol table.
[0071] like Figure 4 As shown, step S103 is executed as follows: based on the fast startup symbol table, the delayed startup symbol table, and the source file, the application is reconstructed into a fast startup function application and an application delayed loading library, and the component is reconstructed into a fast startup function component and a component delayed loading library.
[0072] More specifically, in this embodiment, the step of refactoring the application and the components that the application depends on further includes: obtaining symbols that are not referenced in the source file during the application's operation, and using them to construct a redundant symbol table.
[0073] Accordingly, in this embodiment, based on the fast startup symbol table, the delayed startup symbol table, and the redundant symbol table, the application is reconstructed into a fast startup function application and an application delayed loading library, and the components are reconstructed into fast startup function components and component delayed loading libraries.
[0074] Obtaining the redundant symbol table allows for its removal from source files during the refactoring of applications and components, thereby reducing storage space usage.
[0075] Accordingly, in this embodiment, the steps of reconstructing the application into a fast-start function application and an application delayed loading library, and reconstructing the component into a fast-start function component and a component delayed loading library, include: constructing a shared dynamic library for the fast-start function application and the component based on the fast-start symbol table and the redundant symbol table; and constructing an application delayed loading dynamic library and a component delayed loading dynamic library based on the delayed-start symbol table and the redundant symbol table.
[0076] Accordingly, in the subsequent step of loading the quick-start function application and the quick-start function component in response to the startup command, the shared dynamic library of the quick-start function application and the component is loaded in response to the startup command.
[0077] Accordingly, in the subsequent steps of loading the application delayed loading library and the component delayed loading library, the application delayed loading library and the component delayed loading dynamic library are loaded.
[0078] Continue to refer to Figure 3 Step S2: In response to the startup command, load the fast startup function application and the fast startup function component to start the fast startup function application.
[0079] In this embodiment, the steps of loading the fast-start function application and the fast-start function component file in response to the startup command include: mounting the root file system in response to the startup command; loading the fast-start function application; loading the fast-start function component in response to the fast-start function application loading command; and starting the fast-start function application after the fast-start function component is loaded.
[0080] Specifically, in this embodiment, in the step of loading the quick-start function application and the quick-start function component in response to the startup command, the shared dynamic library of the quick-start function application and the component is loaded in response to the startup command.
[0081] Reference Figure 6 , Figure 6 yes Figure 3 The diagram illustrates a specific embodiment of the dynamic loading method. As an example, in response to the fast-start function application loading instruction, loading the fast-start function component includes: loading the dynamic library of SO file A (reconstructed version A), which includes loading the dynamic libraries of SO file A1, SO file A2, and SO file A3; and loading the dynamic library of SO file B (reconstructed version B1 and SO file B2), which includes loading the dynamic libraries of SO file B1 and SO file B2.
[0082] Continue to refer to Figure 3 Step S3: After the application starts using the quick start function, load the application delayed loading library and the component delayed loading library to start the application delayed loading library.
[0083] In this embodiment, when the application starts, the fast-start function application and fast-start function component are loaded first, and then the application delayed loading library and component delayed loading library are loaded to start the application delayed loading library to start the non-fast-start function application. This helps to reduce the application startup time, speeds up the startup of the application's fast-start function, and also helps to reduce costs.
[0084] In this embodiment, the steps of loading the application delayed loading library and the component delayed loading library include: after the fast startup function application starts, the delayed loading library file system is mounted; the application delayed loading library is loaded; in response to the application delayed loading library loading command, the component delayed loading library is loaded; after the component delayed loading library is loaded, the application delayed loading library is started.
[0085] Specifically, in this embodiment, the step of loading the application delayed loading library and the component delayed loading library involves loading the application delayed loading library and the component delayed loading dynamic library.
[0086] Reference Figure 6 , Figure 6 yes Figure 3 The diagram illustrates a specific embodiment of the dynamic loading method. As a specific embodiment, the steps of loading the application delayed loading library and the component delayed loading library include: in response to the application delayed loading library loading command, delay loading dynamic libraries for SO file A are performed, including: delay loading dynamic libraries for SO file A1, SO file A2, and SO file A3; in response to the application delayed loading library loading command, delay loading dynamic libraries for SO file B are performed, including: delay loading dynamic libraries for SO file B1 and SO file B2.
[0087] Accordingly, the present invention also provides a dynamic loading method. Figure 7 This is a functional block diagram of an embodiment of the dynamic loading system of the present invention.
[0088] refer to Figure 7The dynamic loading system 100 includes: a refactoring module 11, used to refactor the application and the components that the application depends on, used to refactor the application into a fast-start function application and an application delayed loading library, and used to refactor the components into fast-start function components and a component delayed loading library; a fast-start module 12, used to load the fast-start function application and the fast-start function components in response to a startup command, so as to start the fast-start function application; and a delayed loading module 13, used to load the application delayed loading library and the component delayed loading library after the fast-start function application is started, so as to start the application delayed loading library.
[0089] The refactoring module 11 is used to refactor the application and the components that the application depends on, so as to refactor the application into a fast-start function application and an application delayed loading library, and to refactor the components into fast-start function components and component delayed loading libraries; the fast-start module 12 is used to load the fast-start function application and the fast-start function components in response to a startup command, so as to start the fast-start function application; the delayed loading module 13 is used to load the application delayed loading library and the component delayed loading library after the fast-start function application starts, so as to start the application delayed loading library. Thus, through the refactoring module 11, when the application starts, the fast-start function application and the fast-start function components can be loaded first, and then the application delayed loading library and the component delayed loading library can be loaded to start the application delayed loading library, so as to start the non-fast-start function application. This helps to reduce the application startup time, accelerate the startup of the application's fast-start function, and also helps to reduce costs.
[0090] The refactoring module 11 refactors the application and the components that the application depends on, so that when the application starts, the fast-start function application and fast-start function components are loaded first, and then the application delayed loading library and component delayed loading library are loaded to start the non-fast-start function application. This helps to reduce the application startup time and speeds up the startup of the application's fast-start function.
[0091] As an example, the application is used in an embedded device. The application defines the main functions and uses of the embedded system or device and is responsible for interacting with the user.
[0092] As an example, the components that the application depends on refer to components, libraries, or plugins required for the application to load and run, in order to ensure the normal operation of the application.
[0093] In this embodiment, the quick launch function application is an application that performs a specific function within the application. In specific implementations, the quick launch function application can be customized based on actual needs.
[0094] As an example, the fast-start function application is a function in the application that needs to be started and executed with priority, such as an application that performs the main or basic functions of the application; the application delayed loading library is a non-fast-start function application, which is a function with lower priority for startup and execution.
[0095] In one specific embodiment, the embedded device is a smart doorbell, the quick start function is used for sound generation, and the application delayed loading library is used for other functions, such as video functions. In another specific embodiment, the embedded device is a dashcam, the quick start function is used for display, and the application delayed loading library is used for other functions, such as recording and video recording.
[0096] It should be noted that, in this embodiment, the fast startup application and the fast startup component are stored in the root file system so that, in the subsequent step of loading the fast startup application and the fast startup component files in response to the startup command, the root file system can be mounted in response to the startup command.
[0097] It should also be noted that in this embodiment, the application delayed loading library and the component delayed loading library are stored in the delayed loading library file system, thereby planning both the application delayed loading library and the component delayed loading library to another file system other than the root file system. When the application starts, the mounting time of the root file system can be reduced, which further accelerates the startup time of the fast startup function application.
[0098] Furthermore, in this embodiment, the refactoring module 11 performs refactoring processing on the application and the components that the application depends on, thereby providing a unified operation for the refactoring of the application and components, which helps to save development and maintenance time.
[0099] As an example, the refactoring module 11 includes: a source file acquisition unit, used to acquire the source files of the application and the components that the application depends on; a reference symbol acquisition unit, used to acquire symbols referenced by the fast startup function and symbols referenced by non-fast startup functions in the source files during the application's operation, which are respectively used as a fast startup symbol table and a delayed startup symbol table; a second compiler, used to perform a second compilation process to collect the symbols referenced by the fast startup function as the fast startup symbol table; and a refactoring unit, used to refactor the application into a fast startup function application and an application delayed loading library based on the fast startup symbol table, the delayed startup symbol table, and the source files, and to refactor the components into fast startup function components and component delayed loading libraries.
[0100] The source file acquisition unit acquires source files so that the application and components can be refactored based on the source files.
[0101] The fast-start symbol table is used for subsequent construction of fast-start function applications and fast-start function components, and the delayed-start symbol table is used for subsequent construction of application delayed-loading libraries and component delayed-loading libraries.
[0102] Specifically, as an example, the symbol acquisition unit includes: a first compiler for performing a first compilation process to collect symbols referenced during application execution as a runtime symbol table; a code modifier for modifying the application code to retain only the fast startup function; a second compiler for performing a second compilation process to collect symbols referenced by the fast startup function as the fast startup symbol table; and a delayed startup symbol acquirer for acquiring the delayed startup symbol table based on the runtime symbol table and the fast startup symbol table.
[0103] The runtime symbol table contains all symbols referenced during application execution. By obtaining the runtime symbol table, and subsequently the fast startup symbol table, a delayed startup symbol table can be obtained based on the runtime symbol table and the fast startup symbol table.
[0104] Specifically, the first compiler builds a compilation environment and calls the compiler to perform the first compilation process to obtain the first compilation result. Accordingly, based on the first compilation result, the runtime symbol table is obtained.
[0105] A code editor is used to modify the application's code to retain only the fast-start functionality for a second compilation process, thereby facilitating the collection of symbols referenced by the fast-start functionality.
[0106] The second compiler is used to obtain the fast startup symbol table so that application lazy loading libraries and component lazy loading libraries can be built based on the fast startup symbol table. It also facilitates the acquisition of the lazy startup symbol table based on the fast startup symbol table and the runtime symbol table.
[0107] Specifically, the second compiler builds a compilation environment and calls the compiler to perform a second compilation process to obtain a second compilation result. Accordingly, based on the second compilation result, the fast startup symbol table is obtained.
[0108] Specifically, the runtime symbol table is all the symbols referenced during the application's execution. The symbols in the runtime symbol table other than those in the fast startup symbol table constitute the delayed startup symbol table.
[0109] The refactoring unit, based on the fast-start symbol table, the delayed-start symbol table, and the source files, refactors the application into a fast-start function application and an application delayed-loading library, and refactors the components into fast-start function components and component delayed-loading libraries.
[0110] More specifically, in this embodiment, the step of refactoring the application and the components that the application depends on further includes: obtaining symbols that are not referenced in the source file during the application's operation, and using them to construct a redundant symbol table.
[0111] Accordingly, in this embodiment, based on the fast startup symbol table, the delayed startup symbol table, and the redundant symbol table, the application is reconstructed into a fast startup function application and an application delayed loading library, and the components are reconstructed into fast startup function components and component delayed loading libraries.
[0112] Obtaining the redundant symbol table allows for its removal from source files during the refactoring of applications and components, thereby reducing storage space usage.
[0113] Accordingly, in this embodiment, the refactorer constructs a fast-start function application and component shared dynamic library based on the fast-start symbol table and the redundant symbol table, and also constructs an application delayed loading dynamic library and a component delayed loading dynamic library based on the delayed-start symbol table and the redundant symbol table.
[0114] The quick start module 12 is used to load the quick start function application and the quick start function component in response to a startup command, so as to start the quick start function application.
[0115] In this embodiment, the fast startup module 12 includes: a first file system mounting unit, used to mount the root file system in response to a startup command; a fast startup function application loading unit, used to load the fast startup function application; and a fast startup function component loading unit, used to load the fast startup function component in response to the fast startup function application loading command.
[0116] Accordingly, the quick launch function application starts after the quick launch function component is loaded.
[0117] Specifically, in this embodiment, in response to the startup command, the quick-start function application and the component-shared dynamic library are loaded.
[0118] Reference Figure 6 As an example, in response to the fast-start function application loading instruction, loading the fast-start function component includes: loading the refactored dynamic library of so file A in response to the fast-start function application loading instruction; the refactored dynamic library loading of so file A includes loading the refactored dynamic library of so file A1, so file A2, and so file A3; and loading the refactored dynamic library of so file B in response to the fast-start function application loading instruction; the refactored dynamic library loading of so file B includes loading the refactored dynamic library of so file B1 and so file B2.
[0119] The delayed loading module 13 is used to load the application delayed loading library and the component delayed loading library after the fast start function application is started, so as to start the application delayed loading library.
[0120] In this embodiment, when the application starts, the fast-start function application and fast-start function component are loaded first, and then the application delayed loading library and component delayed loading library are loaded to start the application delayed loading library to start the non-fast-start function application. This helps to reduce the application startup time, speeds up the startup of the application's fast-start function, and also helps to reduce costs.
[0121] In this embodiment, the delayed loading module 13 includes: a second file system mounting unit, used to mount the delayed loading library file system after the fast startup function application starts; an application delayed loading library unit, used to load the application delayed loading library; and a component delayed loading unit, used to load the component delayed loading library in response to the application delayed loading library loading command.
[0122] Accordingly, after the component delayed loading library is loaded, the application delayed loading library is started.
[0123] Specifically, in this embodiment, the application delayed loading library and the component delayed loading dynamic library are loaded.
[0124] Reference Figure 6 As a specific embodiment, the steps of loading the application delayed loading library and the component delayed loading library include: in response to the application delayed loading library loading command, the delayed loading dynamic library of so file A is loaded, and the delayed loading dynamic library of so file A includes: the delayed loading dynamic library of so file A1, the delayed loading dynamic library of so file A2, and the delayed loading dynamic library of so file A3; in response to the application delayed loading library loading command, the delayed loading dynamic library of so file B is loaded, and the delayed loading dynamic library of so file B includes: the delayed loading dynamic library of so file B1 and the delayed loading dynamic library of so file B2.
[0125] To address the aforementioned problem, embodiments of the present invention also provide a device that can implement the dynamic loading method provided by the embodiments of the present invention through the above-described dynamic loading method in the form of a loader.
[0126] An optional hardware structure of the device provided in this embodiment of the invention can be as follows: Figure 8 As shown, it includes: at least one processor 01, at least one communication interface 02, at least one memory 03, and at least one communication bus 04.
[0127] In this embodiment of the invention, the number of processor 01, communication interface 02, memory 03 and communication bus 04 is at least one, and processor 01, communication interface 02 and memory 03 communicate with each other through communication bus 04.
[0128] Optionally, the communication interface 02 can be an interface for a communication module used for network communication, such as the interface of a GSM module.
[0129] Optionally, processor 01 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.
[0130] Optionally, memory 03 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0131] The memory 03 stores one or more computer instructions, which are executed by the processor 01 to implement the dynamic loading method provided in this embodiment of the invention.
[0132] It should be noted that the aforementioned terminal device may also include other devices (not shown) that may not be essential to understanding the content disclosed in the embodiments of the present invention; given that these other devices may not be essential for understanding the content disclosed in the embodiments of the present invention, the embodiments of the present invention will not describe them one by one.
[0133] Accordingly, embodiments of the present invention also provide a storage medium storing one or more computer instructions, which are used to implement the dynamic loading method described in the embodiments of the present invention.
[0134] The storage medium is a computer-readable storage medium, which can be a read-only memory (ROM), random access memory (RAM), USB flash drive, portable hard drive, magnetic disk or optical disk, or any other medium that can store program code.
[0135] The embodiments of the present invention described above are combinations of elements and features of the present invention. Unless otherwise stated, the elements or features described are optional. Individual elements or features may be practiced without combination with other elements or features. Furthermore, embodiments of the present invention may be constructed by combining some elements and / or features. The order of operations described in the embodiments of the present invention may be rearranged. Some constructions of any embodiment may be included in another embodiment and may be replaced by corresponding constructions of another embodiment. It will be apparent to those skilled in the art that claims in the appended claims that are not expressly referenced to each other may be combined to form embodiments of the present invention, or may be included as new claims in amendments made after the filing of this application.
[0136] Embodiments of the present invention can be implemented by various means, such as hardware, firmware, software, or combinations thereof. In a hardware configuration, the method according to an exemplary embodiment of the present invention can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, etc.
[0137] In firmware or software configuration, embodiments of the present invention can be implemented in the form of modules, processes, functions, etc. Software code can be stored in a memory unit and executed by a processor. The memory unit is located inside or outside the processor and can send data to and receive data from the processor via various known means.
[0138] While the present invention has been disclosed above, it is not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of the invention; therefore, the scope of protection of the present invention should be determined by the scope defined in the claims.
Claims
1. A dynamic loading method, characterized in that, include: Obtain the source files of the application and the components that the application depends on, and based on the symbols referenced by the fast startup function and the symbols referenced by non-fast startup functions in the source files, refactor the application and the components that the application depends on, to refactor the application into a fast startup function application and an application delayed loading library, and to refactor the components into fast startup function components and component delayed loading libraries. In response to the startup command, the fast startup function application and the fast startup function component are loaded to start the fast startup function application; After the application starts using the quick launch function, the application delayed loading library and component delayed loading library are loaded to start the application delayed loading library.
2. The dynamic loading method as described in claim 1, characterized in that, The steps for refactoring the application and its dependent components based on the symbols referenced by the fast startup function and the symbols referenced by non-fast startup functions in the source file include: During the application's runtime, the symbols referenced by the fast startup function and the symbols referenced by the non-fast startup function in the source file are obtained and used as the fast startup symbol table and the delayed startup symbol table, respectively. Based on the fast-start symbol table, the delayed-start symbol table, and the source files, the application is refactored into a fast-start function application and an application delayed-load library, and the components are refactored into fast-start function components and component delayed-load libraries.
3. The dynamic loading method as described in claim 2, characterized in that, The steps of refactoring the application and the components that the application depends on also include: obtaining symbols that are not referenced in the source files during the application's operation, and using them to construct a redundant symbol table; Based on the fast-start symbol table, delayed-start symbol table, and redundant symbol table, the application is refactored into a fast-start function application and an application delayed-loading library, and the components are refactored into fast-start function components and component delayed-loading libraries.
4. The dynamic loading method as described in claim 3, characterized in that, The steps of refactoring the application into a fast-start function application and an application delayed loading library, and refactoring the components into fast-start function components and component delayed loading libraries, include: constructing a shared dynamic library for fast-start function applications and components based on the fast-start symbol table and the redundant symbol table; and constructing an application delayed loading dynamic library and a component delayed loading dynamic library based on the delayed startup symbol table and the redundant symbol table. In the step of loading the fast launch function application and the fast launch function component in response to the launch command, the fast launch function application and the component share a dynamic library in response to the launch command. In the step of loading the application delayed loading library and the component delayed loading library, the application delayed loading library and the component delayed loading dynamic library are loaded.
5. The dynamic loading method as described in claim 2, characterized in that, The steps for obtaining the symbols referenced by the fast startup function and the symbols referenced by non-fast startup functions in the source file during application runtime include: performing a first compilation process to collect the symbols referenced during application runtime as a runtime symbol table; modifying the application code to retain only the fast startup function; performing a second compilation process to collect the symbols referenced by the fast startup function as the fast startup symbol table; and obtaining the delayed startup symbol table based on the runtime symbol table and the fast startup symbol table.
6. The dynamic loading method as described in claim 1, characterized in that, In the step of refactoring the application and the components that the application depends on, the fast startup function application and the fast startup component are stored in the root file system; The steps of loading the fast-start function application and the fast-start function component file in response to a startup command include: mounting the root file system in response to the startup command; loading the fast-start function application; loading the fast-start function component in response to the fast-start function application loading command; and starting the fast-start function application after the fast-start function component is loaded.
7. The dynamic loading method as described in claim 1 or 6, characterized in that, In the step of refactoring the application and the components that the application depends on, the application lazy loading library and the component lazy loading library are stored in the lazy loading library file system; The steps of loading the application delayed loading library and the component delayed loading library include: after the fast startup function application starts, the delayed loading library file system is mounted; the application delayed loading library is loaded; in response to the application delayed loading library loading command, the component delayed loading library is loaded; after the component delayed loading library is loaded, the application delayed loading library is started.
8. A dynamic loading system, characterized in that, include: The refactoring module is used to obtain the source files of the application and the components that the application depends on, and to refactor the application and the components that the application depends on based on the symbols referenced by the fast startup function and the symbols referenced by non-fast startup functions in the source files. The refactoring module is used to refactor the application into a fast startup function application and an application delayed loading library, and to refactor the components into fast startup function components and component delayed loading libraries. A quick start module is used to load the quick start function application and the quick start function component in response to a start command, so as to start the quick start function application; The delayed loading module is used to load the application delayed loading library and the component delayed loading library after the fast launch function application is launched, so as to start the application delayed loading library.
9. A device, characterized in that, It includes at least one memory and at least one processor, the memory storing one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the dynamic loading method as described in any one of claims 1-7.
10. A storage medium, characterized in that, The storage medium stores one or more computer instructions. one One or more computer instructions are used to implement the dynamic loading method as described in any one of claims 1-7.
Citation Information
Patent Citations
Quick start method of X86 flight control computer
CN101515239A
System startup management and operating system configuration method of embedded device
CN109189485A