Data Hot Update Method, Device, Electronic Device and Readable Storage Medium
By performing differential comparisons in the auxiliary threads of the game client, the data processing time of the main thread during the data hot update is reduced, the game lag caused by the data hot update is solved, and multi-threaded processing is realized.
Patent Information
- Application Number
- CN202211406454.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-10
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2042-11-10
AI Technical Summary
In game applications, due to the large file during data update, the main thread of the client is blocked, causing the game to stutter.
By creating a helper thread in the client of the terminal, the helper thread extracts bare data from the serialized format data, and differential data are obtained by comparing differentials with programming languages in different interpreted languages, and the data processing time of the main thread is reduced.
It shortens the data processing time of the main thread during the hot data update process, avoids application lag, and implements multi-threading based on interpreted languages.
Smart Images

Figure CN115794189B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a method, device, electronic device and computer-readable storage medium for data hot update. Background Art
[0002] Most game applications have a need for data hot update. A large amount of game data in game applications records some information in the game, such as what types of items there are, what equipment there is, and how much attack power the equipment can increase. These metadata are generally filled in as tables by game planners and exported as files in a certain data format and stored on the server side of the game application. When the game application client runs, it can be loaded into memory for use.
[0003] As the functions of game applications continue to expand, game data may need to be adjusted. For example, the diamond rewards for daily tasks can be adjusted. At this time, it is necessary to perform a hot update on the game data.
[0004] However, the process of the client loading game data and parsing it into local memory takes a certain amount of time. The larger the hot update data file, the more time this process takes. When the hot update data file is large, it is very easy to block the main thread of the client, causing game lag. For example, if a game application processes requests sent by players every 100 ms, if the hot update data file is large, the time consumption may be as long as 1000 ms. Such a long hot update time will cause players to feel obvious lag. Summary of the Invention
[0005] This application provides a method, device, electronic device and computer-readable storage medium for data hot update to solve the problem that application lag is easily caused during application data hot update. The specific methods are as follows.
[0006] In a first aspect, this application provides a data hot update method applied to a terminal. A main thread of a client runs in the terminal. The main thread stores target data in a first serialization format and a first structured format of a first interpreted language respectively. The target data in the first structured format is parsed from the target data in the first serialization format. The method includes:
[0007] The main thread, in response to a hot update instruction for the target data, loads updated target data with the first serialization format from a server corresponding to the client, and provides the target data and the updated target data with the first serialization format to an auxiliary thread created by the main thread;
[0008] The auxiliary thread extracts the target raw data and the updated target raw data that do not have the first serialization format from the target data and the updated target data with the first serialization format respectively, performs a difference comparison on the updated target raw data and the target raw data through a preset programming language different from the first interpreted language to obtain difference data, and provides the difference data to the main thread;
[0009] The main thread integrates the data according to the difference data and the target data with the first structured format to obtain the updated target data with the first structured format, and deletes the target data with the first serialization format and the target data with the first structured format.
[0010] In a second aspect, an embodiment of the present application further provides a data hot update device, which is applied to a terminal. A main thread of a client runs in the terminal. The main thread stores target data in a first serialization format and a first structured format of a first interpreted language respectively. The target data in the first structured format is parsed from the target data in the first serialization format. The device includes:
[0011] A first control module, configured to control the main thread to, in response to a hot update instruction for the target data, load the updated target data with the first serialization format from a server corresponding to the client, and provide the target data with the first serialization format and the updated target data to an auxiliary thread created by the main thread;
[0012] A second control module, configured to control the auxiliary thread to extract the target raw data and the updated target raw data that do not have the first serialization format from the target data and the updated target data with the first serialization format respectively, perform a difference comparison on the updated target raw data and the target raw data through a preset programming language different from the first interpreted language to obtain difference data, and provide the difference data to the main thread;
[0013] A third control module, configured to control the main thread to integrate the data according to the difference data and the target data with the first structured format to obtain the updated target data with the first structured format, and delete the target data with the first serialization format and the target data with the first structured format.
[0014] In a third aspect, an embodiment of the present application further provides an electronic device, including:
[0015] A processor; and
[0016] A memory for storing a program, which, after the electronic device is powered on and runs the program through the processor, executes the method described in the first aspect.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing a program, which is run by a processor to execute the method described in the first aspect.
[0018] Compared with the prior art, the present application has the following advantages:
[0019] In the data hot update method provided by the embodiment of the present application, compared with the target data after update, the amount of differential data is much smaller. After the differential data with a smaller amount is obtained by comparison through an auxiliary thread, the main thread only needs to perform data integration and other processing on the differential data with a smaller amount. Therefore, the data processing time required by the main thread during data hot update is shortened, making it less likely to cause application jamming during data hot update. In addition, in this method, for the main thread based on an interpreted language, true multi-threading processing can be achieved during data hot update. Furthermore, in this method, the server does not need to perform data version management, avoiding the problem that data version management is prone to errors. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is a flowchart of a data hot update method provided by an embodiment of the present application;
[0021] Figure 2 is a flowchart of another data hot update method provided by an embodiment of the present application;
[0022] Figure 3 is a flowchart of a third data hot update method provided by an embodiment of the present application;
[0023] Figure 4 is a flowchart of an example of a data hot update method provided by an embodiment of the present application;
[0024] Figure 5 is a flowchart of another example of a data hot update method provided by an embodiment of the present application;
[0025] Figure 6 is a schematic diagram of data processing and interaction by threads in a data hot update method provided by the related art;
[0026] Figures 7 - 13 is a schematic diagram of data processing and interaction by threads in an example of a data hot update method provided by an embodiment of the present application;
[0027] Figure 14 is a block diagram of a data hot update device provided by an embodiment of the present application;
[0028] Figure 15 It is a schematic diagram of the logical structure of an electronic device provided by an embodiment of the present application for realizing data hot update. Detailed implementation manners
[0029] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the connotation of the present application. Therefore, the present application is not limited by the specific implementations disclosed below.
[0030] Before elaborating on the implementation manners of the present application in detail, some related concepts and related technologies involved in the present application are introduced first.
[0031] I. Related concepts:
[0032] 1. Interpreted languages and compiled languages
[0033] Programming languages can be divided into compiled languages and interpreted languages from the perspective of execution principles (or translation methods).
[0034] Computers cannot directly understand languages other than machine languages. Therefore, the code written by humans needs to be compiled into machine languages and then handed over to the computer for execution. There are two ways to translate other languages into machine languages: compilation and interpretation. The difference between the two lies in the translation time point.
[0035] For compiled languages, a dedicated compilation process is required before the program is executed to compile the program source file into a machine language file. It does not need to be recompiled during runtime, and the execution efficiency is relatively high. However, the disadvantage is that compiled languages rely on compilers and have poor cross-platform performance.
[0036] For interpreted languages, the source code does not need to be pre-compiled. Instead, for each line of the source code that is interpreted, it is executed immediately, that is, it is interpreted and executed simultaneously. The execution efficiency of interpreted languages is relatively low, but they have good cross-platform performance.
[0037] Representative languages of compiled languages include: C language, C++.
[0038] Representative languages of interpreted languages include: python, JavaScript, Perl, Shell, etc.
[0039] 2. Global Interpreter Lock (GIL)
[0040] The GIL lock is a mechanism used in interpreted languages to synchronize the execution of threads. Among the threads of the same interpreted language, only the thread holding the GIL lock can execute, ensuring that only one thread is executing at the same time in the same interpreted language.
[0041] It should be noted that the GIL lock of an interpreted language is only valid for the threads of this interpreted language and is invalid for the threads of other interpreted languages. For example, the GIL lock of interpreted language a (abbreviated as GIL-a) is only valid for the threads that need to call the API (Application Programming Interface) of interpreted language a, while the threads that need to call the API of interpreted language b are restricted by the GIL lock of interpreted language b (abbreviated as GIL-b) and are not restricted by GIL-a. That is, among the threads that need to call the API of interpreted language a, only the thread that obtains GIL-a can execute, which has nothing to do with GIL-b. Similarly, among the threads that need to call the API of interpreted language b, only the thread that obtains GIL-b can execute, which has nothing to do with GIL-a.
[0042] Of course, the GIL lock of an interpreted language is also invalid for the threads of compiled languages. In short, the GIL lock of an interpreted language is invalid across programming languages.
[0043] 3. Procedure-Oriented and Object-Oriented
[0044] Object-oriented needs to be considered in combination with procedure-oriented. Programming languages can be divided into object-oriented programming languages and procedure-oriented programming languages from the core programming concept.
[0045] Procedure-Oriented: Break things down into several steps (equivalent to breaking them down into individual methods and data), and then execute them in a certain order.
[0046] Object-Oriented: Abstract things into the concept of objects. First, abstract the objects, then assign some attributes and methods to the objects, and then let each object execute its own methods.
[0047] Representative languages of procedure-oriented programming languages include: C language, Basic, etc.
[0048] Representative languages of object-oriented programming languages include: C++, Python, etc.
[0049] II. Related Technologies:
[0050] Currently, in order to avoid causing game lag during hot updates of game data, there are the following two solutions:
[0051] Idea 1: Adopt a multi-threaded processing method, that is, the main thread of the game client runs normally, and another thread is specifically created to load new game data. After the loading is completed, the main thread is notified to perform hot updates.
[0052] Idea 2: Perform hot updates through incremental differential files. For example, if the item table of the game contains 1,000 items and a new item is added, making it 1,001 items. According to the solution of Idea 1, the data files of these 1,001 items will be loaded. The solution of Idea 2 is to load the newly added item separately. After the loading is completed, it is merged with the item table data already existing in the game client's memory.
[0053] However, there are still deficiencies in the implementation of the above ideas.
[0054] For Idea 1, in interpreted languages such as Python, due to the existence of the GIL lock, each thread needs to acquire the GIL lock first when it needs to call the API of the interpreted language. Only the thread holding the GIL lock can execute to ensure that in an interpreted language, only one thread is running at the same time. Therefore, for game applications that implement hot update-related functions based on interpreted languages, true multi-threaded processing cannot be achieved, that is, the solution of Idea 1 cannot be implemented. When another thread is loading game data, the main thread is also blocked.
[0055] For Idea 2, its main drawback is that the hot update logic becomes more complex. Originally, it only needed to completely replace the game data file on the server side and then the client side could load it (i.e., the solution in the background technology). However, the solution of Idea 2 requires comparing the differences between game data files of different versions, generating the differential part and storing it in a special directory, and then the client side loads the differential part. After the loading is completed, it is merged with the old game data in the client's memory. The essence of this differential part is to manage the version of the metadata when the game is running, and version management is most prone to errors. It is necessary to ensure that this differential part is calculated based on the correct old version. However, as the number of hot updates increases, there will be more and more metadata versions, and the calculation of the differential part between two versions is more likely to go wrong. Seriously, it will cause some functions of the game to be unusable.
[0056] It should be noted that the above exemplary scenario of the hot update of game application data is only an example among many scenarios to which the data hot update method provided in this application can be applied. This exemplary scenario does not limit this application. In actual applications, this data hot update method can also be used for the hot update of other application data.
[0057] To solve the above problems, the present application provides a data hot update method, which is applied to a terminal. That is, the execution subject of this data hot update method is the terminal. In the embodiments of the present application, the terminal may specifically be a desktop computer, a laptop computer, a game console, a smart watch, a tablet computer, a mobile phone, a television, etc., or may also be other electronic devices, which are not specifically limited in the present application. The client described in the embodiments of the present application may be installed in the terminal.
[0058] In one implementation manner, the client (also referred to as the user side) described in the embodiments of the present application may be the client of a game application. The client corresponds to the server of the game application. The server of the game application can interact with the client of the game application and can provide resources for the client of the game application, respond to requests of the client of the game application, and so on.
[0059] The game application may be a multiplayer online battle arena (MOBA) application, a real-time strategy game (RTS) application, a shooting virtual game application, a board game virtual game application, etc., but is not limited thereto.
[0060] The main thread of the client runs in the terminal. The main thread stores target data in the first serialization format and the first structured format of the first interpreted language respectively. Among them, the target data in the first structured format is obtained by parsing the target data in the first serialization format.
[0061] In the embodiments of the present application, the data stored in the first serialization format of the first interpreted language is the original metadata file that has not been parsed. The data stored in the first structured format of the first interpreted language is the data obtained by parsing the original metadata file. That is, by parsing the target data in the first serialization format, the target data in the first structured format can be obtained. By serializing the target data in the first structured format, the target data in the first serialization format can be obtained.
[0062] In one implementation manner, the first interpreted language may be an object-oriented interpreted language. For the object-oriented first interpreted language, the first serialization format is a string format with a string identifier (such as single quotes '', double quotes "", slashes / , etc.) of the first interpreted language, and the first structured format is an object format. Among them, the string format is convenient for transmission and for other programming languages to process. And the object-oriented interpreted language operates on objects. Therefore, when processing data through the object-oriented interpreted language, the data needs to be parsed into an object first, and then data processing operations can be performed through the object.
[0063] In another embodiment, the first interpreted language may also be a procedure-oriented interpreted language. For the procedure-oriented first interpreted language, the first serialization format is a string format with a string identifier (such as single quotes '', double quotes "", slashes / , etc.) of the first interpreted language, and the first structured format is a structure format. Among them, the string format is convenient for transmission and for other programming languages to process. And the procedure-oriented interpreted language operates on structures. Therefore, when processing data through the procedure-oriented interpreted language, the data needs to be parsed into a structure first, and then data processing operations can be performed through the structure.
[0064] That is, in the embodiments of the present application, the main thread stores the same target data in two data formats of the first interpreted language respectively. One is the already parsed structured format, and the other is the original serialized format that has not been parsed into a structured format. Correspondingly, when updating the target data, that is, updating the target data in both of these two data formats.
[0065] Such as Figure 1 shown, the method includes the following steps S110 to step S130.
[0066] Step S110: The main thread, in response to a hot update instruction for the target data, loads the updated target data with the first serialization format from the server corresponding to the client (S11), and provides the target data with the first serialization format and the updated target data to an auxiliary thread created by the main thread (S12).
[0067] In the embodiments of the present application, the hot update instruction for the target data may be actively triggered by the user on the client, or may be automatically triggered by the server after the target data is updated. The embodiments of the present application do not limit this.
[0068] Related personnel can update the target data in the server corresponding to the client to obtain the updated target data, and store it in the disk of the server. In response to the hot update instruction for the target data, the main thread can load the updated target data with the first serialization format from the disk of the server. Among them, the first serialization format is convenient for transmission. Therefore, the server can transmit the updated target data in the disk to the main thread of the client in the first serialization format.
[0069] So far, the main thread stores the old data and new data in the first serialization format, and the old data in the first structured format.
[0070] After that, the main thread can provide the target data and the updated target data with the first serialization format to the auxiliary thread. Among them, the auxiliary thread is created by the main thread, that is, the auxiliary thread is a child thread of the main thread. In the embodiment of the present application, the auxiliary thread needs to be created at any time node after the main thread is created and before the main thread provides the target data and the updated target data with the first serialization format to it, and at the latest, it needs to be created before the main thread is about to provide the target data and the updated target data with the first serialization format.
[0071] Step S120: The auxiliary thread extracts the target bare data and the updated target bare data that do not have the first serialization format from the target data and the updated target data with the first serialization format respectively (S21), compares the updated target bare data with the target bare data through a preset programming language different from the first interpreted language to obtain the difference data, and provides the difference data to the main thread (S22).
[0072] In this step, after the auxiliary thread obtains the target data and the updated target data with the first serialization format provided by the main thread, it can extract the target bare data that does not have the first serialization format from the target data with the first serialization format, that is, remove the format identifier of the target data with the first serialization format to obtain the target bare data, that is, a bare string. The auxiliary thread can also extract the updated target bare data that does not have the first serialization format from the updated target data with the first serialization format, that is, remove the format identifier of the updated target data with the first serialization format to obtain the updated target bare data, that is, a bare string.
[0073] Among them, the format identifiers usually appear in pairs at the head and tail of the bare data. For example, paired single quotes (‘’), paired double quotes (“”), etc. Therefore, it is easy to distinguish them from the bare data. In addition, the format identifiers adopted may also appear in the bare data. For example, when the format identifier adopts the English single quote (’), if the bare data is I'm acoder!, that is, the data with this format identifier is 'I'ma coder!', then the auxiliary thread is very likely to pair the first single quote with the second single quote after the word I. For such situations, when generating the bare data, some special symbols can be added before the second single quote to distinguish it from the format identifier (it is better if it can be distinguished from various format identifiers in various programming languages). For example, add a backslash (\) before the second single quote, then the data with the format identifier with the English single quote is 'I\'m a coder!'. In this way, the auxiliary thread can also treat the second single quote as bare data.
[0074] It should be noted that the above strategy is only an exemplary strategy for facilitating the auxiliary thread to identify and remove the format identifiers in the data, and this exemplary strategy does not limit the present application. It can be understood that other strategies can also be adopted to facilitate the auxiliary thread to distinguish the format identifiers in the data.
[0075] Based on the above strategy, the auxiliary thread can easily identify and remove the format identifiers in the data, so as to obtain the raw data without format identifiers.
[0076] In the embodiment of the present application, the preset programming language is any programming language different from the first interpreted language. The auxiliary thread can then perform a difference comparison based on two raw strings through the preset programming language to obtain difference data and provide the difference data to the main thread.
[0077] Optionally, the preset programming language may include at least one of a compiled language and a second interpreted language different from the first interpreted language. In practical applications, it is sufficient to select a compiled language or an interpreted language different from the first interpreted language as the preset programming language.
[0078] In the embodiment of the present application, since the auxiliary thread can obtain the difference data between the updated target raw data and the target raw data through a preset programming language different from the first interpreted language, in the process of difference comparison, the auxiliary thread does not need to use the first interpreted language (including calling APIs / functions / libraries written in the first interpreted language), and thus does not need to obtain the GIL lock of the first interpreted language. Therefore, compared with the deficiencies of the above-mentioned idea 1, in the data hot update method provided in the embodiment of the present application, for the main thread based on the interpreted language, true multi-threading processing can be achieved during the data hot update process.
[0079] In practical applications, the structured format may not necessarily be processed by a programming language other than the programming language to which it belongs, while the serialized format is suitable for transmission, so many programming languages can process the serialized format. Therefore, compared with the structured format, the cross-programming language property of the serialized format has advantages. That is, the structured format is strongly related to the programming language to which it belongs, while the serialized format is weakly related to the programming language to which it belongs, and can even be considered irrelevant.
[0080] Therefore, in the embodiment of the present application, the auxiliary thread implementing functions based on another programming language may not necessarily be able to process the data in the first structured format. Based on this, the main thread can provide the old data and new data in the serialized format of a programming language to the auxiliary thread instead of providing the old data and new data in the structured format of the programming language to the auxiliary thread. The auxiliary thread can then process the serialized data provided by the main thread through another programming language and then perform a difference comparison.
[0081] Step S130: The main thread integrates data based on the differential data and the target data with the first structured format to obtain updated target data with the first structured format (S31), and deletes the target data with the first serialized format and the target data with the first structured format (S32).
[0082] In this step, the main thread can integrate the differential part obtained by the differential comparison with the auxiliary thread with the target data with the first structured format to update the target data with the first structured format, so as to obtain updated target data with the first structured format.
[0083] At this point, the main thread stores the old data and new data in the first serialized format, as well as the old data and new data in the first structured format.
[0084] After that, the main thread can delete the old data in the first serialized format and the old data in the first structured format, and only retain the new data in the first serialized format and the new data in the first structured format, thus realizing the hot update of the target data of two data structures.
[0085] In the embodiment of the present application, compared with the updated target data, the amount of differential data is much smaller. After the auxiliary thread compares to obtain the differential data with a smaller amount, the main thread only needs to perform data integration and other processing on the differential data with a smaller amount. Therefore, the data processing time required by the main thread in the data hot update process is shortened, making it not easy to cause application lags during data hot updates.
[0086] In the embodiment of the present application, the data hot update can be implemented by the main thread and the auxiliary thread of the client. Therefore, the server only needs to directly replace the old data with the new data locally on the server and provide the new data to the client, without the server performing data version management. Therefore, compared with the deficiency of the above-mentioned idea 2, in the data hot update method provided in the embodiment of the present application, the server does not need to perform data version management, avoiding the problem that data version management is prone to errors.
[0087] The data hot update method provided by the embodiments of the present application can save the same data in two data formats of a first interpreted language, namely a first serialization format and a first structured format. After the main thread loads the new data in the first serialization format from the server, it provides the old data and the new data in the first serialization format to the auxiliary thread together. The auxiliary thread extracts the old raw data and the new raw data from them for difference comparison to obtain the difference data, and provides it to the main thread. The main thread integrates the data according to the difference data and the old data in the first structured format to obtain the new data in the first structured format. Furthermore, the main thread deletes the old data in the two data formats, thus retaining the new data in the two data formats.
[0088] Compared with the updated target data, the amount of the difference data is much smaller. After the auxiliary thread in the embodiments of the present application obtains the difference data with a smaller amount through comparison, the main thread only needs to perform data integration and other processing on the difference data with a smaller amount. Therefore, the data processing time required by the main thread in the data hot update process is shortened, and it is not easy to cause application lags during data hot update.
[0089] In addition, in the embodiments of the present application, since the auxiliary thread can obtain the difference data between the updated target raw data and the target raw data through a preset programming language different from the first interpreted language, during the difference comparison process, the auxiliary thread does not need to use the first interpreted language, and thus does not need to obtain the GIL lock of the first interpreted language. In the data hot update method provided by the embodiments of the present application, for the main thread based on the interpreted language, true multi-threading processing can be achieved during the data hot update process.
[0090] Moreover, in the embodiments of the present application, the data hot update can be implemented by the main thread and the auxiliary thread of the client. Therefore, the server only needs to directly replace the old data with the new data locally on the server and provide the new data to the client, without the server performing data version management. Therefore, in the data hot update method provided by the embodiments of the present application, the server does not need to perform data version management, avoiding the problem that data version management is prone to errors.
[0091] As Figure 2 shown, in one implementation manner, the steps "According to the updated target raw data and the target raw data, perform difference comparison through a preset programming language different from the first interpreted language to obtain the difference data, and provide the difference data to the main thread" (i.e., step S22) executed by the auxiliary thread in step S120 can be specifically implemented through the following steps S221 to S223.
[0092] Step S221: The auxiliary thread processes the updated target raw data into updated target data in a second structured format with a preset programming language, and processes the target raw data into target data in a second structured format.
[0093] In this step, the auxiliary thread can call relevant APIs / functions / libraries of the preset programming language, and through the called APIs / functions / libraries, process the updated target raw data into data in a second structured format with the preset programming language. That is, according to the definition rules of the second structured format in the preset programming language, format identifiers in the second structured format are added to the updated target raw data, so as to obtain updated target data in the second structured format.
[0094] The auxiliary thread can also process the target raw data into target data in a second structured format in the above manner.
[0095] For the step of processing to obtain updated target data in the second structured format and the step of processing to obtain target data in the second structured format, the present application embodiment does not limit the order of these two steps.
[0096] In an optional implementation manner, when the first interpreted language is python, the preset programming language can adopt C++, and the second structured format can be JSON, msgpack, etc.
[0097] Step S222: The auxiliary thread performs a difference comparison on the updated target data and the target data in the second structured format through the preset programming language, and obtains difference data in the second structured format.
[0098] In this step, the auxiliary thread can perform a difference comparison on the updated target data and the target data in the second structured format through functions, interfaces or codes written in the preset programming language for difference comparison, so as to obtain the difference data between the two, and the difference data also has the second structured format.
[0099] Among them, the difference data specifically refers to the part of the updated target data that is different from the target data. If a certain parameter exists in both the updated target data and the target data, but in the updated target data, the parameter value of this parameter has changed, then the changed parameter value will be discovered during the difference comparison process, and this parameter and its parameter value will be selected as a set of difference data. If a certain parameter exists in the updated target data but does not exist in the target data, then this parameter and its parameter value are new data, and this new data will be discovered during the difference comparison process, and this parameter and its parameter value will be selected as a set of difference data. In summary, the data that has changed in the updated target data relative to the target data, as well as the newly added data, can all be selected through the difference comparison. The data set selected through the difference comparison is used as the difference data.
[0100] In one implementation, the parameter and its parameter value can be in the form of a key-value pair, that is, the form of key-key value, so that the auxiliary thread can compare the keys and their key values in the updated target data and the target data to implement the difference comparison process between the updated target data and the target data. Among them, for a key and its key value in the updated target data, as long as one of the key and its key value is inconsistent with the data in the target data, this key and its key value can be selected as a set of difference data.
[0101] Step S223: The auxiliary thread processes the difference data with the second structured format into difference data with the data format of the first interpreted language, and provides the difference data with the data format of the first interpreted language to the main thread.
[0102] In this step, the auxiliary thread can process the difference data with the second structured format into difference data with the data format of the first interpreted language, that is, convert the difference data from the format that can be processed by the preset programming language to the format that can be processed by the first interpreted language. Furthermore, the auxiliary thread can return the difference data that can be processed by the first interpreted language to the main thread that can process data through the first interpreted language, so that the main thread can implement the subsequent step S130 through the first interpreted language.
[0103] In this embodiment, after the target raw data and the updated target raw data are extracted by the auxiliary thread, since the auxiliary thread needs to perform data difference comparison using a preset programming language subsequently, the auxiliary thread can convert the target raw data and the updated target raw data into a second structured format that can be processed by the preset programming language first, and then perform difference comparison on the data with the second structured format through the preset programming language to obtain difference data that also has the second structured format. Further, since the main thread implements subsequent steps based on the first interpreted language, after the difference comparison by the difference thread, the difference data obtained from the comparison also needs to be converted into a data format that can be processed by the first interpreted language, and then returned to the main thread. In this way, the main thread can perform subsequent processing on the comparison result of the auxiliary thread, and finally achieve hot update.
[0104] In summary, to avoid calling the API / functions / libraries of the first interpreted language, the auxiliary thread can convert the data that needs to be compared for differences into a format that can be processed by other programming languages. In this way, the auxiliary thread can perform difference comparison of new and old data through other programming languages. After the comparison is completed, the auxiliary thread converts the comparison result into a format that can be processed by the first interpreted language, and then returns it to the main thread based on the first interpreted language. In this way, by converting the format of the data to be compared, the auxiliary thread can perform difference comparison of new and old data using other programming languages rather than the first interpreted language, without calling the API / functions / libraries of the first interpreted language, thus avoiding blocking the main thread based on the first interpreted language during the difference comparison process.
[0105] In addition, it can be understood that the embodiments of the present application do not exclude programming languages that can directly compare the differences of raw data. That is, in the embodiments of the present application, if there is a programming language other than the first interpreted language that can directly compare the new and old raw data, then this programming language can also be used as the preset programming language in the embodiments of the present application to implement the data difference comparison process. And when performing difference comparison through this programming language, there is no need to perform the format conversion process described in steps S221 - S223.
[0106] Further, since the formats that can be processed by the first interpreted language include the first serialization format and the first structured format, the embodiments of the present application provide two options for selection. One is that the auxiliary thread converts the obtained difference data into the first serialization format and then returns it to the main thread (hereinafter referred to as Option 1), and the other is that the auxiliary thread converts the obtained difference data into the first structured format and then returns it to the main thread (hereinafter referred to as Option 2). The following provides a detailed introduction to these two options.
[0107] Option 1: Step S223 can be specifically implemented through the following steps S2231 - S2232.
[0108] Step S2231: The auxiliary thread converts the differential data with the second structured format into differential data with the first serialized format.
[0109] Step S2232: The auxiliary thread parses the differential data with the first serialized format into differential data with the first structured format, and provides the differential data with the first structured format to the main thread.
[0110] Correspondingly, the step “perform data integration based on the differential data and the target data with the first structured format to obtain updated target data with the first structured format” (i.e., step S31) executed by the main thread in step S130 can be specifically implemented by the following step S311.
[0111] Step S311: The main thread integrates the differential data with the first structured format and the target data with the first structured format to obtain updated target data with the first structured format.
[0112] In Solution 1, the auxiliary thread can first call the relevant APIs / functions / libraries of the first interpreted language to convert the differential data with the second structured format in a preset programming language into differential data with the first serialized format of the first interpreted language, and then call the relevant APIs / functions / libraries of the first interpreted language to further convert it into differential data with the first structured format of the first interpreted language. The auxiliary thread provides the differential data with the first structured format to the main thread.
[0113] Correspondingly, after obtaining the differential data with the first structured format, the main thread can directly integrate the differential data with the first structured format and the target data, so as to obtain updated target data with the first structured format.
[0114] In Solution 1, the step of converting the format of the differential data from the first serialized format to the first structured format is implemented by the auxiliary thread.
[0115] Solution 2: Step S223 can be specifically implemented by the following step S2233.
[0116] Step S2233: The auxiliary thread converts the differential data with the second structured format into differential data with the first serialized format, and provides the differential data with the first serialized format to the main thread.
[0117] Correspondingly, step S31 can be specifically implemented by the following steps S312 to S313.
[0118] Step S312: The main thread parses the differential data with the first serialization format into differential data with the first structured format.
[0119] Step S313: The main thread integrates the differential data with the first structured format and the target data with the first structured format to obtain updated target data with the first structured format.
[0120] In Solution 2, the auxiliary thread can call the relevant APIs / functions / libraries of the first interpreted language to convert the differential data with the second structured format in the preset programming language into differential data with the first serialization format of the first interpreted language, and then directly provide the differential data with the first serialization format to the main thread.
[0121] Correspondingly, after obtaining the differential data with the first serialization format, the main thread first calls the relevant APIs / functions / libraries of the first interpreted language to convert it into differential data with the first structured format of the first interpreted language, and then integrates the differential data with the first structured format and the target data, so as to obtain updated target data with the first structured format as well.
[0122] In Solution 2, the step of converting the format of the differential data from the first serialization format to the first structured format is implemented by the main thread.
[0123] In the above Solution 1 and Solution 2, when the main thread performs data integration, for the parameters that exist in both the differential data and the target data but have different parameter values, the main thread can replace the parameter value of the parameter in the target data with the parameter value of the parameter in the differential data, that is, replace the original parameter value with the new parameter value. For the parameters that exist in the differential data but do not exist in the target data, the main thread can add the parameter and its parameter value to the target data. In this way, data integration is achieved.
[0124] In specific applications, Solution 1 and Solution 2 can be selected according to actual needs, and the embodiments of the present application do not make any limitations in this regard.
[0125] In addition, during the entire process of data hot update, when the main thread or the auxiliary thread uses the first interpreted language, it will be restricted by the GIL lock of the first interpreted language, that is, the main thread or the auxiliary thread can only use the first interpreted language when holding the GIL lock of the first interpreted language. The acquisition and release of the GIL lock of the first interpreted language during the data hot update process will be introduced in detail below.
[0126] It should be noted in advance that for the GIL lock mentioned below, unless otherwise specified, it is understood as the GIL lock of the first interpreted language for the sake of concise and easy-to-understand expression.
[0127] In the embodiments of the present application, the acquisition and / or release of the GIL lock is involved in the following 4 processes.
[0128] The first process: The main thread needs to provide the target data with the first serialization format and the updated target data to the auxiliary thread while holding the GIL lock, and after providing the data to the auxiliary thread, it needs to release the GIL lock.
[0129] Based on the above first process, as Figure 3 shown, the step "providing the target data with the first serialization format and the updated target data to the auxiliary thread created by the main thread" (i.e., step S12) executed by the main thread in step S110 can be specifically implemented by the following step S121.
[0130] Step S121: The main thread provides the target data with the first serialization format and the updated target data to the auxiliary thread created by the main thread while holding the global interpreter lock.
[0131] Correspondingly, after step S12, the data hot update method may further include the following step S13.
[0132] Step S13: The main thread releases the global interpreter lock.
[0133] It should be noted here that the main thread does not necessarily release the GIL lock immediately after providing data to the auxiliary thread (i.e., step S12), but will release the GIL lock after the main thread has executed the current time slice. If providing data to the auxiliary thread happens to be the last step of the main thread's current time slice, the main thread will release the GIL lock immediately after providing data to the auxiliary thread. If providing data to the auxiliary thread is not the last step of the main thread's current time slice, that is, after providing data to the auxiliary thread, the main thread still needs to perform other tasks in the current time slice, then the main thread will release the GIL lock immediately after executing the current time slice.
[0134] Among them, the time slice is the time allocated by the terminal CPU (Central Processing Unit) to each thread. The preemption of CPU resources by each thread can be reflected in the preemption of time slices by each thread. The larger the time slice allocated to a thread, the longer the running time and the shorter the waiting time of the thread.
[0135] In the first process described above, the main thread needs to interact with the auxiliary thread while holding the GIL lock of the first interpreted language, so as to provide data in the data format of the first interpreted language to the auxiliary thread, and release the GIL lock of the first interpreted language after the current time slice of the main thread is executed, so that the auxiliary thread can subsequently obtain the GIL lock of the first interpreted language. The auxiliary thread can interact with the main thread to obtain the data in the data format of the first interpreted language provided by the main thread only when holding the GIL lock of the first interpreted language. In this way, the smooth interaction of the data required for differential comparison can be ensured.
[0136] The second process: The auxiliary thread needs to obtain the target data and the updated target data in the first serialization format provided by the main thread while holding the GIL lock, and release the GIL lock after obtaining them.
[0137] Based on the second process described above, as Figure 3 shown, before step S21, the data hot update method may further include the following steps S24 to S25.
[0138] Step S24: The auxiliary thread obtains the target data and the updated target data in the first serialization format provided by the main thread when obtaining the global interpreter lock.
[0139] Step S25: The auxiliary thread releases the global interpreter lock.
[0140] In the second process described above, the main thread provides data in the data format of the first interpreted language to the auxiliary thread. Therefore, the auxiliary thread needs to first obtain the GIL lock and then, while holding the GIL lock, can interact with the main thread to obtain the data in the data format of the first interpreted language provided by the main thread. In this way, the smooth interaction of the data required for differential comparison can be ensured.
[0141] In addition, since the differential comparison process performed by the auxiliary thread does not need to use the first interpreted language, the auxiliary thread can immediately release the GIL lock after obtaining the data provided by the main thread, thus facilitating the execution of other threads that need this GIL lock. That is, when the auxiliary thread performs differential comparison, other threads that need this GIL lock can obtain this GIL lock and implement some functions of this thread through the first interpreted language.
[0142] Of course, in practical applications, if the preset programming language used by the auxiliary thread during the difference comparison process is a second interpreted language different from the first interpreted language, the auxiliary thread needs to hold the GIL lock of the second interpreted language to perform the difference comparison. After the difference comparison is completed and the second interpreted language is no longer needed, the auxiliary thread can release the GIL lock of the second interpreted language.
[0143] If the preset programming language used by the auxiliary thread during the difference comparison process is a compiled language, the difference comparison can be performed without obtaining any GIL lock because, as mentioned above, the GIL lock is only a mechanism of interpreted languages and does not exist in compiled languages.
[0144] It should be noted that after the main thread releases the GIL lock in the above first process, the auxiliary thread may not be able to immediately obtain the GIL lock to perform the above second process. After a GIL lock is released, it will be obtained by the thread with the highest current priority. After the main thread releases the GIL lock in the above first process, the auxiliary thread is not necessarily the thread with the highest current priority. If it is, the auxiliary thread can immediately obtain the GIL lock; if not, the auxiliary thread needs to wait until a thread with a higher priority than it has finished using the GIL lock and releases it before it can obtain the GIL lock.
[0145] The third process: The auxiliary thread needs to convert the difference data from the data format of the preset programming language to the data format of the first interpreted language while holding the GIL lock, and release the GIL lock after providing the difference data with the data format of the first interpreted language to the main thread.
[0146] Based on the above third process, as Figure 3 shown, step S223 can be specifically implemented by the following step S2230.
[0147] Step S2230: The auxiliary thread processes the difference data with the second structured format into the difference data with the data format of the first interpreted language while obtaining the global interpreter lock, and provides the difference data with the data format of the first interpreted language to the main thread.
[0148] Correspondingly, after step S223, the data hot update method may further include the following step S224.
[0149] Step S224: The auxiliary thread releases the global interpreter lock.
[0150] Among them, for how the auxiliary thread specifically processes to obtain the difference data with the data format of the first interpreted language, reference can be made to the above-mentioned solution one and solution two, which will not be elaborated here.
[0151] In the above-mentioned third process, after the auxiliary thread finishes the difference comparison, it needs to obtain the GIL lock again. Then, while holding the GIL lock, it can call the APIs / functions / libraries of the first interpreted language to convert the comparison result into the data format of the first interpreted language, and then it can perform data interaction with the main thread to provide the main thread with the comparison result in the data format of the first interpreted language. After the auxiliary thread obtains the data provided by the main thread, the task of the auxiliary thread is completed. Therefore, the auxiliary thread can immediately release the GIL lock, so that the main thread can subsequently obtain the GIL lock and, while holding the GIL lock, perform the subsequent steps of data hot update according to the comparison result provided by the auxiliary thread. In this way, the smooth interaction of the difference comparison result can be ensured.
[0152] The fourth process: The main thread needs to obtain the difference data (i.e., the comparison result provided by the auxiliary thread) in the data format of the preset programming language while holding the GIL lock.
[0153] Based on the above-mentioned fourth process, as Figure 3 shown, before step S31, the data hot update method may further include the following step S30.
[0154] Step S30: The main thread obtains the difference data provided by the auxiliary thread while obtaining the global interpreter lock.
[0155] In the above-mentioned fourth process, the auxiliary thread provides the comparison result in the data format of the first interpreted language to the main thread. Therefore, the main thread needs to obtain the GIL lock again. Then, while holding the GIL lock, it can perform data interaction with the auxiliary thread to obtain the comparison result in the data format of the first interpreted language provided by the auxiliary thread. In this way, the smooth interaction of the difference comparison result can be ensured.
[0156] In addition, after the main thread obtains the comparison result in the data format of the first interpreted language, steps such as data integration and old data deletion need to be performed. And these steps are all performed on the data in the data format of the first interpreted language. Therefore, the main thread needs to continue to hold the GIL lock to perform steps such as data integration and old data deletion on the data in the data format of the first interpreted language, and finally achieve hot update.
[0157] It should be noted that, similar to the above description, after the auxiliary thread releases the GIL lock in the above-mentioned third process, the main thread does not necessarily be able to immediately acquire the GIL lock to perform the above-mentioned fourth process. After a GIL lock is released, it will be acquired by the thread with the highest current priority. After the auxiliary thread releases the GIL lock in the above-mentioned third process, the main thread is not necessarily the thread with the highest current priority. If it is, the main thread can immediately acquire the GIL lock. If not, the main thread needs to wait until the thread with a higher priority than it has finished using the GIL lock and releases it before it can acquire the GIL lock.
[0158] The above is the related process of acquiring and releasing the GIL lock of the first interpreted language during the data hot update process.
[0159] In addition, data transfer between the main thread and the auxiliary thread is involved in the embodiments of the present application. The specific data transfer method will be described below.
[0160] Generally, when a thread transfers data to another thread (referred to as providing data in the embodiments of the present application), it can include two transfer methods: value transfer and reference transfer. Among them, value transfer is equivalent to transferring a copy of the actual parameter (abbreviation: actual argument), while reference transfer is equivalent to transferring the storage address of the actual argument. Briefly speaking, the difference between the two is that since value transfer transfers a copy of the actual argument, the value of the actual argument will not be changed in the value transfer method. However, since reference transfer transfers the storage address of the actual argument, after it is transferred to another thread, the thread needs to find the actual argument according to this address and process it. Therefore, the reference transfer method will change the value of the actual parameter.
[0161] Based on the above content, it can be known that when the transferred data may have other uses, it is not desired that the value of the data is changed during the data transfer process. If it is not desired that the value of the data is changed due to reference transfer, the reference transfer method can be used for data transfer. Therefore, in the embodiments of the present application, considering that the data transferred by the main thread or the auxiliary thread may have other uses, the reference transfer method can be selected to transfer data, including the target data with the first serialization format and the updated target data transferred from the main thread to the auxiliary thread, and the difference data with the data format of the preset programming language transferred from the auxiliary thread to the main thread.
[0162] Based on the above consideration, step S12 can be specifically implemented in the following way: The main thread transfers the first reference of the target data with the first serialization format and the second reference of the updated target data with the first serialization format to the auxiliary thread created by the main thread.
[0163] Accordingly, step S24 can be specifically implemented in the following manner: When the auxiliary thread acquires the global interpreter lock, it reads the target data with the first serialization format from the memory space indicated by the first reference, and reads the updated target data with the first serialization format from the memory space indicated by the second reference.
[0164] Similarly, based on the above considerations, the step "providing the differential data to the main thread" executed by the auxiliary thread in step S22 can be specifically implemented in the following manner: The auxiliary thread passes the third reference of the differential data to the main thread.
[0165] Accordingly, step S30 can be specifically implemented in the following manner: When the main thread acquires the global interpreter lock, it reads the differential data from the memory space indicated by the third reference.
[0166] Next, a specific example of data hot update is provided and compared with the related technology. In the related technology and this example, the main thread can be the game main thread, and the data that needs to be hot updated can be game metadata.
[0167] In addition, in this example, the first interpreted language is Python, the preset programming language is C++, accordingly, the first serialization format can be a Python string, the first structured format can be a Python object, and the second structured format can be a JSON object. Among them, JSON is a lightweight data exchange format that is easy for humans to read and write, and is also easy for programs to parse and use.
[0168] Figure 4 and Figure 5 are respectively the flowcharts of two data hot update examples provided by the embodiments of the present application. The data hot update process of this example will be introduced in detail below in combination with the Figure 4 and Figure 5 in the flow.
[0169] Referring to Figure 6 , in the related technology, when game data hot update is required, the game main thread will load the serialized file of the updated game metadata from the server disk, that is, load a new Python string. Next, the game main thread will parse the loaded content to obtain a new Python object, and then directly replace the existing old Python object with the new Python object. Among them, the parsing of the loaded content in the second step is time-consuming, and when the loaded content is large, it will block the main thread of the game.
[0170] Referring to Figure 7, in the example provided by the embodiments of the present application, in addition to saving the Python object of the game metadata, the main thread also saves the original Python string {"x":[1,2,3],"y":{"a":"xxx","b":"yyy"}} before the Python object is parsed. That is, the main thread saves the game data in two data formats of the Python language.
[0171] Refer to Figure 8 , when the game main thread responds to the hot update instruction for the game metadata and thus triggers the hot update of the game metadata, the game main thread loads the new Python string {"x":[1,2,3,4],"y":{"a":"xxx","b":"yyy","c":"vvv"}} corresponding to the updated game metadata from the server disk into the game main thread.
[0172] Refer to Figure 4 and Figure 5 , the game main thread can create an auxiliary thread at this time. It should be noted that the auxiliary thread should be created at the latest at this time.
[0173] Refer to Figure 9 , the game main thread can, while holding the GIL lock, pass the references of the new and old Python strings to the auxiliary thread by reference passing, and then release the GIL lock. Furthermore, the auxiliary thread, while obtaining the GIL lock, receives the references of the new and old Python strings, and then releases the GIL lock. Then, the auxiliary thread reads out the new and old Python strings from the references of the new and old Python strings respectively.
[0174] Refer to Figure 10 , the auxiliary thread respectively parses the new and old bare strings extracted from the new and old Python strings into a new JSON object corresponding to the new bare string and an old JSON object corresponding to the old bare string. Then, the auxiliary thread can obtain the difference part between the new and old JSON objects, called the difference JSON object, through a difference comparison algorithm written in C++ language. That is, the auxiliary thread can obtain a comparison result with a smaller data volume. It should be noted that the difference comparison here is performed on JSON objects, not Python objects, which means that no Python API is called in this difference comparison step, so the auxiliary thread does not need to hold the GIL lock.
[0175] By comparing the differences, it can be seen that a new element is added at position 3 in x, and the value at this newly added position is 4. The value at position a in y changes from xxx to zzz, and a new element is added at position c in y, and the value at this newly added position is vvv. Next, the auxiliary thread can, when obtaining the GIL lock again, call the API of Python to serialize this part of the content (i.e., the difference JSON object) into a Python string that can be processed by the Python language, obtaining the difference Python string {"x":[3,4],"y":{"a":"xxx","c":"vvv"}}.
[0176] Next, referring to Figure 5 , in one implementation, the auxiliary thread can parse the difference Python string into a difference Python object, push the reference of the difference Python object to the game main thread, and then release the GIL lock. Then, when the main thread obtains the GIL lock again, it receives this reference and reads out the difference Python object from this reference.
[0177] Referring to Figure 11 and Figure 12 , and Figure 4 , in another implementation, the auxiliary thread can push the reference of the difference Python string to the game main thread and release the GIL lock. Then, when the main thread obtains the GIL lock again, it receives this reference and reads out the difference Python string from this reference. The main thread then parses the difference Python string into a difference Python object.
[0178] The above two implementations are respectively reflected in Figure 5 and Figure 4 , where the main differences between the two implementations are marked by dashed boxes.
[0179] In this example, compared with the old Python string, the data volume of the difference Python string has become smaller. Therefore, the time-consuming of the game main thread being blocked caused by the parsing process of the difference Python string is also correspondingly reduced, reducing game lag.
[0180] Of course, it can be understood that for the convenience of explanation in this example, the difference in the data volume between the provided differential Python string and the new Python string is relatively small. However, in actual applications, the data volume of the new Python string of the actual game metadata is usually quite large. Therefore, compared with the new Python string, the data volume of the differential Python string is much smaller, and thus the effect of reducing the blocking time and lag will be more obvious. In actual applications, the greater the difference in the data volume between the differential Python string and the new Python string, the more obvious the effect of reducing the blocking time and lag. Even in an ideal situation, users may hardly notice the lag of the game.
[0181] Referring to Figure 12 , the main game thread can perform differential merging of the differential Python object in memory and the old Python object to achieve data integration in the format of Python objects, thereby obtaining the new Python object of the game metadata.
[0182] Referring to Figure 13 , at this time, in the main game thread, there are the new and old Python strings and the new and old Python objects of the game metadata. The main game thread can delete the old Python string and the old Python object, and only retain the new Python string and the new Python object. Thus, the hot update of the game metadata is completed, and during this hot update process, the blocking time of the game is relatively small and the game lag is relatively small.
[0183] Corresponding to the data hot update method provided in the embodiment of the present application, the embodiment of the present application also provides a data hot update device. The device is applied to a terminal, and a main thread of a client is running in the terminal. The main thread stores target data in a first serialization format and a first structured format of a first interpreted language respectively, and the target data in the first structured format is parsed from the target data in the first serialization format. As Figure 14 shown, the device 400 includes:
[0184] A first control module 401, configured to control the main thread, in response to a hot update instruction for the target data, load the updated target data with the first serialization format from the server corresponding to the client, and provide the target data with the first serialization format and the updated target data to an auxiliary thread created by the main thread;
[0185] The second control module 402 is configured to control the auxiliary thread to extract the target raw data and the updated target raw data that do not have the first serialization format from the target data and the updated target data with the first serialization format respectively, perform a difference comparison on the updated target raw data and the target raw data through a preset programming language different from the first interpreted language to obtain difference data, and provide the difference data to the main thread;
[0186] The third control module 403 is configured to control the main thread to perform data integration on the difference data and the target data with the first structured format to obtain the updated target data with the first structured format, and delete the target data with the first serialization format and the target data with the first structured format.
[0187] Corresponding to the data hot update method provided by the embodiment of the present application, the embodiment of the present application further provides an electronic device for data hot update. As Figure 15 shown, the electronic device includes: a processor 501; and a memory 502 for storing a program of the data hot update method. After the device is powered on and runs the program of the data hot update method through the processor, the following steps are executed:
[0188] The main thread, in response to a hot update instruction for target data, loads the updated target data with the first serialization format from the server corresponding to the client, and provides the target data with the first serialization format and the updated target data to the auxiliary thread created by the main thread;
[0189] The auxiliary thread extracts the target raw data and the updated target raw data that do not have the first serialization format from the target data and the updated target data with the first serialization format respectively, performs a difference comparison on the updated target raw data and the target raw data through a preset programming language different from the first interpreted language to obtain difference data, and provides the difference data to the main thread;
[0190] The main thread performs data integration on the difference data and the target data with the first structured format to obtain the updated target data with the first structured format, and deletes the target data with the first serialization format and the target data with the first structured format.
[0191] Corresponding to the data hot update method provided by the embodiment of the present application, the embodiment of the present application provides a computer-readable storage medium storing a program of the data hot update method. When the program is run by a processor, the following steps are executed:
[0192] The main thread, in response to a hot update instruction for target data, loads the updated target data with a first serialization format from the server corresponding to the client, and provides the target data with the first serialization format and the updated target data to an auxiliary thread created by the main thread;
[0193] The auxiliary thread extracts the target raw data and the updated target raw data that do not have the first serialization format from the target data with the first serialization format and the updated target data respectively, performs a difference comparison on the updated target raw data and the target raw data through a preset programming language different from the first interpreted language to obtain difference data, and provides the difference data to the main thread;
[0194] The main thread integrates the data according to the difference data and the target data with the first structured format to obtain the updated target data with the first structured format, and deletes the target data with the first serialization format and the target data with the first structured format.
[0195] It should be noted that for the detailed description of the device, electronic device and computer-readable storage medium provided in the embodiments of the present application, reference can be made to the relevant description of the method in the embodiments of the present application, which will not be elaborated here.
[0196] Although the present application is disclosed above with preferred embodiments, it is not intended to limit the present application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be defined by the scope of the claims of the present application.
[0197] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0198] The memory may include non-permanent memory in the computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of, for example, read-only memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
[0199] 1. A computer-readable medium includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), random access memory (RAM) of other properties, read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage media, or any other non-transitory media that can be used to store information accessible by a computing device. As defined herein, a computer-readable medium does not include transitory media such as modulated data signals and carrier waves.
[0200] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0201] Although the present application is disclosed above in preferred embodiments, it is not intended to limit the present application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application should be determined by the scope defined by the claims of the present application.
Claims
1. A data hot update method, characterized in that, applied to a terminal, in which a main thread of a client is running, and the main thread stores target data in a first serialization format and a first structured format of a first interpreted language respectively, and the target data in the first structured format is parsed from the target data in the first serialization format, and the method includes: The main thread, in response to a hot update instruction for the target data, loads the updated target data with the first serialization format from the server corresponding to the client, and provides the target data with the first serialization format and the updated target data to an auxiliary thread created by the main thread; The auxiliary thread respectively extracts target raw data and updated target raw data without the first serialization format from the target data with the first serialization format and the updated target data, performs a difference comparison on the updated target raw data and the target raw data through a preset programming language different from the first interpreted language to obtain difference data, and provides the difference data to the main thread; The main thread performs data integration on the difference data and the target data with the first structured format to obtain updated target data with the first structured format, and deletes the target data with the first serialization format and the target data with the first structured format.
2. The method according to claim 1, characterized in that, The performing a difference comparison on the updated target raw data and the target raw data through a preset programming language different from the first interpreted language to obtain difference data, and providing the difference data to the main thread includes: The auxiliary thread processes the updated target raw data into updated target data with a second structured format of the preset programming language, and processes the target raw data into target data with the second structured format; The auxiliary thread performs a difference comparison on the updated target data with the second structured format and the target data through the preset programming language to obtain difference data with the second structured format; The auxiliary thread processes the difference data with the second structured format into difference data with a data format of the first interpreted language, and provides the difference data with the data format of the first interpreted language to the main thread.
3. The method according to claim 2, characterized in that, The auxiliary thread processes the difference data with the second structured format into difference data with a data format of the first interpreted language, and provides the difference data with the data format of the first interpreted language to the main thread, including: The auxiliary thread converts the difference data with the second structured format into difference data with the first serialization format; The auxiliary thread parses the difference data with the first serialization format into difference data with the first structured format, and provides the difference data with the first structured format to the main thread; Correspondingly, the data integration of the differential data and the target data with the first structured format to obtain the updated target data with the first structured format includes: The main thread integrates the differential data with the first structured format and the target data with the first structured format to obtain the updated target data with the first structured format.
4. The method according to claim 2, wherein, The auxiliary thread processes the differential data with the second structured format into differential data with the data format of the first interpreted language, and provides the differential data with the data format of the first interpreted language to the main thread, including: The auxiliary thread converts the differential data with the second structured format into differential data with the first serialization format, and provides the differential data with the first serialization format to the main thread; Correspondingly, the data integration of the differential data and the target data with the first structured format to obtain the updated target data with the first structured format includes: The main thread parses the differential data with the first serialization format into differential data with the first structured format; The main thread integrates the differential data with the first structured format and the target data with the first structured format to obtain the updated target data with the first structured format.
5. The method according to claim 1, wherein, The providing the target data and the updated target data with the first serialization format to the auxiliary thread created by the main thread includes: The main thread provides the target data and the updated target data with the first serialization format to the auxiliary thread created by the main thread while holding the global interpreter lock; Correspondingly, after the providing the target data and the updated target data with the first serialization format to the auxiliary thread created by the main thread, it further includes: The main thread releases the global interpreter lock.
6. The method according to claim 1, wherein, Before respectively extracting the target raw data and the updated target raw data that do not have the first serialization format from the target data and the updated target data with the first serialization format, it further includes: The auxiliary thread obtains the target data and the updated target data with the first serialization format provided by the main thread while obtaining the global interpreter lock; The auxiliary thread releases the global interpreter lock.
7. The method according to claim 2, wherein, The auxiliary thread processes the differential data with the second structured format into differential data with the data format of the first interpreted language, and provides the differential data with the data format of the first interpreted language to the main thread, including: When the auxiliary thread obtains the global interpreter lock, it processes the differential data with the second structured format into differential data with the data format of the first interpreted language, and provides the differential data with the data format of the first interpreted language to the main thread; Correspondingly, after the auxiliary thread processes the differential data with the second structured format into differential data with the data format of the first interpreted language and provides the differential data with the data format of the first interpreted language to the main thread, it further includes: The auxiliary thread releases the global interpreter lock.
8. The method according to claim 1, wherein, Before integrating the differential data and the target data with the first structured format to obtain the updated target data with the first structured format, it further includes: When obtaining the global interpreter lock, the main thread obtains the differential data provided by the auxiliary thread.
9. The method according to claim 6, wherein, Providing the target data with the first serialized format and the updated target data to the auxiliary thread created by the main thread includes: The main thread passes the first reference of the target data with the first serialized format and the second reference of the updated target data with the first serialized format to the auxiliary thread created by the main thread; Correspondingly, when the auxiliary thread obtains the global interpreter lock, obtaining the target data with the first serialized format and the updated target data provided by the main thread includes: When obtaining the global interpreter lock, the auxiliary thread reads the target data with the first serialized format from the memory space indicated by the first reference, and reads the updated target data with the first serialized format from the memory space indicated by the second reference.
10. The method according to claim 8, wherein, Providing the differential data to the main thread includes: The auxiliary thread passes the third reference of the differential data to the main thread; Correspondingly, when the main thread obtains the global interpreter lock, obtaining the differential data provided by the auxiliary thread includes: When obtaining the global interpreter lock, the main thread reads the differential data from the memory space indicated by the third reference.
11. The method according to claim 1, wherein, The preset programming language includes at least one of a compiled language and a second interpreted language different from the first interpreted language.
12. A data hot update device, wherein, Applied to a terminal, in which a main thread of a client is running, the main thread stores target data in the first serialized format and the first structured format of the first interpreted language respectively, and the target data in the first structured format is parsed from the target data in the first serialized format. The device includes: The first control module is used to control the main thread. In response to a hot update instruction for the target data, it loads the updated target data with the first serialization format from the server corresponding to the client, and provides the target data and the updated target data with the first serialization format to the auxiliary thread created by the main thread; The second control module is used to control the auxiliary thread. It respectively extracts the target raw data and the updated target raw data that do not have the first serialization format from the target data and the updated target data with the first serialization format. According to the updated target raw data and the target raw data, it performs a difference comparison through a preset programming language different from the first interpreted language to obtain difference data, and provides the difference data to the main thread; The third control module is used to control the main thread. It performs data integration on the basis of the difference data and the target data with the first structured format to obtain the updated target data with the first structured format, and deletes the target data with the first serialization format and the target data with the first structured format.
13. An electronic device, characterized in that, it includes: a processor; and a memory for storing a program. After the electronic device is powered on and runs the program through the processor, it executes the method according to any one of claims 1-11.
14. A computer-readable storage medium, characterized in that, it stores a program which is run by a processor to execute the method according to any one of claims 1-11.
Citation Information
Patent Citations
Data transmission method and device, first terminal and storage medium
CN110225048A
Multi-thread calling method and device, computer system and storage medium
CN111324465A