Data processing method, device and computer program product
By preloading and initializing critical configuration files during application startup, the problem of some files not being included in the pre-read process in existing technologies is solved, thus improving application startup efficiency.
Patent Information
- Application Number
- CN202510997229.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-18
- Publication Date
- 2025-11-07
AI Technical Summary
In existing technologies, some files cannot be included in the pre-read process during application startup, affecting the effectiveness and efficiency of pre-reading.
The first file at a preset position in the input table of the application process image file is preloaded, and its initialization function is used for configuration to ensure that critical files are included in the pre-read process before the critical moment when pre-reading takes effect.
By preloading and initializing the configuration, the necessary settings after the file is loaded are completed in a timely manner, which prepares the application for subsequent pre-reading operations, covers more critical file loading stages, solves the problem that some files cannot be included in the pre-reading process due to late pre-reading timing, and improves the startup efficiency of the application.
Smart Images

Figure CN120909671A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of information technology, and in particular, to a data processing method, device and computer program product. BACKGROUND
[0002] In the application program starting process, after determining the file segments required for starting the application program, the file segments need to be pre-read.
[0003] In the pre-reading scheme of the related prior art, a part of the files has been loaded before the critical moment of the pre-reading taking effect, and the loaded files cannot be included in the pre-reading process, thereby affecting the effectiveness and efficiency of the pre-reading. SUMMARY
[0004] To overcome the problems in the related art, the present disclosure provides a data processing method, device and computer program product, which not only ensures that the necessary settings after loading the files are completed in time, but also covers more critical file loading links, and solves the problem that part of the files cannot be included in the pre-reading process.
[0005] According to a first aspect of an embodiment of the present disclosure, a data processing method is provided, comprising:
[0006] In response to a first starting event of an application program, a first file in a preset position of an input table of the application program is loaded;
[0007] In a case where a system sub-file in the first file is loaded, a first initialization configuration is performed by using a first initialization function of the first file;
[0008] In a case where the first initialization configuration is completed, a file segment required for starting the application program is pre-read.
[0009] According to a second aspect of an embodiment of the present disclosure, a data processing device is provided, comprising:
[0010] A first loading module is configured to load, in response to a first starting event of an application program, a first file in a preset position of an input table of the application program;
[0011] A first initialization module is configured to perform, in a case where a system sub-file in the first file is loaded, a first initialization configuration by using a first initialization function of the first file;
[0012] A starting module is configured to pre-read, in a case where the first initialization configuration is completed, a file segment required for starting the application program.
[0013] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising:
[0014] a processor;
[0015] a memory for storing processor-executable instructions;
[0016] The processor executes the computer program or instructions to implement the steps of the method according to any one of the first aspect.
[0017] According to a fourth aspect of the embodiments of the present disclosure, a non-transitory computer-readable storage medium is provided, which stores computer programs or instructions, and when the computer programs or instructions in the storage medium are executed by a processor, the steps of the method according to any one of the first aspect are implemented.
[0018] According to a fifth aspect of the embodiments of the present disclosure, a computer program product is provided, which includes computer programs or instructions, and when the computer programs or instructions are executed by a processor, the steps of the method according to any one of the first aspect are implemented. The technical solutions provided by the embodiments of the present disclosure can include the following beneficial effects:
[0019] The present disclosure loads the first file located at the preset position in the input table of the application program process image file in advance, so that the key dependent file (the first file) can be included in the pre-reading process before the critical moment of pre-reading taking effect; after the system sub-file in the first file is loaded, the first initialization function in the preset callback table is used for initialization configuration, so as to ensure that the necessary settings after file loading are completed in time and fully prepare for subsequent pre-reading operation; after the initialization configuration is completed, the file segments required for starting the application program are pre-read, so as to cover more key file loading links and solve the problem that some files cannot be included in the pre-reading process due to late pre-reading opportunity.
[0020] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0021] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure.
[0022] Figure 1 is a flowchart of a data processing method according to an exemplary embodiment.
[0023] Figure 2 is a schematic diagram of a file segment according to an exemplary embodiment.
[0024] Figure 3 is a flowchart of another data processing method according to an exemplary embodiment.
[0025] Figure 4 is a data processing device block diagram according to an exemplary embodiment.
[0026] Figure 5 is a structural schematic diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0027] The exemplary embodiments will be described in detail herein with reference to the accompanying drawings. In the following description, the same numbers refer to the same or similar elements throughout the drawings, unless otherwise represented. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure. Instead, they only represent examples of devices and methods consistent with some aspects of the present disclosure, as detailed in the appended claims.
[0028] The present disclosure proposes a data processing method, Figure 1 is a flowchart of a data processing method according to an exemplary embodiment. As Figure 1 shown, the method mainly includes the following steps:
[0029] In step 101, in response to a first start event of triggering an application, a first file in a preset position of an input table of the application is loaded;
[0030] In step 102, in the case of loading a system sub-file in the first file, a first initialization configuration is performed by using a first initialization function of the first file.
[0031] In step 103, in the case of completing the first initialization configuration, a file segment required for starting the application is pre-read.
[0032] It should be noted that the data processing method proposed in the present disclosure can be applied to an electronic device, or can be applied to a server. Here, the electronic device can include a terminal device, such as a mobile terminal or a fixed terminal. The mobile terminal can include a mobile phone, a tablet computer, a notebook computer, etc. The fixed terminal can include a desktop computer, a smart television, etc. The server, as a kind of computer, can provide computing or application services for other clients (such as computers, smart phones, etc. terminal equipment or even large equipment such as train systems) in the network.
[0033] The data processing method in the embodiment of the present disclosure can be configured in a data processing device, which can be arranged in a server, or can also be arranged in an electronic device, and the present disclosure does not limit this.
[0034] It should be noted that the execution subject of the embodiments of the present disclosure can be, for example, a central processing unit (CPU) in a server or an electronic device in hardware, and can be, for example, a related background service in the server or the electronic device in software, and the present disclosure is not limited thereto.
[0035] During the starting process of the application program, the file fragments can include code and resource fragments that need to be loaded into the memory during the running of the application program. For example, the file fragments can include executable code of the application program, a dynamic link library (DLL), a configuration file, a resource file (such as an icon, a string, etc.), and the like.
[0036] It should be noted that the first starting event can be an event triggered by a user for the application program, for starting the application program. The process image file of the application program is a storage form of the program on a storage medium, such as a disk, and contains code, data, resources, and the like required for the program to run. In the embodiments of the present disclosure, the first starting event acting on the application program can be detected, and in a case where the first starting event is detected, the first file at the preset position in the input table of the application program can be loaded by the operating system, in a case where the system sub-file in the first file is loaded by the operating system, the first initialization configuration can be performed by using the first initialization function of the first file, and in a case where the first initialization configuration is completed, the file fragments required for starting the application program can be pre-read by the operating system. The input table can list the names and related information of other modules (such as DLL files) and their exported functions that the module depends on during running. When the operating system loads the process image file, the required dependent modules will be loaded according to the information in the input table, and the function addresses called in these modules are parsed, so as to ensure that the program can correctly call external functions and access resources. The input table can also be referred to as an import table, or a dynamic segment of the file.
[0037] Alternatively, when starting the application program, the operating system loads the application program into the memory according to the structure of the process image file, creates a process and an address space of the process, so that the program can run in the memory. The process image file is used to guide the operating system to allocate memory for the program, set the file structure, and load related resources, so as to ensure that the program can be executed correctly.
[0038] In some embodiments, the input table of the application program includes an input table of the process image file, which is a data structure in the process image file. The input table can list other modules (such as DLL files) and their exported function names and related information that the module depends on at runtime. When the operating system loads the process image file, it will load the required dependent modules according to the information in the input table and resolve the function addresses called in these modules, thereby ensuring that the program can correctly call external functions and access resources. The input table can also be referred to as an import table. The process image file can include an executable file or a DLL file.
[0039] For example, when the user triggers the first start event of the application program, the operating system finds and loads the first file according to the preset position in the input table of the process image file of the application program. It should be noted that the preset position refers to a position in the input table of the process image file of the application program, which is used to indicate the first file, such as a DLL file, that the operating system needs to prioritize to find and load when loading the application program. The input table can include information of all dependent files required by the application program, and the preset position can indicate the specific arrangement order of the dependent files in the input table. For example, the preset position can be set to the first few positions in the input table, such as the first 5 positions, or the first position, such as the first position. When the user triggers the first start event of the application program, the operating system will load the first file located at the preset position according to the indication of the preset position. For example, if the preset position is set to the first position in the input table, the operating system will first load the first DLL file listed in the input table, i.e., a first file; if the preset position is set to the first 3 positions, the operating system will load the first 3 DLL files listed in the input table, i.e., 3 first files. By setting the preset position, the key first file can be ensured to be loaded first when the application program starts. The preset position can be set as needed. For example, the preset position can be the first preset position in the input table. For another example, the preset position can be the first position in the input table.
[0040] Since the first file can be a file with a high position in an import table of a process image file of the application program (for example, can be a file with a highest position in the import table). Illustratively, the first file is before a C runtime library (CRT). Since the first file is a key file relied on by all components during startup, loading the first file in advance is crucial for subsequent application program startup. The C runtime library can include runtime 140.dll, uCRTbase.dll, and the like. The first file can be determined according to relevant information of the application program, and the key files relied on by different application programs during startup can be different. It should be noted that the relevant information of the application program can include attribute information of the application program, for example, the type of the application program.
[0041] In some embodiments, the operating system can load the first file into the memory by calling a function, and the like, where the calling function can include a LoadLibrary function. After loading is completed, system sub-files in the first file (such as other related DLL files that depend on the first file) are also loaded. For example, the first file can depend on some basic system DLL files, and these system sub-files are automatically loaded into the memory after the first file is loaded.
[0042] It should be noted that the system sub-file is a basic module in the operating system, and the first file can rely on the system sub-file to complete its own initialization during the loading process. Since the system sub-file is loaded earliest, the first file can be loaded and executed immediately after the system sub-file. In some embodiments, the first file (for example, app_elf.dll) can be a carrier of early loading framework of ntdll.dll, kernel32.dll, kernelbase.dll, and the like. Illustratively, the import table of the first file can only have ntdll.dll, kernel32.dll, and kernelbase.dll modules. The ntdll.dll is used to provide an interface between a user mode program and a Windows kernel, and contains an implementation of a system call; the kernel32.dll is used to provide core system functions, such as process and thread management, memory management, file operation, and the like; and the kernelbase.dll is a basic layer of Windows API, and is used to provide core system functions, and is a dependency of other DLLs.
[0043] The present disclosure ensures that the first file only depends on system sub-files by limiting the input table of the first file, thereby simplifying the dependency relationship, improving the loading efficiency, and ensuring that the first file can be loaded and executed in the early stage of process initialization. The first file is designed as a carrier of an early loading framework, so that the first file can be loaded in the early stage of process initialization. By limiting the input table of the first file to system sub-files, it can be ensured that the system sub-files have been loaded into the memory at the time of process startup, thereby allowing the first file to execute initialization logic in the early stage.
[0044] After completing the loading of the system sub-files of the first file, the first initialization function of the first file can be used for initialization configuration. The first initialization function, for example, a callback function, is called by the system after the first file is loaded, and is used to perform tasks related to the initialization of the first file, such as configuring the running environment, registering event processing functions, initializing internal data structures, etc., to ensure that the first file and its dependent system sub-files can correctly participate in the startup process of the application. The first initialization function in the preset callback table is defined in advance and is used to make necessary initialization settings after the file is loaded.
[0045] Alternatively, after completing the loading of the system sub-files of the first file, the first initialization function in the preset callback table of the first file can be used for initialization configuration. The preset callback table of the first file, for example, is a predefined data structure, and the first initialization function in the preset callback table, for example, a callback function, is called by the system after the first file is loaded, and is used to perform tasks related to the initialization of the first file, such as configuring the running environment, registering event processing functions, initializing internal data structures, etc., to ensure that the first file and its dependent system sub-files can correctly participate in the startup process of the application. The first initialization function in the preset callback table is defined in advance and is used to make necessary initialization settings after the file is loaded.
[0046] The present disclosure can ensure that the first file and the system sub-files dependent on the first file can participate in the subsequent application startup process in a correct state by calling the first initialization function in the preset callback table of the first file to perform related initialization operations.
[0047] After the first initialization configuration is completed, the operating system starts to pre-read the file segments required for starting the application, and by loading the first file in the preset position in the application process image file input table in advance, the first file can be included in the pre-reading process before the critical moment of pre-reading takes effect; after the system sub-file in the first file is loaded, the first initialization function in the preset callback table is used for initialization configuration to ensure that the necessary settings after file loading are completed in time and fully prepare for subsequent pre-reading operations; after the initialization configuration is completed, the file segments required for starting the application are pre-read, so as to cover more critical file loading links and solve the problem that some files cannot be included in the pre-reading process due to late pre-reading opportunity. It should be noted that the first file can be a key dependent file for starting the application, which can include a dynamic link library (DLL) file.
[0048] It should be noted that the file segments required for starting the application include determining the file segments required for starting the application and pre-reading the file segments required for starting the application, wherein the determination of the file segments and the pre-reading of the file segments can be two independent steps. For example, after the file segments required for starting the application are determined, the file segments required for starting the application can be pre-read to the cache space to complete the pre-reading of the file segments.
[0049] In some embodiments, in response to the first starting event of the application, the first execution parameter of the application executing the second starting event can be obtained. In other embodiments, in response to the first starting event of the application, in the case that the file segments required for starting the application are arranged at different positions of the disk, the first execution parameter of the application executing the second starting event can be obtained.
[0050] Wherein, the second starting event is triggered before the first starting event, and the first execution parameter can include associated data of the application executing the second starting event, such as the starting duration of the application based on the second starting event, the starting speed of the application based on the second starting event, etc.
[0051] It should be noted that the triggering of the second starting event means that the initiation action of the second starting event has occurred and the application has been running, for example, the relevant process has received a starting instruction or meets a starting condition, and the corresponding application or process has entered a running state, so that the first execution parameter of the application executing the second starting event can be obtained. In some embodiments, the first starting event and the second starting event can be two independent starting events, i.e., the starting events triggered at different times for the same application, for example, the first starting event is used to trigger the current starting of the application, and the second starting event is used to trigger the last starting of the application.
[0052] After the first execution parameter is acquired, the first target storage block can be determined from the current first array of structures based on the first execution parameter. It should be noted that the array of structures can include a global array of structures and a page frame number database (PFN database). The global array of structures is a global data structure in programming, used to store and share multiple structure data in the program range, and the PFN database is a data structure used by the operating system to track virtual allocation storage blocks and manage storage blocks.
[0053] The storage block is a memory area used by a program or operating system to store data. At the program level, it can be an element in the global array of structures, used to store specific structure data such as objects or data sets; at the operating system level, the storage block is an entry in the PFN database, representing a physical memory block allocated to a program or process, used to track its state and usage. For example, the storage block can be a physical page frame in the PFN database. The storage block can store code, data, or resources in the program, and can be a part of the memory in the system for the program to use. When the program needs memory, the operating system will allocate it from the free storage block and recycle it to the free list after release.
[0054] The PFN database can record detailed information of the storage block in the current memory through the page frame number entry (PFN Entry). The PFN Entry is a structure in the Windows operating system used to describe a physical page frame (Physical Page Frame). Each physical page frame has a unique number in memory, called the page frame number (PFN). The PFN Entry is an entry in the PFN Database (PFN Database) that stores detailed information about the physical page frame. Since each PFN Entry records detailed information about each storage block in the current memory, the PFN database can be used to obtain the status of the storage block in the current memory, and the required storage block can be filtered from the PFN database. Then, based on the storage block information, the file segments required to start the application program are confirmed.
[0055] In the embodiments of the present disclosure, after the first execution parameter is acquired, the first target storage block can be determined from the first array of structures based on the first execution parameter, and the file segments required to start the application program based on the first start event can be determined based on the storage block information of the first target storage block.
[0056] In the embodiments of the present disclosure, after the first execution parameter is acquired, the first target storage block can be determined from the first array of structure bodies based on the first execution parameter. For example, the first execution parameter can be parsed to extract key information in the first execution parameter, such as the startup duration, the startup speed, and the like of the application program based on the second startup event. Then, the key information in the first execution parameter is compared and matched with the PFN entries in the array of structure bodies to determine the storage block associated with the key information. For example, by analyzing the state and type of the memory storage block recorded in the PFN entry, the storage block with the access frequency greater than the preset frequency and / or the priority higher than the preset priority in the second startup event is found, so as to be determined as the first target storage block. Since the first target storage block determined based on this manner corresponds to the core executable code of the application program, the key DLL file, or the important resource file, and the like, the file segment determined based on the first target storage block can more ensure the normal startup of the application program.
[0057] In some embodiments, in a case where the first execution parameter includes the startup duration of the application program based on the second startup event, the first target storage block is determined from the current first array of structure bodies based on the first execution parameter, including: loading a key file of the application program based on the first startup event, and determining the loading time of the key file; determining a target time window based on the loading time of the key file and the startup duration; and determining the storage block with the loading time in the target time window in the first array of structure bodies as the first target storage block.
[0058] In the embodiments of the present disclosure, the key file of the application program based on the first startup event can be loaded, and the loading time of the key file can be determined. For example, the key file can include the executable file, the dynamic link library (DLL), the configuration file, and the resource file of the application program, and the like. For example, the key file can be the dynamic link library loaded earliest in the process of starting the application program based on the first startup event.
[0059] The loading time can include the time when the file is loaded into the memory. By monitoring and recording the loading time of the key file, basic data can be provided for the subsequent determination of the time window. It should be noted that the loading time is a time point, which is used to indicate the time when the file is loaded into the memory. For example, a dynamic link library is loaded into the system memory at 14:30:00 on July 7, 2025, and the time point is the loading time of the file.
[0060] In some embodiments, the loading time can be determined based on the timestamp variable in the PFN entry. For example, the timestamp variable can be determined as the loading time, or when the timestamp variable is updated, the minimum value of all variable values can be determined as the loading time.
[0061] It should be noted that the TimeStamp variable in the PFN entry can be used to confirm the key data of the storage block, wherein the TimeStamp variable is related to the time when the file segment enters the memory, and can be in seconds as a time unit. The TimeStamp variable can be used to indicate the time of the last operation of the current storage block. If the application is in a cold start state, the TimeStamp variable can be used to indicate the time when the file segment on the current storage block enters the memory for the first time.
[0062] For example, in the PFN entry, the TimeStamp variable records the time when the storage block is last accessed or modified. In the cold start process, the TimeStamp variable can be used to indicate the time when the file segment enters the memory for the first time. In the case of cold start, the operating system loads the necessary files and data into the memory, at which time the storage block is accessed for the first time, and the TimeStamp variable is set to this time. After that, if the storage block is accessed or modified again, the TimeStamp variable will be updated to the latest time.
[0063] In the embodiments of the present disclosure, after determining the loading time of the key file, the target time window can be determined based on the loading time and the startup duration of the application based on the second startup event. The startup duration refers to the total time from the triggering of the second startup event to the completion of the startup of the application. The target time window is a preset time range, which is used to filter the first target storage block.
[0064] In some embodiments, the target time window can be constituted by taking the loading time as a reference and taking the startup duration as a duration. Taking the key file as the earliest loaded dynamic link library in the process of starting the application based on the first startup event as an example, the loading time of the key file can be the time of the earliest loaded dynamic link library in the process of starting the application based on the first startup event. In other embodiments, the loading time can also be taken as a reference, and the startup duration can be adjusted, and the adjusted startup duration can be taken as a duration to constitute the target time window. In some embodiments, the startup duration can be adjusted as needed, for example, the startup duration can be adjusted according to the type of the application, so that the determined target time window is more matched with the application.
[0065] After determining the target time window, the storage blocks in the first structure array whose loading time is within the target time window are determined as the first target storage block.
[0066] Taking the key file as the earliest loaded dynamic link library in the process of starting the application based on the first startup event as an example, all storage blocks that enter the memory in the process of starting the application based on the second startup event can be filtered out based on the target time window, that is, the first target storage block.
[0067] It should be noted that the files required in each start-up process are the same for the same application. The disclosure can determine a target time window based on the loading time of the key files of the application loaded based on the first start-up event and the start-up duration of the application started based on the second start-up event, and screen the storage blocks in the first structure array based on the target time window to determine the first target storage block.
[0068] In some embodiments, determining the first target storage block from the current first structure array based on the first execution parameter includes: determining a reference list of the application; determining a candidate storage block from the first structure array according to a target path in the reference list; and determining the first target storage block from the candidate storage block based on the first execution parameter.
[0069] Exemplarily, the first structure array can be parsed to obtain all file information in the first structure array, and the key files of the application loaded based on the first start-up event and the loading time of the key files can be determined. The candidate storage block can be determined from the first structure array according to the target path in the reference list.
[0070] It should be noted that the reference list of the application can be equivalent to a whitelist mechanism, and the reference list includes the set target paths, such as the installation path of the application, the plug-in directory (including the cache directory) of the application, and part of the system directory. By setting the target path, the storage blocks related to the application can be effectively screened, and the interference of irrelevant storage blocks can be reduced.
[0071] Exemplarily, the candidate storage block can be determined from the first structure array according to the target path in the reference list, that is, the storage block located in the specified path is determined.
[0072] In some embodiments, the method further includes: determining the target path based on the attribute information of the application and / or the installation parameter of the application, and storing the target path to the reference list of the application; and updating the reference list of the application based on the second execution parameter of executing the first start-up event in the case that the application is successfully started based on the first start-up event.
[0073] In the embodiment, the target path can be determined based on the attribute information of the application and / or the installation parameter of the application, and the target path can be stored in the reference list of the application. It should be noted that the attribute information of the application can include, but is not limited to, the type, use, and developer of the application, and the installation parameter can include configuration information generated during the installation of the application. For example, the installation parameter can include the installation path, the plug-in directory, the cache directory, and the like. For example, the target path can be determined based on the attribute information of the application. For another example, the target path can be determined based on the installation parameter of the application. For another example, the target path can be determined based on the attribute information of the application and the installation parameter of the application.
[0074] In some embodiments, after obtaining the attribute information of the application, the attribute information of the application can be processed by a preset rule and algorithm to determine the target path. For example, different path templates can be preconfigured for different attribute information of the application, and after the attribute information of the application is determined, the target path can be determined based on the attribute information of the application and the preconfigured path template. For example, the path template can be preconfigured based on the type of the application, and the target path can be determined based on the preconfigured path template when the attribute information of the application is the type of the application. For example, for office software, the preconfigured path template can be C:\Program Files\<application name> or C:\Users\<username>\AppData\Roaming\<application name>.
[0075] In some embodiments, after obtaining the installation parameter of the application, the installation parameter of the application can be processed by a preset rule and algorithm to determine the target path. For example, the installation path can be parsed, and at least part of the installation path can be determined as the target path. For example, for the application App1, the target path can include the installation path (such as “C:\Program Files\App1”), the plug-in directory (such as “C:\Users<username>\AppData\Roaming\App1\Plugins”), and the cache directory.
[0076] In some embodiments, the attribute information and the installation parameter of the application can be processed by a preset rule and algorithm to determine the target path. For example, the target path determined based on the attribute information of the application and the target path determined based on the installation parameter of the application can be stored in the reference list as the target path.
[0077] By applying the attribute information of the application program and / or the installation parameters of the application program, the location range of the files related to the starting of the application program can be preliminarily determined, and the paths are stored as an initial reference list.
[0078] In the subsequent starting process of the application program, after the application program is successfully started based on the first starting event, the reference list of the application program can be updated based on a second execution parameter for executing the first starting event. The second execution parameter can include the file path actually accessed in the starting process, the access frequency, the loading time, and the like. For example, if it is found that the application program accesses the files in a certain system directory more than a preset number of times when starting, or the access amount of the files in a certain plug-in directory is greater than a preset access amount, the paths can be added to the reference list to update the reference list. At the same time, for the paths in the reference list that are accessed less than a preset number of times in the starting process or are no longer used, the priority of the path in the reference list can be reduced, or the path can be deleted from the reference list to update the reference list.
[0079] Through the technical solution of the present disclosure, the reference list can dynamically adapt to the actual use of the application program, continuously optimize the accuracy and efficiency of the pre-reading, and ensure that the necessary file segments can be more accurately pre-read in the subsequent starting, so as to improve the starting speed of the application program.
[0080] After the candidate storage block is determined, the first target storage block can be determined from the candidate storage block.
[0081] Here, after the candidate storage block is determined, the first target storage block can be selected and determined from the candidate storage block based on the first execution parameter, that is, the storage block that needs to be loaded by the application program in the subsequent starting is obtained. Through the screening method of the white list mechanism, the accuracy and efficiency of the pre-reading can be effectively improved, the waste of system resources is reduced, and the pre-reading speed and performance are ensured.
[0082] In the embodiments of the present disclosure, by analyzing the files loaded in the previous starting process and the corresponding file segments, the file segments that the application program will need to read can be determined in advance before the next starting. In this way, in the subsequent starting process, the operating system can prepare and optimize the loading process of the files in advance, thereby improving the starting efficiency of the application program.
[0083] In some embodiments, a PFN database snapshot can be obtained, and the first target storage block can be selected from the first array of structures based on the PFN database snapshot. The PFN database snapshot refers to a record of the content of the PFN database at a certain moment, and can be used for debugging and analyzing the memory usage.
[0084] Taking a target time window with a start time T1 and an end time T2 as an example, after obtaining a PFN database snapshot, the disclosure can filter out, from the snapshot, a storage block whose loading time is between T1 and T2 and that satisfies at least one of the following conditions:
[0085] The target storage block is located in a paged pool.
[0086] The target storage block is located in a standby list.
[0087] The storage content of the target storage block satisfies a preset format.
[0088] The target storage block has been mapped to a target process.
[0089] It should be noted that, in the memory management of an operating system, the paged pool (Paged Pool) is a kernel-mode memory pool used to store data that can be paged. The memory in the paged pool can be swapped to a paging file on a disk for reloading into physical memory when needed. Through the paged pool, the operating system can more flexibly manage memory resources, especially when the physical memory is tight.
[0090] In the memory management of a Windows operating system, the memory region in standby means that the storage block is in a standby list (Standby List). The standby list is used in the memory management of Windows to store storage blocks that have been released but whose contents are still retained. These storage blocks can be quickly reallocated to processes that need memory, thereby improving the performance of the system.
[0091] The storage content of the target storage block satisfying a preset format includes that the storage content of the target storage block is a file or an image. In memory management, a file can be mapped to memory for quick access to its content, which is called a memory-mapped file (Memory-Mapped File). Through a memory-mapped file, the content of the file can be directly read and written in memory without explicit file I / O operations, thereby improving performance. An image refers to the representation of an executable file (such as an.exe file) or a dynamic link library (DLL) in memory. When an operating system loads an executable file, it maps the content of the file to memory to form an image. This image contains the code and data of the program for the CPU to execute.
[0092] In an operating system, each process has its own virtual address space, and a physical memory storage block is an actual hardware memory unit. In order for a process to access physical memory, the operating system needs to map the virtual address to the physical address. This mapping process is handled by the memory management unit (MMU). The target storage block having been mapped to the target process can include that the target storage block has been or has been mapped to the target process.
[0093] In the embodiments of the present disclosure, the PFN database snapshot can be acquired, and the target storage block can be screened out. The storage block loaded within the target time window (T1 to T2) and meeting specific conditions can be screened out from the PFN database snapshot. The conditions can include that the storage block is located in the paging pool or the standby list, the content meets the preset format (such as a file or an image), and the storage block has been mapped to the target process. Not only can the use efficiency of the memory be improved, but also the resource can be flexibly managed by the operating system when the memory is tight, the startup speed of the application program can be accelerated, and unnecessary file I / O operations can be reduced. The performance can be improved through the memory mapping file mechanism. The process can quickly access the required physical memory storage block, and thus the overall system performance and user experience can be improved.
[0094] After the storage block information of the first target storage block is determined, the file segment required for starting the application program based on the first startup event can be determined based on the storage block information of the first target storage block.
[0095] In some embodiments, the file segment required for starting the application program based on the first startup event is determined based on the storage block information of the first target storage block, including determining the file segment required for starting the application program based on the first startup event based on the size of the first target storage block and the cluster size of the file system.
[0096] In the embodiments of the present disclosure, after the first target storage block is determined, the storage block information of the first target storage block can be acquired, including the size of the first target storage block, the memory address, and the like. In combination with the cluster size of the file system, the file name and the offset corresponding to the first target storage block can be found from the file cache information.
[0097] It should be noted that the offset refers to the starting position of the file segment in the file, the distance relative to the beginning of the file, and is usually measured in bytes. For example, if the offset of a file segment is 1024 bytes, it means that the file segment starts from the 1024th byte of the file. Through the offset, the part to be read in the file can be accurately located. The cluster size of the file system is the basic unit of the file system for allocating storage space, and can be a fixed size (such as 4 KB, 8 KB, etc.). The size of the first target storage block is also fixed (such as 4 KB). Through the size of the first target storage block and the cluster size of the file system, the range of the file segment to be read in the file can be determined. For example, if the size of the first target storage block is 4 KB, and the cluster size of the file system is also 4 KB, then one first target storage block corresponds to one cluster, and thus the starting position and length of the file segment can be directly determined. According to the correspondence between the first target storage block and the file cluster, in combination with the offset, the accurate position of the file segment can be calculated, and thus the file segment required for starting the application program can be determined.
[0098] Based on the size of the first target storage block, the cluster size of the file system and the calculation method of the offset, the part of the file that needs to be loaded can be accurately located, unnecessary data reading is avoided, and the startup efficiency is improved. At the same time, through the file name and offset in the file cache information, the corresponding file segment can be quickly found, and the file loading process in the startup process is further optimized.
[0099] In some embodiments, after determining the file segments required to start the application, a corresponding registry item can be generated for use in the pre-reading stage. Illustratively, the determined file segments and the information related to the file segments are stored in a designated location in the registry. The information related to the file segments can include the path, offset, size and priority of the file segments, and other key data. Before entering the pre-reading stage, the operating system reads the registry item and loads these file segments into memory in advance according to the information related to the file segments in the registry.
[0100] The present disclosure can effectively reduce the disk I / O operation during application startup and improve the startup efficiency by loading the file segments in advance in the pre-reading stage.
[0101] In some embodiments, in the case where the application is successfully started based on the first startup event, the method further includes: in response to the end of the application startup, determining a second array of structures after the end of the startup; and updating the first array of structures based on the difference information between the first array of structures and the second array of structures to obtain an updated first array of structures.
[0102] Illustratively, a snapshot of the first array of structures, i.e., a state table containing all current memory storage block information, can be recorded before the application is started. After the application is started, a snapshot of the second array of structures at this time is recorded again, also forming a state table containing all current memory storage block information. By comparing the changes in storage block information in the two snapshots, such as adding, modifying or releasing storage blocks, the specific operations on the memory storage blocks during the application startup can be identified. Then, the first array of structures is updated according to the difference information to reflect the changes in the memory storage blocks after the application startup.
[0103] In this way, the updated first array of structures can be used in subsequent application startups to more accurately predict and preload the required file segments. For example, when analyzing a virus sample, the initial state of the PFN database can be recorded before the sample is run, and the final state can be recorded again after the sample is run. By comparing the differences between the two states, the system can identify the modifications to the memory storage blocks made by the virus sample during the running process, and then update the PFN database, so that in subsequent analysis or processing, the system can more effectively identify and respond to similar sample behaviors.
[0104] By updating the structure array in real time, the accuracy and real-time performance of the data in the structure array can be ensured, and the accuracy of the determined file segment is improved.
[0105] In some embodiments, in the case of successfully starting the application based on the first start event, the method further comprises: in response to triggering a third start event of the application, determining a second target storage block from the updated first structure array based on a second execution parameter of executing the first start event; and determining a file segment required for starting the application based on the third start event based on the storage block information of the second target storage block.
[0106] In the embodiments of the present disclosure, in the case of successfully starting the application based on the first start event, if a third start event of the application is triggered again, in response to triggering the third start event of the application, a second target storage block is determined from the updated first structure array based on a second execution parameter of executing the first start event. For example, the second execution parameter includes relevant information such as the start duration, and the second target storage block related to the third start event is determined from the updated first structure array by combining the latest storage block information in the updated first structure array.
[0107] After the second target storage block is determined, the file segment required for starting the application based on the third start event can be determined based on the storage block information of the second target storage block. The storage block information usually includes the size, memory address, and access frequency of the storage block, and by analyzing these information, the file segment required for starting the application can be accurately located.
[0108] For example, after the second target storage block is determined, the storage block information of the second target storage block can be obtained, including the size and memory address of the second target storage block. In combination with the cluster size of the file system, the file name and offset corresponding to the second target storage block can be found from the file cache information.
[0109] It should be noted that the offset refers to the starting position of the file segment in the file, the distance relative to the beginning of the file, and is usually measured in bytes. For example, if the offset of a file segment is 1024 bytes, it means that the file segment starts from the 1024th byte of the file. Through the offset, the part to be read in the file can be accurately located. The cluster size of the file system is the basic unit of storage space allocated by the file system, which can be fixed size (such as 4KB, 8KB, etc.). The size of the second target storage block is also fixed (such as 4KB). Through the size of the second target storage block and the cluster size of the file system, the range of the segment to be read in the file can be determined. For example, if the size of the second target storage block is 4KB and the cluster size of the file system is also 4KB, then one second target storage block corresponds to one cluster, so that the starting position and length of the file segment can be directly determined. According to the correspondence between the second target storage block and the file cluster, combined with the offset, the exact position of the file segment can be calculated, so as to determine the file segment required for starting the application program.
[0110] Based on the calculation method of the size of the second target storage block, the cluster size of the file system and the offset, the part to be loaded in the file can be accurately located, unnecessary data reading is avoided, and the starting efficiency is improved. At the same time, through the file name and the offset in the file cache information, the corresponding file segment can be quickly found, and the file loading process in the starting process is further optimized.
[0111] Through the implementation of the present disclosure, the first structure array is continuously updated and continuously optimized, so that the required file segment can be preloaded more efficiently at each start, and the starting efficiency is improved.
[0112] In some embodiments, during the process of starting the application program, there are multiple processes, and for each process of the application program, the file segment corresponding to the process is determined in the manner of any of the above embodiments, and then the file segment of the application program is obtained. Illustratively, based on the storage block information of the first target storage block, the file segment required for starting the application program based on the first starting event is determined, including: for any process in the process of starting the application program, determining the file segment required by the process based on the storage block information of the first storage block, and then determining the file segment required for starting the application program.
[0113] Illustratively, if the file segment required by the process in the stage from P1 to P2 is needed, the start time (t1) of the stage and the completion time (t2) of the stage can be determined, and the first target storage block in the time period (target time window) is selected from the first structure array, and then the file segment required for running the process is determined based on the storage block information of the first target storage block, and then the file segment required for starting the application program is determined.
[0114] By determining the target time window of the file segment required by the process in the specific stage (from the start time t1 to the completion time t2), the first target storage block in the time period can be accurately screened from the first structure array, and based on the storage block information of the target storage block, the file segment required by the running process is determined, and then based on all the file segments required by the process running, the file segment required to start the application program is determined.
[0115] In any of the above embodiments, taking the structure array as a page frame database as an example, the target page storage block can be a target page, i.e., a target physical page frame.
[0116] In the first aspect, since the data in the first structure array can indicate the specific details of the process work, by determining the first target storage block from the first structure array and determining the file segment required to start the application program based on the storage block information of the first target storage block, the accurate acquisition of the file segment can be realized; in the second aspect, compared with the related art which determines the file segment by relying on the system event tracking mechanism or the system call function, the additional system resource consumption caused by monitoring and processing system-level events can be reduced, and the resource utilization efficiency in the application program starting process is improved.
[0117] In any of the above embodiments, taking the structure array as a page frame database as an example, the target storage block can be a target page, i.e., a target physical page frame.
[0118] In some embodiments, after determining the file segment required to start the application program based on the first starting event, the method further includes: loading the first file in the preset position of the input table of the application program; in the case that the system sub-file in the first file is loaded, performing first initialization configuration by using the first initialization function of the first file; in the case that the first initialization configuration is completed, pre-reading the file segment required to start the application program. Illustratively, after determining the file segment required to start the application program, in the case that there is a target component in the process of starting the application program, the file segment is pre-read according to the pre-reading strategy of the present application. The pre-reading strategy includes: loading the first file in the preset position of the input table of the application program; in the case that the system sub-file in the first file is loaded, performing first initialization configuration by using the first initialization function of the first file; in the case that the first initialization configuration is completed, pre-reading the file segment required to start the application program.
[0119] Exemplarily, in response to a first starting event triggering the application, in a case where there is a target component in the process of starting the application, a first file at a preset position in an input table of the application is loaded; in a case where a system sub-file in the first file is loaded, a first initialization configuration is performed by using a first initialization function of the first file; in a case where the first initialization configuration is completed, a file segment required for starting the application is pre-read.
[0120] Here, after the file segment required for starting the application is determined, a pre-reading strategy can be selected according to whether there is a target component in the starting process. The target component can also be referred to as an effective component, and can include a component having a preset function. For example, the target component can be a module having a key influence on starting the application or a module having a relatively high stability requirement, and the target component can affect a dependency relationship and an initialization process in the starting process. If there is a target component in the starting process, the file segment is pre-read according to the pre-reading strategy of the present application.
[0121] In some embodiments, different types of components have corresponding pre-reading strategies respectively. Exemplarily, different types of components have different stability requirements, and the corresponding pre-reading strategies are also different. Exemplarily, different types of components have different importance for starting the application, and the corresponding pre-reading strategies are also different.
[0122] The present disclosure selects a corresponding pre-reading strategy according to whether there is a target component, so as to adapt to different starting scenarios, and can realize efficient pre-reading of a file segment required for starting an application. Not only can the starting efficiency of the application be improved, the time-consuming of disk I / O operations can be reduced, and the user experience can be improved, but also various complex and changeable system environments and application starting requirements can be coped with.
[0123] In some embodiments, pre-reading a file segment required for starting an application to a cache space includes: loading a first file at a preset position in an input table of a process image file of the application; in a case where a system sub-file in the first file is loaded, performing a first initialization configuration by using a first initialization function in a preset callback table of the first file; in a case where the first initialization configuration is completed, pre-reading the file segment required for starting the application, and pre-reading the file segment required for starting the application to the cache space.
[0124] In some embodiments, after the pre-reading of the file segment required for starting the application is completed, the method further includes:
[0125] loading a second initialization function;
[0126] performing a second initialization configuration based on the second initialization function, and starting the application based on the pre-read file segment in a case where the second initialization configuration is completed.
[0127] It should be noted that the second initialization function can belong to a runtime library. The runtime library includes a pre-compiled code module that is called when the application is running, and can provide various basic function supports required by the application at runtime, and assist the application to complete various operations.
[0128] For example, the CRuntimeLibrary (C Runtime Library) of the C language, also known as the C runtime library, is a basic library for running an application, and includes standard functions and functions for supporting basic operations and running environments of a program, and can include a series of function functions such as file operation functions (such as fopen, fread for opening and reading files), memory management functions (such as malloc, free for dynamically allocating and releasing memory), etc. When the written C program is running, the functions in the C runtime library can be called to implement corresponding file operations, memory management and the like. For another example, the runtime library of the NETFramework can include classes and methods for supporting object-oriented programming, exception handling, data access and the like, and the application developed based on the NETFramework can complete tasks based on the contents in the runtime library during running, and ensure that the application runs according to the preset logic.
[0129] In the embodiments of the present disclosure, after the pre-reading of the file segments required for starting the application is completed, the operating system will continue to load the second initialization function, for example, continue to load the second initialization function in the runtime library, and exemplarily, the operating system will continue to load the second initialization function in the C runtime library, and provide support for further initialization of the application.
[0130] Taking the case that the second initialization function belongs to the C runtime library as an example, the present disclosure can start the application based on the pre-read file segments after the second initialization configuration based on the second initialization function is completed. The second initialization configuration is used to set and adjust the environment of the C runtime library, for example, to initialize memory management, file operation, input / output system, etc., so as to ensure that the application can correctly use the functions provided by the C runtime library when running, thereby providing guarantee for stable running of the application.
[0131] It should be noted that the first initialization function is a function in the preset callback table of the first file, which is used to perform initialization operations related to the first file after the first file and its system subfiles are loaded, such as configuring the running environment of the file, registering the callback function, initializing the data structure, and the like, to ensure that the first file can correctly participate in the startup process of the application program; and the second initialization function is located in the C runtime library, which is used to set and adjust the environment of the C runtime library after the file segment is pre-read, such as initializing the memory management, file operation, input / output system, and the like, to provide basic support for the stable running of the application program. The first initialization configuration is mainly for the first file and its dependent system subfiles, to ensure that they can work normally in the pre-reading stage; and the second initialization configuration focuses on the C runtime library, to prepare for the overall running of the application program.
[0132] After the second initialization configuration is completed, the operating system starts the application program by using the pre-read file segment, wherein the pre-read file segment includes various resources and data required for the running of the application program, such as code segments, data segments, configuration files, resource files, and the like. By pre-reading the file segment, the delay of file loading can be reduced when the application program is formally run, the startup efficiency is improved, the application program can quickly enter the running state, and the startup process is more smooth.
[0133] In some embodiments, in response to triggering the first startup event of the application program, a first file located at a preset position in an input table of a process image file of the application program is loaded, including:
[0134] In response to triggering the first startup event of the application program, a locking operation is performed on a global lock.
[0135] In a case where the locking operation is completed, the first file is loaded into the virtual memory of the current first process.
[0136] In some embodiments, in a case where the second initialization configuration is completed, the application program is started, including:
[0137] In a case where the second initialization configuration is completed, an unlocking operation is performed on the global lock.
[0138] In a case where the unlocking operation is successfully performed, the application program is started based on the pre-read file segment.
[0139] It should be noted that the global lock is a mechanism for controlling concurrent access, and by locking, it can be ensured that the loading process of the first file will not be disturbed in a multi-threaded or multi-process environment.
[0140] In the embodiments of the present disclosure, in response to a first starting event of triggering an application program, the operating system performs a locking operation on the global lock, and after the locking operation is completed, the first file is loaded into the virtual memory of the current first process, so as to avoid resource conflicts and data inconsistency problems that may occur when multiple processes or threads simultaneously load the first file.
[0141] After the second initialization configuration is completed, the global lock is unlocked. The unlocking operation is to release the resources occupied by the previous locking, and allow other processes or threads to continue to access the related resources. In the case of completing the second initialization configuration, the global lock is unlocked. In the case of successfully performing the unlocking operation, the application program is started based on the pre-read file segment. After the unlocking operation is completed, the pre-read file segment is used to start the application program. Since the file segment has been loaded into the memory in the pre-reading stage, when the application program is started, the required resources can be quickly obtained from the memory, greatly reducing the time of reading data from the disk, thereby improving the starting speed of the application program.
[0142] In some embodiments, loading the first file into the virtual memory of the current first process comprises:
[0143] In the case of determining that the first process has not loaded the file segment required for running based on the process information in the process environment block, the first file is loaded into the virtual memory of the first process, and in the case of loading the first file into the virtual memory of the first process, the process information in the process environment block is updated based on the process information of the first process.
[0144] It should be noted that the process environment block (Process Environment Block, PEB) is used to store information related to the process, which can include key information of the process, such as module loading information (including base addresses of executable files and dynamic link libraries), environment variables, process parameters, memory allocation information, heap information, debugging information, etc. The file segment required for running includes determining the file segment required for running and loading the file segment required for running.
[0145] When the first file is loaded into the virtual memory of the current first process, the present disclosure first determines whether the first process has loaded the file segment required for running based on the process information in the process environment block. If it is determined according to the record in the process environment block that the first process has not loaded the file segment required for running, a loading operation is performed to load the first file into the virtual memory of the first process.
[0146] In the case of loading the first file into the virtual memory of the first process, the process information in the process environment block can be updated based on the process information of the first process, so that the process environment block can accurately reflect the current actual state of the first process, including the key information such as the loaded file. By updating the process information in the process environment block in a timely manner, the life cycle and resource usage of the first process can be better tracked and managed.
[0147] In some embodiments, in the case of determining that the first process does not load the required file segment based on the process information in the process environment block, the first file is loaded into the virtual memory of the first process, including:
[0148] In the case that the first process does not load the required file segment, and the process image file includes the first file, the first file is loaded into the virtual memory of the first process.
[0149] In some embodiments, in the case that the first process does not load the required file segment, and the disk storing the process image file does not include the file segment required by the first process, a prompt information of loading failure is output.
[0150] Here, after determining that the first process does not load the required file segment based on the process information in the process environment block, it is further determined whether the process image file contains the first file. If the first process does not load the required file segment, and the process image file does indeed contain the first file, the first file can be loaded into the virtual memory of the first process.
[0151] In the case that the first process does not load the required file segment, and the disk storing the process image file does not include the file segment required by the first process, a prompt information of loading failure is output, so that the user or administrator can be promptly fed back when the key file cannot be loaded, facilitating problem troubleshooting and solution. When detecting that the necessary file segment is missing in the disk, the prompt information can remind the user to take appropriate measures, such as checking whether the file is damaged, whether it is mistakenly deleted, or whether it needs to be reinstalled related components, etc., to ensure that the application program can have a clear prompt when encountering file loading problems.
[0152] In some embodiments, the file segment required by the starting application program is pre-read, including:
[0153] In the process of pre-reading the second file required by the starting application program, in the case that an interruption occurs when loading the first file segment of the second file, an interruption event is triggered;
[0154] In response to triggering the interruption event, the reading request of the first file segment and the reading request of the second file segment in the second file are merged to obtain a target request;
[0155] read the first file segment and the second file segment based on the target request.
[0156] In the process of pre-reading the second file required for starting the application, the second file may be interrupted. For example, due to disk reading errors, file system damage or other system abnormalities, the pre-reading operation cannot be completed smoothly. For another example, when loading a certain file segment of the second file, the file segment is already in the cache, at this time, the requests for each file segment of the second file are respectively split, and new requests may be inserted between the respective requests by other processes, resulting in discontinuity of each file segment, and ultimately resulting in failure of the expected continuous IO.
[0157] The present disclosure triggers an interruption event in the case of interruption of the second file, and in response to triggering the interruption event, merges the reading request of the first file segment and the reading request of the second file segment adjacent to the first file segment to obtain a target request; and reads the first file segment and the second file segment based on the target request.
[0158] As shown in Figure 2 Assume that the second file (for example, gdi32.dll) has four file segments, namely file segment A, file segment B, file segment C and file segment D. The four file segments are required in the process of starting the application, and among the four file segments, one file segment B has been loaded into the system cache, that is, the file segment B has been used by other processes, but the file segment A, the file segment C and the file segment D have not been loaded into the cache.
[0159] In the above case, if a reading request for the four file segments of the file segment A, the file segment B, the file segment C and the file segment D is initiated in the application layer, when the reading request is sent to the system cache, it will be split into two reading requests, because the file segment B is already in the cache, so the reading request is respectively split into a first reading request for the file segment A and a second reading request for the file segment C and the file segment D. After the reading request is split, the first reading request is stored in the request queue (IO queue) of the file system, and then the second reading request is also stored in the request queue (IO queue) of the system.
[0160] However, if a new request is inserted between the first reading request and the second reading request by other processes, because there is only one request queue in the entire system, if a reading request is split into two and respectively inserted into the request queue, it is possible that the new request is inserted between the first reading request and the second reading request by other processes, resulting in discontinuity of each file segment, and ultimately resulting in failure of the expected continuous IO.
[0161] For example, the corresponding read disk order becomes reading file segment A based on the first read request, reading other data based on other requests between the first read request and the second read request, and reading file segment C and file segment D based on the second read request, resulting in discontinuous file segments.
[0162] In some embodiments, in the case of an interruption in loading the first file segment of the second file, the interruption event is triggered, including: in loading the first file segment of the second file, if it is determined that the first file segment exists in the system cache, it is determined that the first file segment has been used by other processes, at this time, it is determined that an interruption occurs, and the interruption event can be triggered.
[0163] In other embodiments, the interruption event can be triggered by file mapping. Illustratively, after the file mapping maps the file segment to the virtual address space, a page fault interruption is triggered when the process accesses a storage block (e.g., a page of physical memory) that has not been loaded into the physical memory, i.e., the interruption event is triggered. For example, the application program can specify the virtual address range to be accessed in advance based on the PrefetchVirtualMemory interface, and then determine whether to trigger the interruption event.
[0164] In the embodiments of the present disclosure, by triggering the interruption event when pre-reading the file segments required by the application program, the read requests of the first file segment and the second file segment are combined to form a target request, and the pre-reading is performed based on the target request. On the one hand, the number of IO operations in the pre-reading process can be reduced on the basis of ensuring the continuity of the file segments, the pre-reading efficiency is improved, the consumption of system resources is reduced, and the starting speed of the application program is improved; on the other hand, when an interruption occurs in the pre-reading process, the pre-reading operation can be effectively resumed and continued, the integrity of the file segments required by the application program at the start is ensured, and the application program startup delay caused by the interruption in the pre-reading is reduced.
[0165] In some embodiments, in the case of completing the first initialization configuration, the file segments required for pre-reading the application program include:
[0166] In the case of completing the first initialization configuration, the file segments required for running the second process are pre-read;
[0167] In the case of completing the file segments required for running all processes of the application program, it is determined that the pre-reading of the application program is completed.
[0168] In the case of completing the first initialization configuration, the operating system starts to pre-read the file segments required by the application. For an application containing multiple processes, not only the file pre-reading of the current first process is involved, but also the pre-reading of the file segments required by the second process. In some embodiments, the system identifies and locates the key files and resources relied on by the second process during the startup and running process, which can include: dependent DLL files, configuration files, data files, etc. By pre-reading these file segments in advance, it can be ensured that the required files of the second process exist in the memory when the second process starts, thereby reducing the startup delay of the second process.
[0169] In the case of completing the file segments required by all processes of the application, it is determined that the pre-reading of the application is completed. The present disclosure can continuously monitor and manage the pre-reading operation until the file requirements of all related processes are met. When the file segments of all processes are successfully pre-read and stored in the memory, the pre-reading task can be marked as a completed state. In turn, it ensures that the startup process of the entire application can be efficient and smooth, since all necessary file resources have been prepared in advance, the various components of the application can be quickly started without waiting for the file to be loaded from the disk, thereby improving the startup speed of the application.
[0170] In some embodiments, the method further comprises:
[0171] Encapsulating the system sub-file in the initial file of the application;
[0172] Adding a preset callback table including the first initialization function to the initial file to obtain a first file;
[0173] Adding the first file to a preset position of an input table of the process image file.
[0174] In the development stage of the application, in order to ensure that the first file can be loaded at the appropriate time during the startup process of the application, the input table of the process image file needs to be configured. In some embodiments, the system sub-file can be encapsulated in the initial file of the application, and a preset callback table including the first initialization function can be added to the initial file to obtain a first file, and then the first file can be added to a preset position of an input table of the process image file.
[0175] Exemplarily, the system files required for starting the application can be screened to determine the system sub-files necessary for starting the application, and the system sub-files are encapsulated into the initial file to construct an initial file framework containing the basic components. Then a preset callback table (for example, a TLS callback table) is created, a first initialization function containing initialization logic is added to the preset callback table, and the initial file integrated with the preset callback table is inserted into the preset position of the input table of the process image file, so as to ensure that the system can preferentially identify and load the first file when the process is loaded. The preset callback table can execute the corresponding functions in a preset order when the application is started, thereby realizing the control of the application initialization process.
[0176] In some embodiments, after the system sub-files are determined, the initial file can be compiled. Then the initial file generated by the compiler can be modified to add a preset callback table to the initial file. The preset callback table allows the specified callback function to be automatically executed when the file is loaded into the process, thereby realizing early initialization. The TLS callback mechanism is a mechanism used in the Windows system to execute specific code when the file is loaded and unloaded. By adding a TLS callback table in the resource part of the file, it can be ensured that the specified callback function is automatically called when the file is loaded. The function (for example, EarlyInitialize) for performing early initialization is added to the TLS callback table, so that when the first file is loaded into the process, the system automatically calls the callback function to execute the early initialization logic.
[0177] After the first file is obtained, the process image file (for example, an executable file.exe) generated by the compiler can be modified to add a first file input item in the input table of the process image file. The input table defines the list of files that need to be loaded when the process is started. By modifying the input table, it can be ensured that the first file is loaded when the process is created.
[0178] In some embodiments, the loading order of the first file can be defined by modifying the order of the input table or reorganizing the entries of the input table. For example, in the input table, the input item of the first file is adjusted to the frontmost position. By adjusting the order of the input table, it can be ensured that the first file is the first file to be loaded, thereby ensuring the preferential execution of the early initialization logic.
[0179] Exemplarily, a dynamic link library module named app_elf.dll, i.e., an initial file, can be created, and the input table of the initial file only contains three DLLs of ntdll.dll, kernel32.dll and kernelbase.dll. The initial file is designed as a carrier of an early loading framework, which means that it will be loaded in an early stage of process initialization. A function for performing early initialization, i.e., a first initialization function, is defined and exported in the initial file, so as to enable other modules to call the function. This mechanism allows specific initialization logic to be performed in an early stage of process startup. Then the initial file generated by the compiler is modified to add a TLS callback table and add the function for performing early initialization to the TLS callback table, to obtain a first file. The process image file generated by the compiler can also be modified to add a first file input item in the input table of the process image file and adjust the input order of the first file to the first position.
[0180] The preset callback table can contain the first initialization function. The first file is placed in a preset position of the input table of the process image file, so that the first file and the callback function thereof can be loaded and executed in an early stage of application startup, and the first file in the preset position can be executed before the CRT. In this way, the application can load and initialize key components in a predetermined order at startup, thereby optimizing the pre-reading process, improving the startup efficiency, ensuring the efficiency and stability of the startup process, and the customized configuration of the input table of the process image file is an important basis for optimizing the pre-reading, so that the application can fully utilize system resources during the startup process and reduce unnecessary delay.
[0181] Figure 3 is a flowchart of another data processing method according to an exemplary embodiment. As shown in Figure 3 the method mainly includes the following steps:
[0182] In step 301, in response to a first startup event of an application, a global lock is locked.
[0183] Here, in response to the first startup event of the application, the operating system will lock the global lock, and after successfully performing the locking operation, the first file will be loaded into the virtual memory of the current first process, which can avoid resource conflicts and data inconsistency problems that may occur when multiple processes or threads load the first file at the same time.
[0184] In step 302, it is determined whether the first process has loaded a file segment required for running.
[0185] Here, if the first process does not load the file segment required for running, step 303 is performed.
[0186] In step 303, it is determined whether the first file is included in the disk storing the process image file.
[0187] Here, in the case where the file segment required for running the first process is included in the disk storing the process image file, step 304 is performed. In the case where the file segment required for running the first process is not included in the disk storing the process image file, it is determined that the loading fails. At this time, a prompt information of the loading failure can be output.
[0188] In step 304, the first file is loaded to the virtual memory of the first process.
[0189] Here, in the case where the first file is loaded to the virtual memory of the first process, step 305 can also be performed.
[0190] In step 305, the process information in the process environment block is updated based on the process information of the first process.
[0191] In step 306, other files associated with the first file in the input table are loaded.
[0192] Exemplarily, for the currently loaded file (e.g., the first file), the loader parses the input table, determines other files dependent on the first file, and recursively loads the dependent files, so as to ensure that all necessary modules (e.g., files) are loaded into the memory, so that the application program can be executed correctly.
[0193] In step 307, the first initialization configuration is performed by using the first initialization function in the preset callback table of the first file.
[0194] Exemplarily, in the process of loading the file, if the file contains a TLS callback table, the corresponding callback function is automatically called by the system.
[0195] In step 308, the second initialization function in the C runtime library is loaded, and the second initialization configuration is performed based on the second initialization function.
[0196] Here, after the loading of the first file and the dependent item parsing are completed, the loader initializes the C runtime library (CRT). The C runtime library is a basic library for running the application program, and contains standard functions and functions for supporting the basic operation and running environment of the program. After the pre-reading of the file segment required for starting the application program is completed, the operating system continues to load the second initialization function in the C runtime library, to provide support for the further initialization of the application program.
[0197] In step 309, the global lock is unlocked in the case that the second initialization configuration is completed.
[0198] Exemplarily, a main function (e.g., DLLMain function) for file management can be invoked to execute the initialization code of the file (DLL). After the execution of the main function, the loader unlocks the global lock to indicate that the loading process is completed. At this time, the file is successfully loaded and can be used by other parts in the process.
[0199] In the embodiments of the present disclosure, the timing of performing the first initialization configuration by the first initialization function in the preset callback table of the first file is after loading the other files associated with the first file in the input table of the process and before loading the C runtime library. In this way, the loading of the first file and the other files associated with the first file does not depend on the C runtime library, and more files can be loaded before the callback.
[0200] Further, the loading of the C runtime library is after the preset callback table, and the functions of the C runtime library are not used when the preset callback table performs the callback operation. In this way, the pre-reading can be performed immediately after the first file including the system sub-file (e.g., kernel33 and ntdll) is loaded, which greatly advances the time point of the pre-reading, and more dependencies can be included in the pre-reading process, wherein the dependencies can include the file segments required to start the application.
[0201] Figure 4 is a block diagram of a data processing apparatus according to an exemplary embodiment. As shown in Figure 4 the data processing apparatus 400 mainly includes:
[0202] The first loading module 401 is configured to load the first file in the preset position of the input table of the application in response to the first start event of the application.
[0203] The first initialization module 402 is configured to perform the first initialization configuration by the first initialization function of the first file in the case that the system sub-file in the first file is loaded.
[0204] The start module 403 is configured to pre-read the file segments required to start the application in the case that the first initialization configuration is completed.
[0205] In some embodiments, after the pre-reading of the file segments required to start the application is completed, the apparatus 400 further includes:
[0206] The second loading module is configured to load the second initialization function.
[0207] The second loading module is configured to perform a second initialization configuration based on the second initialization function, and start the application based on the pre-read file segment when the second initialization configuration is completed.
[0208] In some embodiments, the first loading module 401 is configured to:
[0209] In response to a first start event of triggering the application, perform a locking operation on a global lock;
[0210] When the locking operation is completed, load the first file into a virtual memory of the current first process;
[0211] The second loading module is configured to:
[0212] When the second initialization configuration is completed, perform an unlocking operation on the global lock;
[0213] When the unlocking operation is successfully performed, start the application based on the pre-read file segment.
[0214] In some embodiments, the first loading module 401 is configured to:
[0215] When it is determined based on the process information in the process environment block that the first process does not load a required file segment, load the first file into a virtual memory of the first process;
[0216] When the first file is loaded into the virtual memory of the first process, the apparatus 400 further comprises:
[0217] An updating module configured to update the process information in the process environment block based on the process information of the first process.
[0218] In some embodiments, the first loading module 401 is configured to:
[0219] When the first process does not load a required file segment, and the process image file includes the first file, load the first file into a virtual memory of the first process;
[0220] The apparatus 400 further comprises:
[0221] A prompting module configured to output a prompt information of loading failure when the first process does not load a required file segment, and the disk storing the process image file does not include a file segment required by the first process to run.
[0222] In some embodiments, the starting module 403 is configured to:
[0223] In the process of pre-reading the second file required for starting the application, in the case of interruption of loading the first file segment of the second file, triggering an interruption event;
[0224] In response to triggering the interruption event, merging the read request of the first file segment with the read request of the second file segment in the second file to obtain a target request;
[0225] Based on the target request, pre-reading the first file segment and the second file segment.
[0226] In some embodiments, the starting module 403 is configured to:
[0227] In the case of completing the first initialization configuration, pre-reading the file segment required for running the second process;
[0228] In the case of completing the file segment required for running all processes of the application, determining the completion of the pre-reading of the application.
[0229] In some embodiments, the apparatus 400 further comprises:
[0230] The packaging module is configured to package the system sub-file in the initial file of the application;
[0231] The obtaining module is configured to add the preset callback table including the first initialization function to the initial file to obtain the first file;
[0232] The generating module is configured to add the first file to the preset position of the input table of the process image file.
[0233] As to the apparatus in the above embodiments, the specific manners in which various modules perform operations have been described in detail in the embodiments of the method, and will not be described in detail here.
[0234] Based on the same inventive concept, the embodiments of the present disclosure provide an electronic device, which can be a computer or a terminal in one or more of the above embodiments. Figure 5 is a structural schematic diagram of an electronic device according to an exemplary embodiment. As shown in Figure 5 The electronic device 500 adopts general computer hardware and includes a processor 501, a memory 502, a bus 503, an input device 504 and an output device 505.
[0235] In some possible implementation manners, the memory 502 can include computer storage media in the form of volatile and / or nonvolatile memory, such as read only memory (ROM) and / or random access memory (RAM). The memory 502 can store operating systems, application programs, other program modules, executable code, program data, user data, and the like.
[0236] The input device 504 can be used to input commands and information into the electronic device, and the input device 504 can be, for example, a keyboard or a pointing device, such as a mouse, a trackball, a touchpad, a microphone, a joystick, a game pad, a satellite television antenna, a scanner, or the like. The input device 504 can be connected to the processor 501 through the bus 503.
[0237] The output device 505 can be used for the electronic device 500 to output information, and in addition to the monitor, the output device 505 can also be other peripheral output devices, such as a speaker and / or a printing device. The output device 505 can also be connected to the processor 501 through the bus 503.
[0238] The electronic device 500 can be connected to a network, for example, a local area network (LAN), through the antenna 506. In a networked environment, executable instructions can be stored in a remote storage device, and are not limited to being stored locally.
[0239] When the processor 501 in the electronic device 500 executes the executable code or the application program stored in the memory 502, the electronic device 500 can implement the file processing method in the above embodiments, and the specific execution process is described above and will not be repeated here.
[0240] The memory 502 described above can store executable instructions for implementing the functions of the first loading module 401, the first initialization module 402, and the starting module 403 in the above embodiments. Figure 4 The memory 502 described above can store executable instructions for implementing the functions of the first loading module 401, the first initialization module 402, and the starting module 403 in the above embodiments. Figure 4 The functions / implementation processes of the first loading module 401, the first initialization module 402, and the starting module 403 in the above embodiments can be implemented by the processor 501 in the above embodiments calling the executable instructions stored in the memory 502, and the specific implementation process and functions are described above. Figure 5 The functions / implementation processes of the first loading module 401, the first initialization module 402, and the starting module 403 in the above embodiments can be implemented by the processor 501 in the above embodiments calling the executable instructions stored in the memory 502, and the specific implementation process and functions are described above.
[0241] Based on the same inventive concept, the embodiments of the present disclosure also provide a storage medium. The storage medium stores instructions. When the instructions run on a computer, the instructions are used to execute the data processing method in one or more of the above embodiments.
[0242] Based on the same inventive concept, the embodiments of the present disclosure further provide a computer program or a computer program product. When the computer program product is executed on a computer, the computer is caused to implement the data processing method in one or more embodiments described above.
[0243] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the present disclosure. It is intended that the present disclosure cover any and all variations of the present disclosure including those variations contained within the scope of the even as defined by the claims. It is intended that the specification and examples be considered exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0244] It should be understood that the present disclosure is not limited to the precise structures as herein described and illustrated in the drawings, and that various modifications and changes can be made without departing from its scope. The scope of the present disclosure is limited only by the claims that follow.
Claims
1. A data processing method, characterized by, The method comprises: loading a first file in a preset position of an input table of the application in response to a first start event of triggering the application; performing first initialization configuration by using a first initialization function of the first file in a case that system sub-file in the first file is loaded completely; pre-reading file segments required for starting the application in a case that the first initialization configuration is completed.
2. The method of claim 1, wherein, After the pre-reading of the file segments required for starting the application is completed, the method further comprises: loading a second initialization function; performing second initialization configuration based on the second initialization function, and starting the application based on the pre-read file segments in a case that the second initialization configuration is completed.
3. The method of claim 2, wherein, The loading of the first file in the preset position of the input table of the process image file of the application in response to the first start event of triggering the application comprises: locking a global lock in response to the first start event of triggering the application; loading the first file to a virtual memory of a current first process in a case that the locking operation is completed.
4. The method of claim 3, wherein, The starting of the application in a case that the second initialization configuration is completed comprises: unlocking the global lock in a case that the second initialization configuration is completed; starting the application based on the pre-read file segments in a case that the unlocking operation is successfully executed.
5. The method of claim 3, wherein, The loading of the first file to the virtual memory of the current first process comprises: loading the first file to the virtual memory of the first process in a case that it is determined based on process information in a process environment block that the first process does not load a file segment required for running, and updating the process information in the process environment block based on process information of the first process in a case that the first file is loaded to the virtual memory of the first process.
6. The method of claim 5, wherein, The loading of the first file to the virtual memory of the first process in a case that it is determined based on process information in a process environment block that the first process does not load a file segment required for running comprises: loading the first file to the virtual memory of the first process in a case that the first process does not load a file segment required for running and the process image file comprises the first file.
7. The method of claim 1, wherein, The pre-reading of the file segments required for starting the application comprises: triggering an interrupt event in a case that a first file segment of the second file is interrupted during the pre-reading of the second file required for starting the application; merging a reading request of the first file segment and a reading request of a second file segment in the second file to obtain a target request in response to the triggering of the interrupt event; pre-reading the first file segment and the second file segment based on the target request.
8. The method of claim 1, wherein, The pre-reading of the file segments required for starting the application in a case that the first initialization configuration is completed comprises: pre-reading a file segment required for running a second process in a case that the first initialization configuration is completed; determining that pre-reading of the application program is completed in case that all file segments required for running processes of the application program are completed.
9. The method according to any one of claims 1 to 8, characterized in that, The method further comprises: encapsulating the system sub-file in an initial file of the application program; adding the preset callback table including the first initialization function into the initial file to obtain the first file; adding the first file into the preset position of the input table of the process image file.
10. A data processing apparatus, characterized by, comprise: a first loading module configured to load a first file in a preset position of an input table of an application program in response to a first starting event of triggering the application program; a first initialization module configured to perform first initialization configuration by using a first initialization function of the first file in case that a system sub-file in the first file is completed; a starting module configured to pre-read file segments required for starting the application program in case that the first initialization configuration is completed.
11. A computer program product comprising computer programs or instructions, characterized in that, The computer program or instructions are executed by the processor to implement the steps of the method in any one of claims 1 to 9.