Data processing method and apparatus, electronic device, and program product
Patent Information
- Application Number
- CN202611234916.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-14
- Publication Date
- 2026-10-27
AI Technical Summary
[0003]相关技术中,资源数据与属性信息通常采用串行加载方式,在资源规模较大时,需等待全部资源数据加载完成后才能开始界面渲染,导致界面响应延迟,用户等待时间较长,资源加载效率较低
当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现如本公开实施例中任一的数据处理方法。
Smart Images

Figure CN122985272A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a data processing method, apparatus, electronic device, and program product. Background Technology
[0002] As terminal applications become increasingly feature-rich, the amount of resource data that the interface needs to load continues to grow. Resource data is usually stored on external storage devices, and during loading, the resource data and its attribute information must be read into memory before rendering and display can be completed.
[0003] In related technologies, resource data and attribute information are usually loaded serially. When the resource scale is large, the interface rendering can only begin after all resource data has been loaded, resulting in interface response delay, long user waiting time, and low resource loading efficiency. Summary of the Invention
[0004] This invention provides a data processing method, apparatus, electronic device, and program product to achieve the technical effect of improving the loading efficiency of interface resources.
[0005] According to one aspect of the present invention, a data processing method is provided, the method comprising: In response to a resource loading request for the first interface, a first resource set corresponding to the resource loading request is determined; the first resource set includes multiple first resource data and is stored in an external storage device; When the external storage device stores companion files corresponding to each of the first resource data, each companion file in the external storage device is synchronously loaded into memory to obtain the attribute information of each of the first resource data; the companion file includes the attribute information of the first resource data; With all the accompanying files loaded synchronously, the first resource data in the external storage device is asynchronously loaded into the memory; During the asynchronous loading of each of the first resource data, for the second resource data that has been loaded in each of the first resource data, the second resource data is rendered and displayed on the first interface according to the attribute information of the second resource data in memory.
[0006] According to another aspect of the present invention, a data processing apparatus is provided, the apparatus comprising: The first module is configured to, in response to a resource loading request for the first interface, determine a first resource set corresponding to the resource loading request; the first resource set includes multiple first resource data and is stored in an external storage device; The second module is used to synchronously load each of the companion files in the external storage device into memory when the external storage device stores companion files corresponding to each of the first resource data, so as to obtain the attribute information of each of the first resource data; the companion file includes the attribute information of the first resource data; The third module is used to asynchronously load each of the first resource data in the external storage device into the memory when all the companion files have been loaded synchronously; The fourth module is used to render and display the second resource data to the first interface based on the attribute information of the second resource data in memory during the asynchronous loading of each of the first resource data.
[0007] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: One or more processors; Storage device for storing one or more programs. When one or more programs are executed by one or more processors, the one or more processors implement any of the data processing methods described in the embodiments of this disclosure.
[0008] According to another aspect of the present invention, a computer-readable storage medium is provided, which stores computer instructions for causing a processor to execute and implement any of the data processing methods of the present invention.
[0009] According to another aspect of the present disclosure, a computer program product is provided, which, when executed by a processor, implements any of the data processing methods described in the embodiments of the present disclosure.
[0010] The technical solution of this disclosure first synchronously loads the accompanying files into memory to obtain the attribute information of each resource data, and then asynchronously loads the resource data into memory. This allows the currently loaded resource data to be directly rendered and displayed on the first interface based on the obtained attribute information during the asynchronous loading process, without waiting for all resource data to be loaded. Simultaneously, the synchronous loading of the accompanying files and the asynchronous loading of the resource data are executed in stages, avoiding mutual blocking between attribute information acquisition and resource data loading. The technical solution of this disclosure solves the problem in the prior art where serial loading of resource data and attribute information leads to waiting for all resources to be loaded before interface rendering can begin, resulting in delayed interface response. It achieves a loading method where synchronous loading of accompanying files to obtain attribute information and asynchronous loading of resource data are executed in parallel, and the loaded resource data is rendered and displayed instantly. This achieves the technical effects of shortening interface response time, reducing user waiting time, and improving resource loading efficiency.
[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A flowchart illustrating a data processing method provided in an embodiment of this disclosure; Figure 2 A flowchart illustrating a data processing method provided in an embodiment of this disclosure; Figure 3 A flowchart illustrating a data processing method provided in an embodiment of this disclosure; Figure 4 A flowchart illustrating a data processing method provided in an embodiment of this disclosure; Figure 5 This is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of the present disclosure; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0014] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0015] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0016] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0017] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0018] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0019] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0020] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0021] Figure 1This is a flowchart illustrating a data processing method provided in an embodiment of this disclosure. This embodiment is applicable to situations involving loading front-end interface resources, particularly game interface resources. The method can be executed by a data processing device, which can be implemented in hardware and / or software and can be configured in electronic devices such as computers or servers. Figure 1 As shown, the method in this embodiment includes: S110. In response to a resource loading request for the first interface, determine a first resource set corresponding to the resource loading request; the first resource set includes multiple first resource data and is stored in an external storage device.
[0022] For ease of understanding, this disclosure uses a game scenario as an example for illustrative purposes. The first interface can be understood as a visual interface that needs to be rendered and displayed when a resource loading request is triggered. In one scenario, the first interface can be an information presentation interface that does not require user interaction. For example, an interface for presenting game progress, an interface for viewing battle data, or an interface for displaying ranking information; and so on. In another scenario, the first interface can be an interactive interface that allows user interaction. For example, an interface for managing game items (such as weapons used by player characters in the game scene), an interface for selecting character information, an interface for controlling characters; and so on.
[0023] A resource loading request can be understood as a request to load all the content to be displayed on the first interface from an external device into memory for rendering. In this embodiment, there are various ways to obtain a resource loading request, which are not specifically limited here. In one scenario, a resource loading request can be actively triggered by the user. For example, the user clicks a control, presses a shortcut, or selects an option. In another scenario, a resource loading request can be automatically triggered by the system. For example, during game operation, if the current game state determines that a new interface needs to be displayed, a resource loading request is automatically generated. For example, in a game scene, the player character moves to the boundary of a new area, or a timer expires and a reminder interface needs to be displayed.
[0024] Optionally, the resource loading request may include an interface identifier. It is understood that an interface identifier can be used to distinguish different interfaces. The interface identifier is associated with the resource data corresponding to the interface. In this embodiment, corresponding resource identifiers are pre-configured for different interface identifiers. Resource identifiers can be used to distinguish different resource data. For example, interface identifiers include interface A and interface B. Resource identifiers may include resource A, resource B, resource C, resource D, and resource E. Interface A corresponds to resource A, resource B, and resource C; interface B corresponds to resource D and resource E. In this embodiment, the storage method of the mapping relationship between interface identifiers and resource identifiers can be set according to actual needs and is not limited here. For example, an independent index file can be pre-generated for each interface, recording a list of all resource identifiers required by that interface. Alternatively, a configuration table can be pre-established, where each row records the correspondence between an interface identifier and a set of resource identifiers.
[0025] The first resource set can be understood as the set of all resource data required in response to a resource loading request. The first resource set is an ordered or unordered set composed of multiple first resource data. All the first resource data in the first resource set together constitute the complete content required by the first interface. First resource data can be understood as each individual resource in the first resource interface, which is the smallest data element constituting the content of the first interface. Optionally, the first resource may include at least one of the following: image resources, video resources, audio resources, and text resources. The first resource data may include content that will be rendered onto the first interface and directly presented to the user. The external storage device can be understood as the actual physical storage location of the resource data, not located in the device's running memory. Optionally, the external storage device may include at least one of the following: a game resource compressed package on a local disk, a CDN content distribution node, a game resource server, cloud storage, etc. All the first resource data in the first resource set is stored as files on the external storage device before being loaded.
[0026] In this embodiment of the disclosure, there are multiple ways to determine the first resource set corresponding to the resource loading request in response to the resource loading request for the first interface.
[0027] As an optional implementation in this disclosure, determining the first resource set corresponding to the resource loading request in response to a resource loading request for the first interface may include: parsing the resource loading request to obtain an interface identifier in the resource loading request; determining the resource identifier corresponding to the interface identifier based on the correspondence between the interface identifier and the resource identifier; thereby determining the first resource data to be rendered on the first interface, i.e., obtaining the first resource set. In this technical solution, the first resource data in the first resource set is stored in an external storage device.
[0028] S120. If the external storage device stores companion files corresponding to each of the first resource data, each companion file in the external storage device is synchronously loaded into memory to obtain the attribute information of each of the first resource data.
[0029] The accompanying file can be understood as a file used to describe the attribute information of the corresponding first resource data. The correspondence between the first resource data and the accompanying file is one-to-one. In this embodiment, the accompanying file and the first resource data are located in the same directory on an external storage device or associated through a fixed naming rule. Attribute information can be understood as the data content recorded in the accompanying file that describes the characteristics of the first resource data. Optionally, the attribute information may include at least one of the following: the size specifications, data format, compression method, color space, layout coordinates on the interface, scaling ratio, and loading priority of the resource data. Attribute information is a necessary prerequisite for correctly rendering the first resource data onto the first interface. Without attribute information, even if the resource itself is obtained, it cannot be drawn onto the first interface.
[0030] Synchronous loading is a blocking data reading method. The thread initiating synchronous loading will not return until the loading operation is complete; it must wait until all target data has been successfully read and written to memory before continuing execution of subsequent logic. Memory, or the device's running memory, is a storage area where the processor can perform high-speed read and write operations. Memory is used to store accompanying files read from external storage devices and their contained attribute information, so that subsequent rendering processes can directly read and use them.
[0031] Specifically, for each first resource data in the first resource set, it is determined whether there is a corresponding companion file on the external storage device. If it is confirmed that each first resource data has a corresponding companion file, a load instruction can be generated to load each companion file from the external storage device into memory. Based on this load instruction, all companion files in the external storage device can be read and written into memory. In this embodiment, reading and writing all companion files from the external storage device into memory may include: reading each companion file from the external storage device sequentially or in batches, and writing each companion file into the corresponding storage area in memory. After all companion files are loaded synchronously, all attribute information corresponding to each first resource data in the first resource set is stored in memory.
[0032] Optionally, when the external storage device stores companion files corresponding to each of the first resource data, synchronously loading each of the companion files in the external storage device into memory includes: when the external storage device stores companion files corresponding to each of the first resource data, sending a first loading instruction through the main thread to multiple second working threads independent of the main thread, so that each of the multiple second working threads independently reads the corresponding companion file from the external storage device and writes the attribute information of the read first resource data into memory to obtain the attribute information of each of the first resource data.
[0033] The main thread can be understood as a thread used to send first load instructions to multiple second worker threads that are independent of the main thread. It should be noted that there is only one main thread. This thread sends the first load instructions to multiple second worker threads, and after sending, blocks and waits for all second worker threads to complete loading the attribute information of each first resource data. Once all second worker threads have completed loading, the blocking is lifted to proceed to the next processing step.
[0034] In this embodiment, the main thread enters a blocked waiting state after sending the load instruction and remains blocked until all the multiple second worker threads have completed loading the attribute information of the first resource data. The second worker threads can be understood as threads used to load companion files stored on external storage devices into memory. There are typically multiple second worker threads. These multiple second worker threads work in parallel. In one scenario, the multiple first threads are directly created by the main thread. In another scenario, the multiple main threads can be selected by the main thread from a pre-created thread pool.
[0035] The correspondence between the second worker thread and the companion file can be one-to-one. In this embodiment, the companion file includes the attribute information of the first resource data. The first loading instruction can be understood as a task instruction issued by the main thread to the second worker thread. The instruction content can be: read the specified companion file, extract the attribute information of the first resource data, and write the attribute information into memory.
[0036] Specifically, when the external storage device stores companion files corresponding to each of the first resource data, the main thread can send a first loading instruction to multiple second working threads independent of the main thread, so that each of the multiple second working threads can independently read the corresponding companion file from the external storage device and write the attribute information of the read first resource data into memory to obtain the attribute information of each of the first resource data.
[0037] In one scenario, if the external storage device stores companion files corresponding to each of the first resource data, a corresponding second working thread can be created for each companion file by the main thread, and a loading instruction for loading the companion file can be issued to this second working thread, so that the second working thread loads the corresponding companion file into memory, thereby storing the attribute information of the first resource data into a preset storage area in memory.
[0038] In another scenario, where the external storage device stores companion files corresponding to each of the first resource data, and the number of worker threads in the thread pool is not less than the number of companion files, the main thread can select a corresponding second worker thread from the thread pool for each companion file and issue a load instruction to the second worker thread to load the corresponding companion file into memory, thereby storing the attribute information of the first resource data in a preset storage area of memory. Therefore, if the number of worker threads in the thread pool is less than the number of companion files, the main thread can also create new worker threads to load the companion files.
[0039] S130. With all the accompanying files already loaded synchronously, the first resource data in the external storage device is asynchronously loaded into the memory.
[0040] Asynchronous loading is a non-blocking data reading method. The thread that initiates asynchronous loading returns immediately after issuing the read request, without waiting for the data to be read completely. Instead, a background thread continuously reads data from the external storage device, and notifies the main thread when the data arrives via callback or event notification.
[0041] Specifically, after confirming that all accompanying files have been synchronously loaded into memory, a request can be generated to asynchronously load each first resource data in the first resource set from the external storage device. Based on this asynchronous loading request, a background loading thread can read each first resource data from the external storage device in parallel or serially, and write it into the specified storage area in memory after reading is complete.
[0042] S140. During the asynchronous loading of each of the first resource data, for the second resource data that has been loaded in each of the first resource data, the second resource data is rendered and displayed on the first interface according to the attribute information of the second resource data in the memory.
[0043] The second resource data can be understood as the first resource data whose content has been successfully read from and written to the external storage device during the asynchronous loading process. As asynchronous loading progresses, more and more first resource data is read and written to memory; this first resource data that has reached memory constitutes the second resource data. Once all the first resource data has been asynchronously loaded, the second resource data is equivalent to all the first resource data.
[0044] Specifically, after asynchronous loading begins, it is determined whether new first resource data has arrived in memory. Whenever first resource data is successfully read from external storage and written to memory, that resource data becomes second resource data. The attribute information corresponding to this second resource data can then be immediately read from memory. Based on the read attribute information, the second resource data is then rendered. For example, it is scaled according to the size recorded in the attribute information, decoded according to the format recorded in the attribute information, and its drawing position on the first interface is determined according to the layout coordinates recorded in the attribute information. Thus, the rendered content can be drawn onto the corresponding area of the first interface.
[0045] In this embodiment, a complete rendering and display process is executed each time new resource data arrives in memory. Therefore, the content on the first interface is gradually enriched; that is, the already arrived portion is displayed first, and subsequently arriving resource data continues to be overlaid and displayed until all the first resource data is asynchronously loaded and the entire content of the first interface is rendered.
[0046] In this embodiment of the disclosure, the method may further include: if no corresponding companion file exists for each of the first resource data, the first resource data in the external device may be loaded synchronously or asynchronously into memory. The method further includes: if the first resource data is cached in memory, the first resource data may be read from the cache, i.e., the first resource data may be loaded into the memory. If the first resource data is not cached in memory, and if no companion file exists for the first resource data, the first resource data in the external device may be loaded synchronously or asynchronously into memory.
[0047] In this embodiment of the disclosure, a game engine can use a multi-threaded approach to obtain the game interface through synchronous loading with asynchronous processing. Synchronous loading with asynchronous processing means synchronously loading the accompanying files of the game interface elements to obtain their attribute information, and asynchronously loading the game interface elements themselves.
[0048] The technical solution of this disclosure first synchronously loads the accompanying files into memory to obtain the attribute information of each resource data, and then asynchronously loads the resource data into memory. This allows the currently loaded resource data to be directly rendered and displayed on the first interface based on the obtained attribute information during the asynchronous loading process, without waiting for all resource data to be loaded. Simultaneously, the synchronous loading of the accompanying files and the asynchronous loading of the resource data are executed in stages, avoiding mutual blocking between attribute information acquisition and resource data loading. The technical solution of this disclosure solves the problem in the prior art where serial loading of resource data and attribute information leads to waiting for all resources to be loaded before interface rendering can begin, resulting in delayed interface response. It achieves a loading method where synchronous loading of accompanying files to obtain attribute information and asynchronous loading of resource data are executed in parallel, and the loaded resource data is rendered and displayed instantly. This achieves the technical effects of shortening interface response time, reducing user waiting time, and improving resource loading efficiency.
[0049] Figure 2 This is a schematic flowchart illustrating another data processing method provided in this embodiment. The technical solution of this embodiment can be combined with other embodiments; for the same or related parts, they can be described in conjunction with the descriptions of other embodiments, and will not be repeated here. Figure 2 As shown, the method in this embodiment may specifically include: S210. In response to a resource loading request for the first interface, determine a first resource set corresponding to the resource loading request; the first resource set includes multiple first resource data and is stored in an external storage device.
[0050] S220: If the external storage device stores companion files corresponding to each of the first resource data, the main thread sequentially loads each companion file from the external storage device into memory to obtain the attribute information of each of the first resource data; the companion file includes the attribute information of the first resource data.
[0051] In this embodiment, the accompanying files can be either compressed or uncompressed. Specifically, loading each accompanying file sequentially from the external storage device into memory via the main thread can include: sequentially reading each accompanying file from the external device via the main thread and writing each read accompanying file into memory, so that memory stores each accompanying file. Furthermore, the memory may also include pre-loaded, packaged accompanying files.
[0052] S230. With all the accompanying files already loaded synchronously, the first resource data in the external storage device is asynchronously loaded into the memory.
[0053] S240. During the asynchronous loading of each of the first resource data, for the second resource data that has been loaded in each of the first resource data, the second resource data is rendered and displayed on the first interface according to the attribute information of the second resource data in the memory.
[0054] The technical solution of this disclosure embodiment loads each of the companion files from the external storage device into memory sequentially through the main thread, thereby realizing the function of reading files from the external storage device and writing data into memory through the main thread.
[0055] Figure 3 This is a schematic flowchart illustrating another data processing method provided in this embodiment. The technical solution of this embodiment can be combined with other embodiments; for the same or related parts, they can be described in conjunction with the descriptions of other embodiments, and will not be repeated here. Figure 3 As shown, the method in this embodiment may specifically include: S310. In response to a resource loading request for the first interface, determine a first resource set corresponding to the resource loading request; the first resource set includes multiple first resource data and is stored in an external storage device.
[0056] S320: If the external storage device stores companion files corresponding to each of the first resource data, the main thread sequentially loads each companion file from the external storage device into memory to obtain the attribute information of each of the first resource data.
[0057] S330. With all the accompanying files loaded synchronously, the main thread sends a second loading instruction to multiple first working threads independent of the main thread, so that each of the multiple first working threads independently reads the corresponding first resource data from the external storage device and writes the read first resource data into the memory.
[0058] In this context, a first worker thread can be understood as a worker thread used to load first resource data stored in an external storage device into memory. The number of first worker threads is typically multiple. In this embodiment, the main thread can be in a normal operating state after sending the second load instruction. After all the multiple first worker threads have completed loading the first resource data, they synchronize the first resource data to the main thread. It can be understood that the normal operating state can be understood as the main thread being in a non-blocking state, meaning that the main thread continues to operate normally after sending the instruction and can process other tasks without waiting for the first worker threads to complete their tasks. The first worker threads execute asynchronously relative to the main thread and execute in parallel with each other. In this embodiment, the correspondence between the first worker threads and the first resource data can be one-to-one. That is, each of the multiple first worker threads independently reads the corresponding first resource data from the external storage device.
[0059] In one scenario, multiple first worker threads may be directly created by the main thread. In another scenario, multiple main threads may be selected from a pre-created thread pool. In this embodiment, the first worker threads and the second worker threads may be the same batch of threads. The first worker threads may be a group of threads, and the second worker threads may be a different type of thread. The first worker threads and the second worker threads are at least partially identical. The second load instruction can be understood as a task instruction issued by the main thread to the first worker threads. The instruction content may be loading first resource data stored on an external storage device into memory.
[0060] Specifically, when all the accompanying files have been loaded synchronously, the main thread sends a second loading instruction to multiple first worker threads that are independent of the main thread, so that each of the multiple first worker threads independently reads the corresponding first resource data from the external storage device and writes the read first resource data into the memory.
[0061] In one scenario, where all the accompanying files have been loaded synchronously, a corresponding first worker thread can be created for each first resource data by the main thread, and a loading instruction for loading the first resource data can be issued to this first worker thread, so that the first worker thread loads the corresponding first resource data into memory, thereby storing the first resource data in a preset storage area of memory.
[0062] In another scenario, assuming all accompanying files have been loaded synchronously, and the number of worker threads in the thread pool is not less than the number of first resource data items, the main thread can select a corresponding first worker thread from the thread pool for each first resource data item and issue a load instruction to the first worker thread to load the corresponding first resource data into memory, thus storing the first resource data in a preset storage area in memory. Therefore, if the number of worker threads in the thread pool is less than the number of first resource data items, the main thread can create new worker threads to load the first resource data.
[0063] S340. During the asynchronous loading of each of the first resource data, for the second resource data that has been loaded in each of the first resource data, the second resource data is rendered and displayed on the first interface according to the attribute information of the second resource data in the memory.
[0064] The technical solution of this disclosure embodiment involves the main thread sending a second loading instruction to multiple first worker threads independent of the main thread. This allows each of the multiple first worker threads to independently read the corresponding first resource data from the external storage device and write the read first resource data into the memory. The main thread can operate normally after sending the second loading instruction. After all the multiple first worker threads have completed loading the first resource data, they synchronize the first resource data back to the main thread. This achieves an asynchronous parallel loading mechanism where multiple first worker threads read the first resource data and write it into memory in parallel, the main thread runs non-blockingly after sending the instruction, and all data is synchronized back to the main thread upon completion. This achieves the technical effect of fully utilizing multi-threaded parallel input / output to improve resource loading efficiency, while avoiding the main thread being idle and blocked while waiting for loading, and ensuring data integrity and consistency.
[0065] Figure 4 This is a schematic flowchart illustrating another data processing method provided in this embodiment. The technical solution of this embodiment can be combined with other embodiments; for the same or related parts, they can be described in conjunction with the descriptions of other embodiments, and will not be repeated here. Figure 4 As shown, the method in this embodiment may specifically include: S410. In response to a resource loading request for the first interface, determine a first resource set corresponding to the resource loading request; the first resource set includes multiple first resource data and is stored in an external storage device.
[0066] S420. If the external storage device stores companion files corresponding to each of the first resource data, each companion file in the external storage device is synchronously loaded into memory to obtain the attribute information of each of the first resource data. The memory includes a first container, the first container includes a second resource set, and the second resource set includes multiple unused third resource data.
[0067] The first container is implemented based on a Least Recently Used (LRU) cache eviction policy. The first container includes a second resource set. This second resource set can be understood as a collection of multiple unused third resource data. These third resource data can be understood as unused resource data in memory. In practical applications, the number of third resource data is typically multiple.
[0068] S430. With all the accompanying files already loaded synchronously, the first resource data in the external storage device is asynchronously loaded into the memory.
[0069] S440. During the asynchronous loading of each of the first resource data, for the second resource data that has been loaded in each of the first resource data, the second resource data is rendered and displayed on the first interface according to the attribute information of the second resource data in the memory.
[0070] S450. Determine the available space capacity of the first container. If the available space capacity meets the first condition, determine the entry time of each of the third resource data into the first container, and delete each of the third resource data in order from earliest to latest according to the entry time.
[0071] Here, available space capacity can be understood as the capacity of space in the first container that can be used to store resource data. The first condition can be understood as a pre-set condition used to trigger the deletion of third resource data from the container. Optionally, the first condition may include available space capacity exceeding a preset capacity threshold. The capacity threshold can be set according to actual needs and is not specifically limited here. Entry time can be understood as the time when the third resource data enters the first container.
[0072] Specifically, the available space capacity of the first container is determined. If the available space capacity meets a first condition, the entry time of each of the third resource data into the first container can be determined. Then, the corresponding third resource data can be deleted from the first container in order of their entry times from earliest to latest.
[0073] In one scenario, if the first condition is not met during the deletion of third resource data from the first container, the deletion operation can be terminated. In another scenario, the corresponding third resource data is deleted from the first container in ascending order of entry time until no resource data remains in the first container.
[0074] In this embodiment of the disclosure, the memory includes multiple fourth resource data. The method further includes: for each fourth resource data, obtaining a smart pointer corresponding to the fourth resource data, determining the reference count of the smart pointer, and when the reference count is 1, adding the fourth resource data as the third resource data to the first container, thereby achieving unified management of resource data; the reference count represents the number of times the fourth resource data is referenced at the current moment. The fourth resource data can be understood as resource data in memory that needs to be analyzed to determine whether it can be added to the first container.
[0075] In this embodiment of the disclosure, determining the available space capacity of the first container includes: obtaining the memory usage and / or memory status at the current moment; and determining the available space capacity of the first container based on the memory usage and / or the memory status. Here, memory usage can be understood as the amount of memory space occupied by resource data loaded into memory during program execution. Memory status can be understood as the state of memory at the current moment. Optionally, the memory status may include one of the following: load status.
[0076] As an optional implementation of this disclosure, the memory usage at the current moment is obtained, and the available space capacity of the first container is determined based on the memory usage. As another optional implementation of this disclosure, the memory state at the current moment is obtained; and the available space capacity of the first container is determined based on the memory state. As yet another optional implementation of this disclosure, the memory usage and memory state at the current moment are obtained; and the available space capacity of the first container is determined based on the memory usage and memory state.
[0077] Optionally, determining the available space capacity of the first container based on the memory usage includes: determining the available space capacity of the first container based on the ratio of the memory usage at the current moment to the memory usage limit and a preset threshold range. In this embodiment of the disclosure, the upper limit of the capacity of the first container is dynamically adjusted based on the ratio of the available memory usage to the memory usage limit; the lower the ratio, the larger the capacity limit, and the higher the ratio, the smaller the capacity limit. When the maximum threshold is exceeded, the capacity limit is adjusted to zero. The memory usage limit can be understood as the maximum threshold of memory space allowed to be used by the program. The memory usage limit can be set according to actual needs and is not limited here. There are multiple ways to obtain the memory usage limit. For example, in response to an information configuration operation for the memory usage limit, the memory usage limit can be obtained based on this information configuration operation. Alternatively, the memory usage limit can be determined based on the total memory (e.g., 90% of the total memory).
[0078] In this embodiment of the disclosure, the number of preset threshold ranges can be one or more. When there are multiple preset threshold ranges, a corresponding upper limit for the capacity of the first container can be set for each preset threshold range, thereby enabling more refined dynamic adjustment of the capacity of the first container based on the memory usage ratio.
[0079] For example, the preset threshold ranges include: a threshold range of 0-25%, a threshold range of 25%-50%, a threshold range of 50%-75%, and a threshold range of 75%-100%. Within the 0-25% threshold range, if the ratio of the current memory usage to the memory usage limit is within the 0-25% threshold range, the available space capacity of the first container can be dynamically increased. If the ratio is within the 25%-50% threshold range, the available space capacity of the first container can be kept constant. If the ratio is within the 50%-75% threshold range, the available space capacity of the first container can be dynamically decreased. If the ratio is within the 75%-100% threshold range, the available space capacity of the first container can be set to zero.
[0080] The technical solution of this disclosure embodiment determines the available space capacity of the first container, and when the available space capacity meets the first condition, determines the entry time of each third resource data entering the first container, and deletes each third resource data in order from earliest to latest according to the entry time. This realizes an intelligent memory reclamation mechanism that accurately locates and clears data that should be eliminated, and achieves the technical effect of accurately releasing the target amount of memory while prioritizing the clearing of long-term unused data and retaining recently frequently used data to the maximum extent to maintain cache hit rate and speed-up effect.
[0081] Figure 5 This is a schematic diagram of a data processing apparatus provided in an embodiment of the present disclosure. Figure 5 As shown, the data processing device includes: a first module 510, a second module 520, a third module 530, and a fourth module 540. Specifically, the first module 510 is used to determine a first resource set corresponding to a resource loading request for a first interface; the first resource set includes multiple first resource data and is stored in an external storage device. The second module 520 is used to synchronously load each companion file corresponding to each first resource data into memory when the external storage device stores companion files, to obtain attribute information of each first resource data; the companion files include the attribute information of the first resource data. The third module 530 is used to asynchronously load each first resource data from the external storage device into memory when all companion files have been synchronously loaded. The fourth module 540 is used to render and display second resource data that has been loaded in memory on the first interface during the asynchronous loading of each first resource data, based on the attribute information of the second resource data in memory.
[0082] The technical solution of this disclosure first synchronously loads the accompanying files into memory to obtain the attribute information of each resource data, and then asynchronously loads the resource data into memory. This allows the currently loaded resource data to be directly rendered and displayed on the first interface based on the obtained attribute information during the asynchronous loading process, without waiting for all resource data to be loaded. Simultaneously, the synchronous loading of the accompanying files and the asynchronous loading of the resource data are executed in stages, avoiding mutual blocking between attribute information acquisition and resource data loading. The technical solution of this disclosure solves the problem in the prior art where serial loading of resource data and attribute information leads to waiting for all resources to be loaded before interface rendering can begin, resulting in delayed interface response. It achieves a loading method where synchronous loading of accompanying files to obtain attribute information and asynchronous loading of resource data are executed in parallel, and the loaded resource data is rendered and displayed instantly. This achieves the technical effects of shortening interface response time, reducing user waiting time, and improving resource loading efficiency.
[0083] In some embodiments of this disclosure, optionally, the second module 520 is configured to load each of the companion files from the external storage device into memory sequentially via the main thread.
[0084] In some embodiments of this disclosure, optionally, the third module 530 is configured to send a second loading instruction to a plurality of first working threads independent of the main thread, so that each of the plurality of first working threads independently reads the corresponding first resource data from the external storage device and writes the read first resource data into the memory; wherein, the main thread can be in a normal operating state after sending the second loading instruction, and after all the plurality of first working threads have completed loading the first resource data, they synchronize the first resource data to the main thread.
[0085] In some embodiments of this disclosure, optionally, the memory includes a first container, the first container includes a second resource set, the second resource set includes a plurality of unused third resource data; the data processing device further includes a fifth module, the fifth module being configured to determine the available space capacity of the first container, and, if the available space capacity satisfies a first condition, determine the entry time of each of the third resource data into the first container, and delete each of the third resource data in order of their entry times from earliest to latest.
[0086] In some embodiments of this disclosure, optionally, the memory further includes a plurality of fourth resource data; the data processing device further includes a sixth module, the sixth module being configured to, for each of the fourth resource data, obtain a smart pointer corresponding to the fourth resource data, determine the reference count of the smart pointer, and, when the reference count is 1, add the fourth resource data as the third resource data to the first container; the reference count represents the number of times the fourth resource data is referenced at the current time.
[0087] In some embodiments of this disclosure, optionally, the fifth module is configured to obtain the memory usage and / or memory status of the memory at the current moment; and determine the available space of the first container based on the memory usage and / or the memory status.
[0088] In some embodiments of this disclosure, optionally, the fifth module is used to determine the available space of the first container based on the ratio of the memory usage at the current moment to the memory usage limit and a preset threshold range.
[0089] In some embodiments of this disclosure, the data processing apparatus may optionally include a seventh module, which is used to synchronously or asynchronously load each of the first resource data in the external device into the memory when there is no corresponding companion file for each of the first resource data.
[0090] The data processing apparatus provided in this disclosure can execute the data processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the method.
[0091] It is worth noting that the various units and modules included in the above-mentioned data processing device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.
[0092] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0093] like Figure 6 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0094] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0095] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as data processing methods.
[0096] In some embodiments, the data processing method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via read-only memory (ROM) 12 and / or communication unit 19. When the computer program is loaded into random access memory (RAM) 13 and executed by processor 11, one or more steps of the data processing method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the data processing method by any other suitable means (e.g., by means of firmware).
[0097] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0098] Computer programs used to implement the data processing methods of this disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0099] Computer programs used to implement the data processing methods of this disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0100] This disclosure provides a computer-readable storage medium storing computer instructions for causing a processor to execute a data processing method, comprising: in response to a resource loading request for a first interface, determining a first resource set corresponding to the resource loading request; the first resource set including a plurality of first resource data and stored in an external storage device; when the external storage device stores companion files corresponding to each of the first resource data, synchronously loading each of the companion files in the external storage device into memory to obtain attribute information of each of the first resource data; the companion files including the attribute information of the first resource data; when all the companion files have been synchronously loaded, asynchronously loading each of the first resource data in the external storage device into memory; during the asynchronous loading of each of the first resource data, for second resource data that has been loaded in each of the first resource data, rendering and displaying the second resource data on the first interface according to the attribute information of the second resource data in memory.
[0101] In the context of this disclosure, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0102] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0103] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0104] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0105] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication unit 19, or installed from storage unit 18, or installed from ROM 12. When the computer program is executed by processor 11, it performs the functions defined in the methods of embodiments of this disclosure.
[0106] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements a data processing method according to any embodiment of this disclosure.
[0107] In implementing a computer program product, computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0108] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this disclosure can be achieved, and this is not limited herein.
[0109] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A data processing method, characterized in that, The method includes: In response to a resource loading request for the first interface, a first resource set corresponding to the resource loading request is determined; the first resource set includes multiple first resource data and is stored in an external storage device; When the external storage device stores companion files corresponding to each of the first resource data, each companion file in the external storage device is synchronously loaded into memory to obtain the attribute information of each of the first resource data; the companion file includes the attribute information of the first resource data; With all the accompanying files loaded synchronously, the first resource data in the external storage device is asynchronously loaded into the memory; During the asynchronous loading of each of the first resource data, for the second resource data that has been loaded in each of the first resource data, the second resource data is rendered and displayed on the first interface according to the attribute information of the second resource data in memory.
2. The method according to claim 1, characterized in that, The step of synchronously loading each of the companion files in the external storage device into memory includes: The main thread loads each of the companion files from the external storage device into memory sequentially.
3. The method according to claim 2, characterized in that, The step of asynchronously loading each of the first resource data in the external storage device into the memory includes: The main thread sends a second loading instruction to multiple first worker threads that are independent of the main thread, so that each of the multiple first worker threads independently reads the corresponding first resource data from the external storage device and writes the read first resource data into the memory. The main thread can be in normal operation after sending the second loading instruction, and the multiple first worker threads will synchronize the first resource data to the main thread after all of them have completed loading the first resource data.
4. The method according to claim 1, characterized in that, The memory includes a first container, the first container includes a second resource set, and the second resource set includes multiple unused third resource data; the method further includes: The available space capacity of the first container is determined. If the available space capacity meets the first condition, the entry time of each of the third resource data into the first container is determined, and each of the third resource data is deleted in order from the earliest to the latest according to the entry time.
5. The method according to claim 4, characterized in that, The memory also includes multiple fourth resource data, and the method further includes: For each of the fourth resource data, obtain the smart pointer corresponding to the fourth resource data, determine the reference count of the smart pointer, and when the reference count is 1, add the fourth resource data as the third resource data to the first container; the reference count represents the number of times the fourth resource data is referenced at the current time.
6. The method according to claim 4, characterized in that, Determine the available space in the first container, including: Obtain the memory usage and / or memory status of the memory at the current moment; The available space of the first container is determined based on the memory usage and / or the memory status.
7. The method according to claim 4, characterized in that, Determining the memory usage at the current moment includes: The available space of the first container is determined based on the ratio of the current memory usage to the upper limit of memory usage and a preset threshold range.
8. The method according to claim 1, characterized in that, The method further includes: If no corresponding companion file exists for each of the first resource data, the first resource data in the external device will be loaded synchronously or asynchronously into the memory.
9. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method as described in any one of claims 1-8.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the data processing method according to any one of claims 1-8.
