A data-oriented hot update method and device
By dividing the business logic of online games into states and components, and utilizing the independent memory spaces of the kernel layer and the hot update layer, new components are dynamically loaded to replace old components, thus solving the limitations of multi-threading and editor support in existing hot updates and achieving efficient, restart-free updates.
Patent Information
- Application Number
- CN202310399983.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-13
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2043-04-13
AI Technical Summary
In existing technologies, hot update methods for online games have limitations in terms of multithreading and editor support, resulting in low development efficiency and poor user experience.
Using a data-oriented programming approach, business logic is divided into state, components, and component proxies. State data is stored in the kernel layer, and components reside in the hot update layer. Hot updates are achieved by dynamically loading new components to replace old ones.
It enables efficient hot updates without requiring device restarts, improving development efficiency and maintaining user experience stability.
Smart Images

Figure CN116271844B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a data-oriented hot updating method and device, computing device and computer readable storage medium. BACKGROUND
[0002] In the prior art, network games are an application with high real-time requirements, and a large number of clients are connected to the server in real time. In order to reduce the server process restart caused by function modification, a non-stop service updating mechanism is usually used, such as rolling update, stateless service, script update and the like. However, these solutions have corresponding limitations, such as only for short connection services, or room type services and the like with weak real-time interaction requirements. For example, the script update solution is to develop logical services by using a script language such as Lua, and to update the script and the service function through the underlying framework. However, the script language does not support multi-threaded operation, or cannot obtain excellent editor support like static languages. Therefore, there is an urgent need for a hot updating method to reduce bugs in large project development and improve development efficiency. SUMMARY
[0003] Therefore, the present application provides a data-oriented hot updating method, device, computing device and computer readable storage medium to solve the technical defects in the prior art.
[0004] According to a first aspect of the present application, a data-oriented hot updating method is provided, comprising:
[0005] dividing the business logic into states, components and component agents; wherein the states only include data related to the business logic;
[0006] loading the states and component agents into the kernel layer of a process, and loading the components into the hot updating layer of the process; wherein the kernel layer and the hot updating layer belong to two independent memory spaces of the process respectively;
[0007] dynamically loading new components into the hot updating layer, and replacing the old components in the hot updating layer with the new components.
[0008] According to a second aspect of the present application, a data-oriented hot updating device is provided, comprising:
[0009] a state unit, a component unit and a component agent unit, which constitute the business logic of an application; wherein the state unit only includes data related to the business logic;
[0010] a first loading unit configured to load the states and component agents into the kernel layer of a process;
[0011] a second loading unit, configured to load the component to a hot update layer of the process; wherein the kernel layer and the hot update layer belong to two independent memory spaces of the process respectively;
[0012] a third loading unit, configured to dynamically load a new component to the hot update layer, and replace an old component in the hot update layer with the new component.
[0013] According to a third aspect of the embodiments of the present application, a computing device is provided, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor executes the instructions to implement the steps of the data-oriented hot update method.
[0014] According to a fourth aspect of the embodiments of the present application, a computer readable storage medium is provided, which stores computer instructions executable by a processor to implement the steps of the data-oriented hot update method.
[0015] In the embodiments of the present application, the business logic is divided into state, component and component proxy based on the object-oriented idea. The business data in the process is maintained unchanged through the separation of state and component, and the component has friendly access to the state. All state data is saved in the kernel layer, and the component runs in the hot update layer of the same process space; such mechanism can ensure that the component in the hot update layer can be replaced at any time while the state required by the component remains unchanged, and better realizes the hot update function. The scheme of the embodiments of the present application overcomes the defects of various hot update technologies in the prior art, not only improves the work efficiency of research and development, but also has good user experience. BRIEF DESCRIPTION OF DRAWINGS
[0016] Figure 1 is a structural block diagram of a computing device provided by the embodiments of the present application;
[0017] Figure 2 is a flowchart of a data-oriented hot update method provided by the embodiments of the present application;
[0018] Figure 3 is a composition diagram of business logic in the data-oriented hot update method provided by the embodiments of the present application;
[0019] Figure 4 is a diagram of memory space in the data-oriented hot update method provided by the embodiments of the present application;
[0020] Figure 5 is a structural diagram of a data-oriented hot update device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0021] In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced without the specific details. In other instances, well-known methods, procedures, components, and circuits have not been described in detail so as not to unnecessarily obscure aspects of the present application.
[0022] The terminology used in this description is for the purpose of describing particular embodiments only and is not intended to limit one or more embodiments of the present application. As used in one or more embodiments of the present application and the accompanying claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0023] It will be understood that, although the terms first, second, etc. can be used herein to describe various information, these terms are not intended to denote a temporal or chronological order. Rather, these terms are used solely to distinguish one from another only. For example, a first can be termed a second, and, similarly, a second can be also termed a first, without departing from the scope of one or more embodiments of the present application. As used herein, the term "if' can be interpreted to mean "when" or "responsive to the determination" or "in response to the determination" or "in response to the component determining" or "in response to the component decided" or "based on a determination" or "based on the component determining" or "based on the component deciding." As used herein, the term "plurality" can be interpreted to mean "two or more." As used herein, the term "exemplary" is used exclusively in its sense of "serving as an example," not in its sense of "representing the best of its kind."
[0024] In the present application, a data-oriented hot updating method and device, a computing device and a computer readable storage medium are provided, which are described in detail in the following embodiments.
[0025] Figure 1 A structural block diagram of a computing device 100 according to an embodiment of the present application is shown. The components of the computing device 100 include, but are not limited to, a memory 110 and a processor 120. The processor 120 is connected to the memory 110 through a bus 130, and a database 150 is used to save data.
[0026] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of such networks include the public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 can include one or more of any type of network interface (e.g., network interface card (NIC)), wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a near-field communication (NFC) interface, and the like.
[0027] In one embodiment of the present application, the above-mentioned components of the computing device 100 and other components not shown in the figure can be connected to each other, for example, through a bus. It should be understood that, Figure 1 Figure 1 The computing device structure diagram shown is only for the purpose of example, and is not a limitation on the scope of the present application. Those skilled in the art can add or replace other components as needed.
[0028] The computing device 100 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a PC. The computing device 100 can also be a mobile or stationary server.
[0029] In the prior art, when developing a complex software system, the object-oriented programming idea is usually adopted to abstract various requirements in the software system into various virtual objects to complete the programming work. However, in the development of some fields, it is gradually found that the layer-by-layer abstraction operation of object-oriented programming is easy to cause the code to be bloated, thereby causing the software running efficiency to be reduced and the development work to be more and more tedious. For example, in the game field, the performance requirement of the software is usually high and it is always hoped that the changes in various requirements have the least impact on the system. Therefore, in modern game programming, the idea of data-oriented programming is becoming more and more popular.
[0030] The core idea of data-oriented programming is to reduce the complexity of a system by separating code from data. When code is separated from data, a software system consists of two main parts that can be considered separately: data entities and code modules. The benefit of this is that the software system is simple and easy to understand, and the software system is very flexible and does not need to change the design to adapt to changing requirements. For example, the ECS model is a common data-oriented programming approach in the field of game programming. In which, ECS is the abbreviation of Entity, Component and System, is a data-oriented programming paradigm, used to build high-performance, scalable and easy-to-maintain applications. In ECS, an application is decomposed into three main parts: entities, components, and systems. Entities are basic objects in an application and do not contain any data or logic. Components are data and logic associated with entities, which describe the characteristics and behaviors of entities. Systems are code logic that handle entities and components, which are responsible for updating and processing the data of components, and controlling the interaction and communication between components. Systems extract data from entities and components as needed and operate and modify them. In the ECS model, an entity is composed of several components of its required attributes, such as a character entity composed of components of its name, position state, etc. A system manages game entities composed of several specific components.
[0031] In this application, the data-oriented idea is used and adopted, and the business logic of the application is redesigned, so that when the function of the application needs to be updated, the device does not need to be restarted, overcoming the limitations and defects of various hot update technologies in the prior art.
[0032] The processor 120 in the specification Figure 1 may execute the steps in the data-oriented hot update method shown in Figure 2 . Figure 2 A flowchart for implementing a data-oriented hot update method is shown in , which can be used for any device that executes business logic, including steps 202 to 206.
[0033] Step 202: Divide the business logic into states, components, and component agents.
[0034] In a feasible implementation, according to the data-oriented idea, the business logic of the application is divided into states, components, and component agents, as shown in Figure 3 , the business logic is composed of multiple different states, components, and component agents, wherein the components and component agents correspond one-to-one.
[0035] The state only includes data related to the business logic, for example, in a business logic related to a game character, the data related to the game character is placed in different states respectively, such as experience value, weapon of equipment, and items in the backpack, each of which has its own state. The schematic code of the state is as follows,
[0036]
[0037]
[0038] In the state class, get and set methods of various data types are included to provide data access functions.
[0039] Further, the component is a logic processing unit related to the state, and is used to process various types of business logic. For example, the logic of increasing the level of the game character due to the increase of the experience value of the character corresponds to the character upgrade component, and the logic of upgrading the weapon due to the forging of the weapon corresponds to the weapon upgrade component, and the like. The schematic code of a component is as follows:
[0040]
[0041] In the class definition of each component, in addition to the related logic processing method, an instance of the component agent corresponding to the component is included, which enables the component to obtain data in the state through the component agent.
[0042] The component agent corresponds to the component one-to-one, and serves as the agent of the component to wrap the actual component and maintain the relationship with the state. Therefore, in the definition of each component agent, a method of accessing the state instance is defined; and in the component agent, a method of obtaining the component instance corresponding to the component agent is defined.
[0043] Optionally, the component agent obtains the component instance corresponding to the component agent from the component cache. The schematic code of the component agent is as follows:
[0044]
[0045]
[0046] Step 204: load the state and the component agent to the kernel layer, and load the component to the hot update layer;
[0047] In a feasible implementation, when the application is started or initialized, the state and the component agent constituting the business logic are loaded to the kernel layer, and the component is loaded to the hot update layer.
[0048] The kernel layer and the hot update layer run in the same process, but belong to two independent memory spaces, and the two memory spaces can access each other. Figure 4
[0049] Specifically, the component is loaded into the component cache of the hot update layer.
[0050] Further, when the component agent is initialized, the component cache of the hot update layer is accessed through the kernel layer to obtain the corresponding component instance, and then the association between the component and the component agent is completed.
[0051] In the implementation of the business logic of the application, since the implementation of the business logic is entirely in the hot update layer, the application process completes the execution of the business logic by calling the component instance; further, the component instance obtains the required state instance through the component agent instance m_Agent therein, and after completing the execution of the business logic, the state is synchronized.
[0052] Step 206: Dynamically load a new component into the hot update layer, and replace the old component in the hot update layer with the new component.
[0053] In this step, when it is necessary to update the business logic of the device, the new component is dynamically loaded into the hot update layer of the original process space through the kernel layer, the component is reconstructed, the association between the new component and the original state and component agent in the kernel layer is completed, and the update of the business logic is realized without changing the original state.
[0054] The new component is packaged in a hot update package in a manner common in the art, such as a program set, a dynamic library, a jar package, etc. Those skilled in the art should know that in the technical field, different programming languages have different implementations of dynamically loading program packages, which are not listed here.
[0055] Optionally, when the new component is dynamically loaded, the old component instance to be replaced in the hot update layer is first unloaded. In a feasible manner, the identifier of the new component in the hot update package can be obtained, such as the name of the component, and then the old component instance to be replaced in the hot update layer is unloaded according to the identifier.
[0056] Further, after the new component is dynamically loaded into the hot update layer, the component cache in the hot update layer is checked, and if the instance of the current component is empty, a new instance of the current component is created in the hot update layer, and the association between the new component and the component agent is constructed. That is, the component instance m_CacheComponent pointed to by the component agent in the kernel layer is updated, and the component agent instance m_Agent in the component is updated, so that the component agent in the kernel layer is associated with the new component instance.
[0057] Another embodiment of the present application describes how to use the above method to implement hot update for the upgrade business logic of a specific game character.
[0058] In this embodiment, the current game character state playerState contains the accumulated experience value of the character, and the character upgrade component upgradeComponent contains the method upgradeCal for calculating the character level. The character upgrade component agent upgradeComponentAgent wraps the upgrade component.
[0059] Whenever the character obtains new experience value, the execution thread executes the logic of the character upgrade component, calls the upgradeCal method to determine whether the character should be upgraded based on the accumulated experience value and the new experience value. The accumulated experience value and the new experience value are obtained from the character state by the character upgrade component through an instance of the character upgrade component agent.
[0060] When it is found that the calculation process in the calculation method upgradeCal needs to be updated, a new upgrade component is written to implement a new upgradeCal method, which is then dynamically loaded into the hot update layer of the current process space to build a new upgrade component instance. When loading, the original instance of upgradeComponent in the hot update layer is first unloaded, and then the new upgradeComponent is dynamically loaded.
[0061] After the original upgradeComponent is unloaded, the upgradeComponent instance pointed to by the upgradeComponentAgent in the kernel layer becomes empty. At this time, the component cache in the hot update layer is checked. If the instance of upgradeComponent is determined to be empty, a new instance of upgradeComponent is created in the hot update layer, so that the component instance m_CacheComponent in the upgradeComponentAgent points to the created new instance of upgradeComponent, thereby associating the upgradeComponentAgent in the kernel layer with the new upgradeComponent. When the character needs to calculate experience value next time, the new upgradeCal method will be used for calculation.
[0062] It should be noted that in the above hot update process, the data in the game character state playerState, i.e., the accumulated experience value, always remains in the kernel layer and does not change due to the update of the component, thereby maintaining the user's character state while updating the data processing logic, successfully implementing an efficient hot update scheme.
[0063] Further, in the new component, not only the original method is updated, but also various processing logics can be added according to the needs of the business logic. For example, the component includes an instance of the component agent, which enables the component to obtain data in the state through the component agent, and then implement new processing logic around the state.
[0064] In the embodiment of the present application, in order to implement an efficient and zero-restart hot updating scheme, the business logic of the application is divided into a state, a component and a component agent based on the data-oriented idea, wherein the state includes the data part of the business logic, the component includes the processing method of the business logic, the component agent corresponds to the component one by one and wraps the component. When executing the application, the process space is divided into a kernel layer and a hot updating layer, all state data and component agents are actually saved in the kernel layer, and the component is loaded into the hot updating layer. When the logic business needs to be updated, the kernel layer parses the hot updating program package through dynamic loading, replaces the old component with the new component in the hot updating layer, and then executes the new business logic. In the embodiment of the present application, the separation of the state and the component can maintain the business data in the process unchanged, and at the same time enable the component to have friendly access to the state. All state data are saved in the kernel layer, and the agent of the component is also saved in the kernel layer to process the business logic by using the method of the component; such mechanism can ensure that the component in the hot updating layer can be replaced at any time while the state of the component remains unchanged, thereby not affecting the business data of the user and better implementing the hot updating function.
[0065] Corresponding to the method embodiment, the present application also provides an embodiment of a data-oriented hot updating device, Figure 5 The structure of the data-oriented hot updating device in one embodiment of the present application is shown, which comprises:
[0066] a state unit, a component unit and a component agent unit, which constitute the business logic of the application; wherein the state unit only includes data related to the business logic;
[0067] a first loading unit for loading the state and the component agent to the kernel layer of the process;
[0068] a second loading unit for loading the component to the hot updating layer of the process; wherein the kernel layer and the hot updating layer belong to two independent memory spaces of the process respectively;
[0069] a third loading unit for dynamically loading a new component into the hot updating layer and replacing the old component in the hot updating layer with the new component.
[0070] The foregoing is a schematic scheme of the data-oriented hot updating device according to the embodiment. It should be noted that the technical scheme of the data-oriented hot updating device and the technical scheme of the data-oriented hot updating method described above belong to the same concept, and the details of the technical scheme of the data-oriented hot updating device that are not described in detail can be seen from the description of the technical scheme of the data-oriented hot updating method.
[0071] In an embodiment of the present application, a computing device is also provided, which includes a memory, a processor, and computer instructions stored in the memory and executable on the processor, and the processor executes the instructions to implement the steps of the data-oriented hot updating method.
[0072] The foregoing is a schematic scheme of the computing device according to the embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the data-oriented hot updating method described above belong to the same concept, and the details of the technical scheme of the computing device that are not described in detail can be seen from the description of the technical scheme of the data-oriented hot updating method.
[0073] In an embodiment of the present application, a computer readable storage medium is also provided, which stores computer instructions, and the instructions are executed by a processor to implement the steps of the data-oriented hot updating method as described above.
[0074] The foregoing is a schematic scheme of the computer readable storage medium according to the embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the data-oriented hot updating method described above belong to the same concept, and the details of the technical scheme of the storage medium that are not described in detail can be seen from the description of the technical scheme of the data-oriented hot updating method.
[0075] The foregoing describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown or sequential order in order to achieve the desired results. In some implementations, multitasking and parallel processing can be advantageous.
[0076] The computer readable medium can include any entity or apparatus capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable medium can include appropriate additions or subtractions according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
[0077] It should be noted that for the foregoing method embodiments, the descriptions are expressed as a combination of a series of actions for the sake of simplicity, but those skilled in the art should know that the present application is not limited by the order of the described actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.
[0078] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.
[0079] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The alternative embodiments do not describe all the details and do not limit the present application to the specific embodiments described. Obviously, according to the content of the present application, many modifications and changes can be made. The present application selects and describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can well understand and utilize the present application. The present application is limited by the claims and their entire scope and equivalents.
Claims
1. A data-oriented hot update method, characterized by, The application comprises: The business logic is divided into states, components and component agents; wherein, the states only include data related to the business logic; the components are logical processing units related to the states, and the components further include instances of the component agents; the component agents correspond to the components one by one, and the component agents include methods for accessing state instances and methods for obtaining component instances corresponding thereto; The states and component agents are loaded into a kernel layer of a process, and the components are loaded into a hot update layer of the process; wherein, the kernel layer and the hot update layer belong to two independent memory spaces in the process respectively; The old components in the hot update layer are replaced with new components by dynamically loading the new components into the hot update layer, including: after the old component instances to be replaced in the hot update layer are unloaded, the new components are dynamically loaded into the hot update layer; then, instances of the new components are created in a component cache of the hot update layer, and the association between the new components and the component agents is constructed.
2. The method of claim 1, wherein, The states provide access methods for various data types.
3. The method of claim 1, wherein, The method for obtaining component instances corresponding thereto comprises: The component agents obtain component instances corresponding thereto from a component cache in the hot update layer.
4. The method of claim 1, wherein, The new components implement new processing logic around the states.
5. A data-oriented hot update apparatus, comprising: The application comprises: A state unit, a component unit and a component agent unit, which constitute the business logic of an application; wherein, the state unit only includes data related to the business logic; the component unit is a logical processing unit related to the state unit, and the component unit further includes instances of the component agent unit; the component agent unit corresponds to the component unit one by one, and the component agent unit includes methods for accessing state unit instances and methods for obtaining component unit instances corresponding thereto; A first loading unit for loading the state unit and the component agent unit into a kernel layer of a process; A second loading unit for loading the component unit into a hot update layer of the process; wherein, the kernel layer and the hot update layer belong to two independent memory spaces of the process respectively; A third loading unit for dynamically loading new component units into the hot update layer and replacing old component units in the hot update layer with the new component units, including: after the old component unit instances to be replaced in the hot update layer are unloaded, the new component units are dynamically loaded into the hot update layer; then, instances of the new component units are created in a component cache of the hot update layer, and the association between the new component units and the component agent units is constructed.
6. A computing device comprising a memory, a processor, and computer instructions stored on the memory and executable on the processor, wherein, The processor executes the instructions to implement the steps of the method of any one of claims 1-4.
7. A computer-readable storage medium storing computer instructions, wherein, The instructions are executed by the processor to implement the steps of the method of any one of claims 1-4.
Citation Information
Patent Citations
Updating method and system for software development kits, electronic device and storage medium
CN109002320A