A data processing method and device, electronic equipment and storage medium
By configuring the circuit breaker binary and detecting its duration during the execution of the application's function binary on the main thread, the problem of the main thread freezing was solved, improving user experience and retention rate, and reducing losses for vendors.
Patent Information
- Application Number
- CN202210334307.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-03-31
AI Technical Summary
The main thread may freeze during application execution, causing the terminal operating system to stop running, affecting user experience and reducing user retention, resulting in losses for application vendors.
Configure a circuit breaker binary file during the execution of the application's function binary file in the main thread. Detect the duration of continuous execution and skip the current function if it exceeds a first preset duration, then execute the subsequent function to avoid the main thread being interrupted by the terminal operating system.
It improves the execution efficiency of the main thread, avoids interruptions to the terminal operating system, enhances the user experience, increases user retention, and reduces losses for application vendors.
Smart Images

Figure CN114816471B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular, to a data processing method and device, electronic equipment and storage medium. BACKGROUND
[0002] With the rapid development of technology, application programs are gradually indispensable in people's life and work. The stability of application programs has a very important influence on user experience, user growth and user retention.
[0003] Among them, in the case that the user needs to use the application program on the terminal, the user inputs the start operation of starting the application program in the terminal, and then the operating system of the terminal allocates the main thread for the application program. The main thread can run the application program, so that the user can use the application program. SUMMARY
[0004] The present application shows a data processing method, device, electronic equipment and storage medium.
[0005] In a first aspect, the present application shows a data processing method applied to a terminal, wherein an executable file of an application program is running on the terminal, and the operating system of the terminal allocates a main thread for the executable file. The method comprises:
[0006] In the process of executing the binary file of one of the plurality of functions related to the business function in the executable file by the main thread, if the execution reaches the fuse binary file configured in the binary file of the one function in advance, the duration of the execution of the process of executing the binary file of the one function by the main thread is detected.
[0007] If the duration of the execution is greater than or equal to a first preset duration, the binary file of the one function is skipped, and the binary file of the function after the one function in the execution order among the plurality of functions related to the business function is executed.
[0008] Among them, the first preset duration is less than the second preset duration, wherein if the duration of the execution of the one function in the executable file by the main thread is greater than or equal to the second preset duration, the main thread is interrupted by the operating system of the terminal.
[0009] In an optional implementation, the binary file of the function includes a plurality of sub-binary files, and at least two sub-binary files among the plurality of sub-binary files are respectively configured with the fuse binary file.
[0010] In an optional implementation, the method further comprises:
[0011] Determine whether the server corresponding to the application has a configuration file for updating the executable file of the application, wherein the configuration file includes at least the circuit breaker binary file and the function name of the function of the application that needs to be circuit breakered;
[0012] If the configuration file exists on the server, obtain the configuration file from the server;
[0013] Configure the circuit breaker binary file in the binary file of the function corresponding to the function name in the executable file of the application according to the configuration file.
[0014] In an optional implementation, the method further includes:
[0015] Upon receiving a startup operation that launches the executable file of the application in the terminal, the following steps are performed: determining whether the server corresponding to the application has a configuration file for updating the executable file of the application; if the configuration file exists in the server, obtaining the configuration file from the server; and configuring the circuit breaker binary file in the binary file of the function corresponding to the function name in the executable file of the application according to the configuration file.
[0016] Launch the executable file of the application that has been configured with the circuit breaker binary.
[0017] In one optional implementation, the executable file of the application installed on the terminal includes the executable file of the current version of the application;
[0018] The method further includes:
[0019] Determine whether the server corresponding to the application has the executable file of the new version of the application; the binary file of the function that needs to be circuit-broken in the executable file of the new version of the application has been configured with the circuit-broken binary file;
[0020] If the server has an executable file of a new version of the application, obtain the executable file of the new version of the application from the server;
[0021] Replace the current version of the executable file of the application with the new version of the executable file.
[0022] In an optional implementation, the method further includes:
[0023] Upon receiving a launch operation that launches the current version of the executable file of the application in the terminal, the following steps are performed: determining whether the server corresponding to the application has a new version of the executable file of the application; if the server has a new version of the executable file of the application, obtaining the new version of the executable file of the application from the server; and replacing the current version of the executable file of the application with the new version of the executable file of the application.
[0024] Launch the new version of the executable file for the application.
[0025] In one alternative implementation, the executable file of the new version of the application is obtained by compiling the source code of the new version of the application, and the source code of the functions that need to be circuit-broken in the source code of the new version of the application contains the circuit-broken code corresponding to the circuit-broken binary file.
[0026] In one optional implementation, the functions that need to be circuit-broken include functions whose names are in a pre-set set of preset functions. The function names in the preset set include the names of at least one function in the source code of the new version of the application. The circuit-broken code in the source code of the function that needs to be circuit-broken is automatically configured in the source code of the function that needs to be circuit-broken by a preset plugin in the development environment where the source code of the current version of the application is located, based on the function names in the preset set.
[0027] In one optional implementation, the functions that need to be circuit-broken include at least: functions added by the new version of the application's executable file relative to the current version of the application's executable file; functions added by the current version of the application's executable file relative to the previous version of the application's executable file; functions in the application's executable file that the main thread needs to execute during the application's startup process; designated functions in the application; and / or functions involved in designated business functions in the application's executable file.
[0028] In an optional implementation, the continuous execution duration of detecting the process of the main thread executing the binary file of the function includes:
[0029] Create a child thread;
[0030] The child thread obtains the message loop state data of the main thread recorded in the message loop function of the main thread;
[0031] The execution duration of the binary file of the function executed by the main thread is obtained based on the message loop state data.
[0032] Secondly, this application discloses a data processing method applied to a terminal, the terminal running a development environment containing the source code of the application, the method comprising:
[0033] Obtain the circuit breaker code, and obtain the function name of the function that needs to be circuit breaker in the source code of the application;
[0034] Configure the circuit breaker code in the source code of the function that needs to be circuit-broken according to the function name;
[0035] The source code of the application configured with the circuit breaker code is compiled to obtain the executable file of the application. The binary file of the function that needs to be circuit-broken in the executable file of the application contains the circuit breaker binary file corresponding to the circuit breaker code.
[0036] To ensure that during the execution of the binary file of the function requiring circuit breaking among multiple functions involved in the business function of the executable file in the main thread, when the execution reaches the circuit breaking binary file configured in advance in the binary file of the function requiring circuit breaking, the duration of the continuous execution of the binary file of the function requiring circuit breaking in the main thread is detected; if the duration of continuous execution is greater than or equal to a first preset duration, the binary file of the function requiring circuit breaking is skipped, and the binary file of the function that is executed after the function requiring circuit breaking among the multiple functions involved in the business function is executed. The main thread is allocated to the executable file by the operating system of the terminal running the executable file.
[0037] In an optional implementation, obtaining the function name of the function requiring circuit breaking in the application's source code includes:
[0038] Obtain the function names from a pre-set set of preset functions; the function names in the preset set include the function names of at least one function in the source code of the new version of the application;
[0039] The function name that needs to be circuit-broken is obtained from the function name in the preset function set.
[0040] In one optional implementation, the development environment has pre-defined plugins;
[0041] The step of configuring the circuit-breaking code in the source code of the function that needs to be circuit-broken according to the function name includes:
[0042] Based on the preset plugin in the development environment, the circuit breaker code is automatically configured in the source code of the function that needs to be circuit-broken according to the function name in the preset function set.
[0043] In an optional implementation, configuring the circuit-breaking code in the source code of the function requiring circuit breaking according to the function name includes:
[0044] The source code of the function corresponding to the function name is determined in the source code of the application.
[0045] In the source code of the function corresponding to the function name, the circuit breaker code is inserted at least once every other line of code.
[0046] In one optional implementation, the functions that need to be circuit-broken include at least: functions added by the new version of the application's executable file relative to the current version of the application's executable file; functions added by the current version of the application's executable file relative to the previous version of the application's executable file; functions in the application's executable file that the main thread needs to execute during the application's startup process; designated functions in the application; and / or functions involved in designated business functions in the application's executable file.
[0047] Thirdly, this application discloses a data processing apparatus applied to a terminal, wherein an executable file of an application program runs on the terminal, and the operating system of the terminal allocates a main thread to the executable file; the apparatus includes:
[0048] The detection module is used to detect the duration of execution of the binary file of the main thread executing the binary file of the function that is one of the multiple functions involved in the business function of the executable file when the main thread executes the binary file of the function that is configured to trigger the circuit breaker in advance in the binary file of the function.
[0049] The execution module is configured to, when the continuous execution duration is greater than or equal to a first preset duration, skip the binary file of the first function and execute the binary file of the function that is among the multiple functions involved in the business function and whose execution order is after the first function.
[0050] Wherein, the first preset duration is less than the second preset duration, and if the continuous execution duration of the main thread executing the binary file of the function in the executable file is greater than or equal to the second preset duration, then the main thread is interrupted by the operating system of the terminal.
[0051] In one optional implementation, the binary file of the function includes multiple sub-binary files, and at least two of the sub-binary files respectively configure the circuit breaker binary file.
[0052] In an alternative implementation, the apparatus further includes:
[0053] The first determining module is used to determine whether the server corresponding to the application has a configuration file for updating the executable file of the application, wherein the configuration file includes at least the circuit breaker binary file and the function name of the function of the application that needs to be circuit breakered;
[0054] The first acquisition module is used to acquire the configuration file from the server if the configuration file is present in the server.
[0055] The first configuration module is used to configure the circuit breaker binary file in the binary file of the function corresponding to the function name in the executable file of the application, according to the configuration file.
[0056] In an alternative implementation, the apparatus further includes:
[0057] The first determining module is further configured to: upon receiving a launch operation of the executable file of the application launched in the terminal, determine whether the server corresponding to the application has a configuration file for updating the executable file of the application.
[0058] The first startup module is used to start the executable file of the application with the configured circuit breaker binary file when the configuration file is obtained from the server and the circuit breaker binary file is configured in the binary file of the function corresponding to the function name in the executable file of the application according to the configuration file.
[0059] In one optional implementation, the executable file of the application installed on the terminal includes the executable file of the current version of the application;
[0060] The device further includes:
[0061] The second determining module is used to determine whether the server corresponding to the application has an executable file of a new version of the application; the binary file of the function that needs to be circuit-broken in the executable file of the new version of the application has been configured with the circuit-broken binary file;
[0062] The second acquisition module is used to acquire the executable file of the new version of the application from the server if the server has the executable file of the new version of the application.
[0063] The replacement unit is used to replace the current version of the executable file of the application with a new version of the executable file of the application.
[0064] In an alternative implementation, the apparatus further includes:
[0065] The second determining module is further configured to: upon receiving a launch operation that launches the current version of the executable file of the application in the terminal, determine whether the server corresponding to the application has a new version of the executable file of the application;
[0066] The second startup module is used to launch the new version of the application's executable file when the new version of the application's executable file is obtained from the server and the current version of the application's executable file is replaced with the new version of the application's executable file.
[0067] In one alternative implementation, the executable file of the new version of the application is obtained by compiling the source code of the new version of the application, and the source code of the functions that need to be circuit-broken in the source code of the new version of the application contains the circuit-broken code corresponding to the circuit-broken binary file.
[0068] In one optional implementation, the functions that need to be circuit-broken include functions whose names are in a pre-set set of preset functions. The function names in the preset set include the names of at least one function in the source code of the new version of the application. The circuit-broken code in the source code of the function that needs to be circuit-broken is automatically configured in the source code of the function that needs to be circuit-broken by a preset plugin in the development environment where the source code of the current version of the application is located, based on the function names in the preset set.
[0069] In one optional implementation, the functions that need to be circuit-broken include at least: functions added by the new version of the application's executable file relative to the current version of the application's executable file; functions added by the current version of the application's executable file relative to the previous version of the application's executable file; functions in the application's executable file that the main thread needs to execute during the application's startup process; designated functions in the application; and / or functions involved in designated business functions in the application's executable file.
[0070] In one optional implementation, the detection module includes:
[0071] Create a unit for creating child threads;
[0072] The first acquisition unit is used to acquire the message loop state data of the main thread recorded in the message loop function of the main thread based on the child thread;
[0073] The second acquisition unit is used to acquire the continuous execution duration of the binary file of the main thread executing the function based on the message loop state data.
[0074] Fourthly, this application discloses a data processing apparatus applied to a terminal, the terminal running a development environment containing the source code of the application, the apparatus comprising:
[0075] The third acquisition module is used to acquire the circuit breaker code and the function name of the function that needs to be circuit breaker in the source code of the application.
[0076] The second configuration module is used to configure the circuit-breaking code in the source code of the function that needs to be circuit-broken according to the function name;
[0077] The compilation module is used to compile the source code of the application configured with the circuit breaker code to obtain the executable file of the application. The binary file of the function that needs to be circuit-broken in the executable file of the application contains the circuit breaker binary file corresponding to the circuit breaker code.
[0078] To ensure that during the execution of the binary file of the function requiring circuit breaking among multiple functions involved in the business function of the executable file in the main thread, when the execution reaches the circuit breaking binary file configured in advance in the binary file of the function requiring circuit breaking, the duration of the continuous execution of the binary file of the function requiring circuit breaking in the main thread is detected; if the duration of continuous execution is greater than or equal to a first preset duration, the binary file of the function requiring circuit breaking is skipped, and the binary file of the function that is executed after the function requiring circuit breaking among the multiple functions involved in the business function is executed. The main thread is allocated to the executable file by the operating system of the terminal running the executable file.
[0079] In one optional implementation, the third acquisition module includes:
[0080] The third acquisition unit is used to acquire function names from a pre-set set of preset functions; the function names in the preset set of preset functions include the function names of at least one function in the source code of the new version of the application.
[0081] The fourth acquisition unit is used to obtain the function name of the function that needs to be circuit-broken based on the function name in the preset function set.
[0082] In one optional implementation, the development environment has pre-defined plugins;
[0083] The configuration module includes:
[0084] The first configuration unit is used to automatically configure the circuit breaking code in the source code of the function that needs to be circuit broken based on the function name in the preset function set according to the preset plugin in the development environment.
[0085] In an optional implementation, configuring the circuit-breaking code in the source code of the function requiring circuit breaking according to the function name includes:
[0086] A determining unit is used to determine the source code of the function corresponding to the function name in the source code of the application.
[0087] The second configuration unit is used to insert the circuit breaker code into the source code of the function corresponding to the function name at least one line interval.
[0088] In one optional implementation, the functions that need to be circuit-broken include at least: functions added by the new version of the application's executable file relative to the current version of the application's executable file; functions added by the current version of the application's executable file relative to the previous version of the application's executable file; functions in the application's executable file that the main thread needs to execute during the application's startup process; designated functions in the application; and / or functions involved in designated business functions in the application's executable file.
[0089] Fifthly, this application discloses an electronic device comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to perform the data processing method described in any of the preceding aspects.
[0090] Sixthly, this application discloses a non-transitory computer-readable storage medium, wherein when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the data processing method as described in any of the preceding aspects.
[0091] In a seventh aspect, this application discloses a computer program product in which, when the instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to perform the data processing method described in any of the preceding aspects.
[0092] The technical solution provided in this application may include the following beneficial effects:
[0093] In this application, during the execution of the binary file of one of multiple functions involved in the business function of the application's executable file by the main thread, if the execution reaches a circuit breaker binary file pre-configured in that function's binary file, the duration of the main thread's execution of that function's binary file is detected. If the duration is greater than or equal to a first preset duration, the binary file of that function is skipped, and the binary file of the function involved in the business function that follows that function in the execution order is executed. The first preset duration is less than a second preset duration. If the duration of the main thread's execution of the binary file of a function in the executable file is greater than or equal to the second preset duration, the main thread is interrupted by the terminal's operating system.
[0094] This application ensures that the continuous execution time of the main thread executing the binary file of a function does not exceed a first preset duration. Since the first preset duration is less than the second preset duration, the terminal's operating system needs to interrupt the main thread's execution. This prevents the main thread from being interrupted by the terminal's operating system, thus improving the user experience, increasing user retention, and minimizing losses for the application vendor. Attached Figure Description
[0095] Figure 1 This is a flowchart of the steps of a data processing method according to this application.
[0096] Figure 2 This is a flowchart of the steps of a data processing method according to this application.
[0097] Figure 3 This is a structural block diagram of a data processing device according to this application.
[0098] Figure 4 This is a structural block diagram of a data processing device according to this application.
[0099] Figure 5 This is a block diagram of an electronic device according to this application.
[0100] Figure 6 This is a block diagram of an electronic device according to this application. Detailed Implementation
[0101] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0102] After conducting statistical analysis of the current situation, the inventors discovered that during the main thread's operation of the application, the main thread sometimes freezes and is interrupted by the terminal's operating system, causing the application to exit. This results in users being unable to use the application, leading to a very poor user experience, reducing user retention, and causing losses for the application's vendors.
[0103] Therefore, the need to improve user experience, user retention rates, and avoid losses for application vendors was proposed.
[0104] To improve user experience, increase application retention, and minimize losses for application vendors, the inventors conducted statistical analysis on the aforementioned situations and discovered that main thread freezing occurs when the main thread executes a task (such as complex calculations or file read / write operations) for an excessively long time (exceeding the operating system's tolerance limit) without completing it, preventing other operations within the application from being performed. For example, this renders the application unusable for the user. Therefore, the operating system considers the main thread to be in an abnormal state and invalid, and to conserve system resources, it directly interrupts the main thread's execution.
[0105] Based on this idea, the inventors realized that if the continuous execution time of the main thread's task does not exceed the tolerance time specified by the terminal's operating system, the terminal's operating system can be prevented from directly interrupting the main thread.
[0106] To ensure that the duration of the main thread's task execution does not exceed the tolerance time specified by the terminal's operating system, see [reference needed]. Figure 1 This diagram illustrates a flowchart of a data processing method according to this application, applied to a terminal, including terminals widely used by users. The terminal runs an executable file of an application, and the terminal's operating system allocates a main thread to the executable file. Specifically, the method may include the following steps:
[0107] In step S101, during the execution of the binary file of one of the multiple functions involved in the business function of the executable file of the application by the main thread, if the execution reaches the circuit breaker binary file configured in advance in the binary file of that function, the continuous execution time of the main thread executing the binary file of that function is detected.
[0108] This application includes many business functions, such as live streaming, peer-to-peer video chat, shopping, and photo taking. Users can utilize these business functions while using the application.
[0109] When a user uses a business function of an application, the main thread will execute multiple functions involved in that business function. These functions have a specific execution order, and the main thread will execute these functions sequentially according to their order of execution.
[0110] The terminal runs the application's executable file, which is obtained by compiling the application's source code.
[0111] The multiple functions involved in this business function exist as binary files in the application's executable file.
[0112] In addition, at least one of the functions involved in this business function has at least one circuit breaker binary file configured in its binary file.
[0113] For example, for any one of the functions, at least one circuit breaker binary file is configured in the middle position of the binary file of the function. For example, a circuit breaker binary file is configured in the middle position of the binary file of the function, or circuit breaker binary files are configured at two or more intervals in the middle position region of the binary file of the function.
[0114] Thus, for any one of the functions in at least one of the at least one circuit breaker binary files configured, during the execution of that function's binary file by the main thread, at least one circuit breaker binary file will often be executed.
[0115] The purpose of the circuit breaker binary file is to detect the duration of the main thread's execution of the binary file of a function. If the duration is greater than or equal to a first preset duration, the binary file of that function is skipped and the binary file of the function that follows the first function in the execution order is executed. Alternatively, if the duration is less than the first preset duration, the content of the binary file of that function that follows the circuit breaker binary file is executed.
[0116] Thus, if the main thread executes a circuit breaker binary file of the function's binary file, the duration of the main thread's execution of that function's binary file can be detected.
[0117] In this step, a child thread can be created, and then the message loop state data of the main thread recorded in the message loop function of the main thread can be obtained based on the child thread. Then, the execution duration of the binary file of a function executed by the main thread can be obtained based on the message loop state data.
[0118] The terminal's operating system allocates a message loop function for the main thread. The message loop function can include functions such as Runloop or Looper.
[0119] The message loop function is used to handle various events that occur during the execution of the application's executable file (such as touch events, UI refresh events, or timer events).
[0120] The terminal's operating system provides an API (Application Programming Interface) for listening to the message loop function. In this way, the message loop state data of the main thread recorded in the main thread's message loop function can be listened to through the API.
[0121] It can obtain the duration of Timer events, Source events, and wake-up events for a specific function from the message loop state data, and use the longest duration as the continuous execution duration of the main thread executing the binary file of that function.
[0122] In step S102, if the continuous execution duration is greater than or equal to the first preset duration, the binary file of the function is skipped, and the binary file of the function that follows the function in the execution order among the multiple functions involved in the business function is executed.
[0123] Wherein, the first preset duration is less than the second preset duration, and if the continuous execution duration of the binary file of a function in the executable file executed by the main thread is greater than or equal to the second preset duration, the main thread is interrupted by the terminal's operating system.
[0124] The second preset duration is built into the terminal's operating system, such as 8 seconds, 9 seconds, or 10 seconds. This application does not limit this, and the specific duration can be based on the actual duration built into the terminal's operating system.
[0125] The first preset duration can be set in advance by the application developers within the application; for example, it can include 5 seconds, 6 seconds, or 7 seconds. As long as the first preset duration is less than the second preset duration, this application does not impose any specific value on the first preset duration.
[0126] If the continuous execution duration is greater than or equal to the first preset duration, it means that although the continuous execution duration of the main thread executing the binary file of this function has not reached the duration at which the terminal's operating system needs to interrupt the main thread's execution, the continuous execution duration of the main thread executing the binary file of this function is already relatively long. If the execution of the binary file of this function is not interrupted, the continuous execution duration of the main thread executing the binary file of this function will continue to increase. If the increased continuous execution duration is greater than or equal to the second preset duration, the main thread will be interrupted by the terminal's operating system, which will cause the application's executable file to exit (that is, the terminal will interrupt the execution of the application's executable file), which will cause inconvenience to the user and reduce the user experience.
[0127] Therefore, if the execution duration is greater than or equal to the first preset duration, the execution of the binary file of that function can be interrupted in a timely manner. For example, the binary file of that function can be skipped, and the binary file of the function that is executed after that function among the multiple functions involved in the business function can be executed.
[0128] In another embodiment of this application, if the continuous execution time is less than a first preset time, the content in the binary file of the function located after the circuit breaker binary file continues to be executed.
[0129] If the continuous execution duration is less than the first preset duration, it means that the continuous execution duration of the main thread executing the binary file of this function has not reached the duration of "the terminal's operating system needs to interrupt the main thread's operation", and the continuous execution duration of the main thread executing the binary file of this function is not long. Therefore, the content of the binary file of this function located after the circuit breaker binary file can continue to be executed.
[0130] In this application, during the execution of the binary file of one of multiple functions involved in the business function of the application's executable file by the main thread, if the execution reaches a circuit breaker binary file pre-configured in that function's binary file, the duration of the main thread's execution of that function's binary file is detected. If the duration is greater than or equal to a first preset duration, the binary file of that function is skipped, and the binary file of the function involved in the business function that follows that function in the execution order is executed. The first preset duration is less than a second preset duration. If the duration of the main thread's execution of the binary file of a function in the executable file is greater than or equal to the second preset duration, the main thread is interrupted by the terminal's operating system.
[0131] This application ensures that the continuous execution time of the main thread executing the binary file of a function does not exceed a first preset duration. Since the first preset duration is less than the second preset duration (the duration during which the terminal's operating system needs to interrupt the main thread's execution), the continuous execution time of the main thread executing the binary file of a function does not exceed the second preset duration. This avoids the main thread being interrupted by the terminal's operating system, thereby improving the user experience, increasing user retention of the application, and minimizing losses for the application vendor.
[0132] In one embodiment, the function's binary file includes multiple sub-binary files, and at least two of the sub-binary files are configured with a circuit breaker binary file.
[0133] This allows the execution of the binary file of one of the multiple functions involved in the business function of the application's executable file on the main thread to reach the circuit breaker binary file configured in advance for that function at least twice. This enables the system to "detect the duration of the main thread's execution of the binary file of that function at least twice. If the duration is greater than or equal to a first preset duration, the binary file of that function is skipped, and the binary file of the function that follows that function in the execution order of the multiple functions involved in the business function is executed."
[0134] By increasing the number of times the process of "detecting the continuous execution duration of the main thread executing the binary file of a function, and if the continuous execution duration is greater than or equal to the first preset duration, skipping the binary file of that function and executing the binary file of the function that follows the execution order of the function involved in the business function", it is possible to minimize the possibility that the continuous execution duration of the main thread executing the binary file of that function is greater than or equal to the second preset duration.
[0135] In other words, if the execution time of the main thread executing the binary file of a function is greater than or equal to the first preset time, the binary file of that function can be skipped as much as possible and the binary file of the function that is executed after the binary file of the function involved in the business function can be executed.
[0136] Secondly, by determining the location of the circuit breaker binary file within the binary file of the function that triggers the action of "detecting the continuous execution duration of the main thread's execution of the binary file of this function, and if the continuous execution duration is greater than or equal to a first preset duration, skipping the binary file of this function and executing the binary file of the function that follows the execution order of the multiple functions involved in this business function," developers can locate the content within the binary file of this function that causes the continuous execution duration of the main thread's execution of the binary file of this function to be greater than or equal to the first preset duration, so that developers can fix this part.
[0137] In this context, the executable file of an application installed on the terminal can be understood as the executable file of the current version of the application.
[0138] In one embodiment of this application, the current version of the executable file of the application installed on the terminal may not yet have a circuit breaker binary file. The circuit breaker binary file or the circuit breaker code corresponding to the circuit breaker binary file is developed by the application developers after the user has installed the current version of the executable file of the application on the terminal, and the developers have not yet released a new version of the executable file of the application that includes the circuit breaker binary file.
[0139] Until the developers release a new version of the executable file containing the circuit breaker binary, users cannot install the new version of the executable file containing the circuit breaker binary on their terminals. Consequently, the functions in the current version of the executable file of the application installed on the terminal that require circuit breaking will not have the functionality corresponding to the circuit breaker binary.
[0140] In this context, to ensure that the functions requiring circuit breaking in the current version of the executable file of the application installed on the terminal have the functionality corresponding to the circuit breaking binary, after the developer develops the circuit breaking binary and before the developer releases a new version of the executable file containing the circuit breaking binary, in another embodiment of this application, the terminal can determine (e.g., periodically determine) whether the server corresponding to the application has a configuration file for updating the executable file of the application. The circuit breaking binary issued by the developer can be deployed on the server corresponding to the application using a configuration file, which includes at least the circuit breaking binary and the function names of the functions in the application that require circuit breaking.
[0141] Specifically, the terminal can send a query request to the server through an application to inquire whether the server has a configuration file for updating the application's executable file. Upon receiving the query request, if the server has the configuration file for updating the application's executable file, the application can return a first query response to the terminal, indicating that the server has such a configuration file. If the server does not have the configuration file for updating the application's executable file, the application can return a second query response to the terminal, indicating that the server does not have such a configuration file.
[0142] After receiving the first query response, the terminal can learn from the first query response that the server has a configuration file for updating the executable file of the application.
[0143] After receiving the second query response, the terminal can learn from the second query response that the server does not have a configuration file for updating the executable file of the application.
[0144] If the server has a configuration file for updating the application's executable file, the terminal can obtain the configuration file from the server.
[0145] For example, a terminal sends a download request to a server through an application to request the download of a configuration file. After receiving the download request, the server can send the configuration file to the terminal, and the terminal can receive the configuration file sent by the server.
[0146] Then, the terminal can configure the circuit breaker binary file in the binary file of the function corresponding to the function name in the application's executable file according to the configuration file.
[0147] Furthermore, in another embodiment, the configuration file may also include at least one location in the binary file of the function corresponding to the function name for configuring the circuit breaker binary file. If there are two or more locations, the two or more locations are separated in the binary file of the function corresponding to the function name.
[0148] In this way, the terminal can configure the circuit breaker binary file in each location of the binary file corresponding to the function name in the application's executable file according to the configuration file.
[0149] In this way, the circuit breaker binary file is updated in real time to the executable file of the current version of the application installed on the terminal.
[0150] In this way, the function in the executable file of the current version of the application installed on the terminal that needs to be circuit-broken has the corresponding function of the circuit-broken binary file.
[0151] However, the circuit breaker binary has a certain storage space. Therefore, configuring the circuit breaker binary in the binary file of the function corresponding to the function name in the current version of the application's executable file will increase the terminal storage space occupied by the application's executable file.
[0152] The earlier the circuit breaker binary is configured in the binary file of the function corresponding to the function name in the current version of the application's executable file, the longer the circuit breaker binary will exist in the current version of the application's executable file. The longer the duration of "increasing the terminal's storage space occupied by the application's executable file" will be, the lower the utilization rate of the terminal's storage space.
[0153] Thus, in order to improve the utilization of terminal storage space, one approach is to reduce the duration of "increasing the terminal storage space occupied by application executable files".
[0154] To reduce the duration of "increasing the terminal's storage space usage by the application's executable file," one approach is to reduce the duration of the circuit breaker binary's presence in the current version of the application's executable file.
[0155] To reduce the duration of the circuit breaker binary in the current version of the application's executable, one approach is to delay configuring the circuit breaker binary in the binary file corresponding to the function name in the current version of the application's executable.
[0156] For example, upon receiving a launch command to start the current version of the application's executable file in the terminal, it can be determined whether the server corresponding to the application has a configuration file for updating the current version of the executable file. If the configuration file exists on the server, it is retrieved from the server. Based on the configuration file, a circuit breaker binary is configured in the binary file of the function corresponding to the function name in the current version of the application's executable file. Then, the current version of the application's executable file with the configured circuit breaker binary is launched.
[0157] This not only ensures that the functions requiring circuit breaking in the current version of the executable file of the application have the functionality corresponding to the circuit breaking binary after the current version of the executable file of the application is launched, but also reduces the duration of the circuit breaking binary file in the current version of the executable file of the application, thereby improving the utilization of the terminal's storage space.
[0158] The executable files of applications installed on the terminal include: the executable file of the current version of the application, etc.
[0159] In one embodiment of this application, the current version of the executable file of the application installed on the terminal may not yet have a circuit breaker binary file. The circuit breaker binary file or the circuit breaker code corresponding to the circuit breaker binary file is developed by the application developers after the user has installed the current version of the executable file of the application on the terminal, and the developers have released a new version of the executable file of the application that includes the circuit breaker binary file.
[0160] After the developers have released a new version of the executable file for the application that includes the circuit breaker binary, users can install the new version of the executable file for the application on their terminals.
[0161] Thus, in order to ensure that the functions requiring circuit breaking in the executable file of the application installed on the terminal have the corresponding functionality in the circuit breaking binary file, in another embodiment of this application, the terminal can determine whether the server corresponding to the application has a new version of the executable file of the application. The new version of the application's executable file has a circuit breaking binary file configured in the binary file of the function requiring circuit breaking.
[0162] Specifically, the terminal can send a query request to the server through an application to inquire whether the server has a new version of the executable file for the application. After receiving the query request, if the server has the new version of the executable file for the application, it can return a third query response to the terminal through the application, indicating that the new version of the executable file for the application is available on the server. If the server does not have the new version of the executable file for the application, it can return a fourth query response to the terminal through the application, indicating that the new version of the executable file for the application is not available on the server.
[0163] After receiving the third query response, the terminal can learn from the third query response that the server has an executable file containing a new version of the application.
[0164] After receiving the fourth query response, the terminal can learn from the fourth query response that the server does not have the executable file of the new version of the application.
[0165] If the server has a new version of the executable file for the application, the terminal can obtain the new version of the executable file for the application from the server.
[0166] For example, a terminal sends a download request to a server through an application to request the download of a new version of the application's executable file. After receiving the download request, the server can send the new version of the application's executable file to the terminal, and the terminal can receive the new version of the application's executable file sent by the server.
[0167] Then, the terminal can replace the current version of the application's executable file with the new version of the application's executable file.
[0168] However, because the new version of the application's executable file contains a circuit breaker binary, the new version of the application's executable file occupies more storage space than the current version of the application's executable file.
[0169] Therefore, replacing the current version of the application's executable file with a new version of the application's executable file will increase the storage space occupied by the application's executable file on the terminal.
[0170] The sooner the new version of the application's executable file is replaced with the current version, the longer the new version of the application's executable file will exist on the terminal, and the longer the "increased terminal storage space occupied by the application's executable file" will last, thus reducing the utilization rate of the terminal's storage space.
[0171] Thus, in order to improve the utilization of terminal storage space, one approach is to reduce the duration of "increasing the terminal storage space occupied by application executable files".
[0172] To reduce the duration of "increasing the storage space occupied by the application's executable file on the terminal", one approach is to reduce the duration of the existence of a new version of the application's executable file on the terminal.
[0173] To reduce the duration of a new version of the application's executable file on the terminal, one approach is to delay the timing of replacing the current version of the application's executable file with the new version.
[0174] For example, upon receiving a launch command to start the current version of the application's executable file in the terminal, it can be determined whether a new version of the application's executable file exists on the server corresponding to the application. If the new version of the application's executable file exists on the server, it is retrieved from the server. The new version of the application's executable file is then used to replace the current version of the application's executable file. Finally, the new version of the application's executable file is launched.
[0175] This not only ensures that when an executable file for the application needs to be launched, the new version of the executable file is launched (the new version of the executable file contains the function that needs to be circuit-broken, which has the corresponding function of the binary file), but also reduces the duration of the new version of the executable file on the terminal, thereby improving the utilization of the terminal's storage space.
[0176] In one embodiment of this application, the executable file of the new version of the application is obtained by compiling the source code of the new version of the application. The source code of the function that needs to be circuit-broken in the source code of the new version of the application contains the circuit-broken code corresponding to the circuit-broken binary file.
[0177] Functions requiring circuit breaking include those corresponding to function names in a pre-defined set of default functions. These default function sets include the names of at least one function in the source code of the latest version of the application. The circuit breaking code in the source code of the functions requiring circuit breaking is automatically configured in the source code of the functions requiring circuit breaking by a default plugin in the development environment where the current version of the application's source code resides, based on the function names in the default function set. Default plugins can include Clang, etc. Clang is a front-end compiler for Objective-C, an object-oriented programming language based on LLVM (Low Level Virtual Machine), supporting C / C++ and extended C languages.
[0178] The functions that need to be circuit-broken include at least: functions added by the new version of the application's executable file compared to the current version of the application's executable file; functions added by the current version of the application's executable file compared to the previous version of the application's executable file; functions in the application's executable file that the main thread needs to execute during the application's startup process; specified functions in the application; and / or functions involved in specified business functions in the application's executable file.
[0179] In the process of developing an application, it is common to update the application based on one version and then release the executable file of the new version.
[0180] Specifically, suppose the current version of the application is version A. Version A of the application has source code and executable file of version A. Suppose the application developers need to update the application. For example, suppose the application developers need to add a new business function to the application. The new business function involves multiple new functions. In this case, the developers will add the source code of the new business function (which involves the source code of multiple new functions) to the source code of version A of the application, thus obtaining the source code of version B of the application. The developers will then compile the source code of version B of the application to obtain the executable file of version B of the application.
[0181] In one possible scenario, if an application needs to be updated from version A to obtain version B, and some new functions are added to version A to obtain version B, then the functions in version A are usually normal. For example, after the release of version A and before the update to obtain version B, version A has usually undergone at least one round of optimization by the developers. This ensures that the continuous execution time of any function in the executable file of version A of the application by the main thread will not exceed the second preset threshold, and the main thread will not be interrupted by the terminal's operating system because "the continuous execution time of any function in the executable file of version A of the application by the main thread exceeds the second preset threshold".
[0182] Therefore, in the developed version B application, the functions that may cause exceptions are often the functions added to version B application compared to version A application.
[0183] The main thread may execute the "added function" in the executable file of application version B for a duration that exceeds the second preset threshold. If the execution time exceeds the second preset threshold, the main thread may be interrupted by the terminal's operating system.
[0184] Therefore, the functions that need to be circuit-broken can include at least: functions added by the new version of the application's executable file relative to the current version of the application's executable file, or functions added by the current version of the application's executable file relative to the previous version of the application's executable file, etc.
[0185] During the execution of an application's executable file, certain scenarios may occur multiple times, such as launching the application's executable file and searching for information based on user instructions. These scenarios, which occur repeatedly, deserve special attention, as the functions involved may be those that require circuit breaking.
[0186] Therefore, functions that need to be circuit-broken can also include: functions in the application's executable file that the main thread needs to execute during the application's startup process, specified functions in the application, and / or functions involved in specified business functions in the application's executable file, etc.
[0187] Reference Figure 2This document illustrates a flowchart of a data processing method according to this application, applied to a terminal, including terminals used by application developers, etc. The terminal runs a development environment containing the application's source code. The method includes:
[0188] In step S201, the circuit breaker code is obtained, and the function name of the function that needs to be circuit breaker in the application's source code is obtained.
[0189] Circuit breaker code can be entered by developers in the development environment.
[0190] As analyzed above, functions that require circuit breaking can include at least: functions added by the new version of the application's executable file compared to the current version of the application's executable file; functions added by the current version of the application's executable file compared to the previous version of the application's executable file; functions in the application's executable file that the main thread needs to execute during the application's startup process; specified functions in the application; and / or functions involved in specified business functions in the application's executable file, etc.
[0191] In this step, function names from a pre-set set of preset functions can be obtained. The function names in the preset set include the function names of at least one function in the source code of a new version of the application. The function names of the functions that need to be circuit-broken can be obtained based on the function names in the preset set. For example, the function names in the preset set can be used as the function names of the functions that need to be circuit-broken.
[0192] The function names in the preset function set can be composed of the function names that need to be circuit-broken, as mentioned above.
[0193] In step S202, the circuit breaker code is configured in the source code of the function that needs to be circuit-broken according to the function name.
[0194] The development environment includes pre-installed plugins. These plugins may include Clang, etc. Clang is a front-end compiler for Objective-C, an object-oriented programming language based on LLVM, supporting C / C++ and extended C languages.
[0195] Thus, when configuring circuit-breaking code in the source code of the function that needs to be circuit-broken based on the function name, the circuit-breaking code can be automatically configured in the source code of the function that needs to be circuit-broken based on the function name in the preset function set by the preset plugin in the development environment.
[0196] In another embodiment of this application, when configuring circuit breaker code in the source code of the function that needs to be circuit-broken according to the function name, the source code of the function corresponding to the function name can be determined in the source code of the application. In the source code of the function corresponding to the function name, circuit breaker code is inserted at least one line of code at a time.
[0197] In step S203, the source code of the application configured with the circuit breaker code is compiled to obtain the executable file of the application. The binary files of the functions that need to be circuit-broken in the executable file of the application contain the circuit breaker binary files corresponding to the circuit breaker code.
[0198] In this application, the circuit breaker code is obtained, as well as the function name of the function that needs to be circuit-broken in the application's source code. The circuit breaker code is configured in the source code of the function that needs to be circuit-broken based on the function name. The source code of the application with the circuit breaker code configured is compiled to obtain the application's executable file. The binary file of the function that needs to be circuit-broken in the application's executable file contains the circuit breaker binary file corresponding to the circuit breaker code.
[0199] To ensure that during the execution of the binary files of functions that require circuit breaking among the multiple functions involved in the business functionality of the executable file in the main thread, when the execution reaches the circuit breaking binary file configured in advance in the binary file of the function that requires circuit breaking, the duration of the execution of the binary file of the function that requires circuit breaking in the main thread is detected; if the duration of the execution is greater than or equal to a first preset duration, the binary file of the function that requires circuit breaking is skipped, and the binary file of the function that is in the execution order after the function that requires circuit breaking among the multiple functions involved in the business functionality is executed. The main thread is allocated to the executable file by the operating system of the terminal running the executable file.
[0200] This application ensures that the continuous execution time of the binary file containing the function requiring circuit breaking in the main thread does not exceed a first preset duration. Since the first preset duration is less than the duration during which the terminal's operating system needs to interrupt the main thread's execution, the continuous execution time of the binary file containing the function requiring circuit breaking in the main thread does not exceed the second preset duration. This avoids the main thread being interrupted by the terminal's operating system, thereby improving the user experience, increasing user retention of the application, and minimizing losses for the application vendor.
[0201] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by this application.
[0202] Reference Figure 3 This diagram illustrates a structural block diagram of a data processing apparatus according to this application, applied to a terminal, wherein an executable file of an application program runs on the terminal, and the terminal's operating system allocates a main thread to the executable file; the apparatus includes:
[0203] The detection module 11 is used to detect the duration of execution of the binary file of the main thread executing the binary file of the function that is one of the multiple functions involved in the business function of the executable file when the main thread executes the binary file of the function that is configured to be a circuit breaker in advance in the binary file of the function.
[0204] The execution module 12 is configured to, when the continuous execution duration is greater than or equal to a first preset duration, skip the binary file of the one function and execute the binary file of the function that is in the execution order after the one function among the multiple functions involved in the business function.
[0205] Wherein, the first preset duration is less than the second preset duration, and if the continuous execution duration of the main thread executing the binary file of the function in the executable file is greater than or equal to the second preset duration, then the main thread is interrupted by the operating system of the terminal.
[0206] In one optional implementation, the binary file of the function includes multiple sub-binary files, and at least two of the sub-binary files respectively configure the circuit breaker binary file.
[0207] In an alternative implementation, the apparatus further includes:
[0208] The first determining module is used to determine whether the server corresponding to the application has a configuration file for updating the executable file of the application, wherein the configuration file includes at least the circuit breaker binary file and the function name of the function of the application that needs to be circuit breakered;
[0209] The first acquisition module is used to acquire the configuration file from the server if the configuration file is present in the server.
[0210] The first configuration module is used to configure the circuit breaker binary file in the binary file of the function corresponding to the function name in the executable file of the application, according to the configuration file.
[0211] In an alternative implementation, the apparatus further includes:
[0212] The first determining module is further configured to: upon receiving a launch operation of the executable file of the application launched in the terminal, determine whether the server corresponding to the application has a configuration file for updating the executable file of the application.
[0213] The first startup module is used to start the executable file of the application with the configured circuit breaker binary file when the configuration file is obtained from the server and the circuit breaker binary file is configured in the binary file of the function corresponding to the function name in the executable file of the application according to the configuration file.
[0214] In one optional implementation, the executable file of the application installed on the terminal includes the executable file of the current version of the application;
[0215] The device further includes:
[0216] The second determining module is used to determine whether the server corresponding to the application has an executable file of a new version of the application; the binary file of the function that needs to be circuit-broken in the executable file of the new version of the application has been configured with the circuit-broken binary file;
[0217] The second acquisition module is used to acquire the executable file of the new version of the application from the server if the server has the executable file of the new version of the application.
[0218] The replacement unit is used to replace the current version of the executable file of the application with a new version of the executable file of the application.
[0219] In an alternative implementation, the apparatus further includes:
[0220] The second determining module is further configured to: upon receiving a launch operation that launches the current version of the executable file of the application in the terminal, determine whether the server corresponding to the application has a new version of the executable file of the application;
[0221] The second startup module is used to launch the new version of the application's executable file when the new version of the application's executable file is obtained from the server and the current version of the application's executable file is replaced with the new version of the application's executable file.
[0222] In one alternative implementation, the executable file of the new version of the application is obtained by compiling the source code of the new version of the application, and the source code of the functions that need to be circuit-broken in the source code of the new version of the application contains the circuit-broken code corresponding to the circuit-broken binary file.
[0223] In one optional implementation, the functions that need to be circuit-broken include functions whose names are in a pre-set set of preset functions. The function names in the preset set include the names of at least one function in the source code of the new version of the application. The circuit-broken code in the source code of the function that needs to be circuit-broken is automatically configured in the source code of the function that needs to be circuit-broken by a preset plugin in the development environment where the source code of the current version of the application is located, based on the function names in the preset set.
[0224] In one optional implementation, the functions that need to be circuit-broken include at least: functions added by the new version of the application's executable file relative to the current version of the application's executable file; functions added by the current version of the application's executable file relative to the previous version of the application's executable file; functions in the application's executable file that the main thread needs to execute during the application's startup process; designated functions in the application; and / or functions involved in designated business functions in the application's executable file.
[0225] In one optional implementation, the detection module includes:
[0226] Create a unit for creating child threads;
[0227] The first acquisition unit is used to acquire the message loop state data of the main thread recorded in the message loop function of the main thread based on the child thread;
[0228] The second acquisition unit is used to acquire the continuous execution duration of the binary file of the main thread executing the function based on the message loop state data.
[0229] In this application, during the execution of the binary file of one of multiple functions involved in the business function of the application's executable file by the main thread, if the execution reaches a circuit breaker binary file pre-configured in that function's binary file, the duration of the main thread's execution of that function's binary file is detected. If the duration is greater than or equal to a first preset duration, the binary file of that function is skipped, and the binary file of the function involved in the business function that follows that function in the execution order is executed. The first preset duration is less than a second preset duration. If the duration of the main thread's execution of the binary file of a function in the executable file is greater than or equal to the second preset duration, the main thread is interrupted by the terminal's operating system.
[0230] This application ensures that the continuous execution time of the main thread executing the binary file of a function does not exceed a first preset duration. Since the first preset duration is less than the second preset duration, the terminal's operating system needs to interrupt the main thread's execution. This prevents the main thread from being interrupted by the terminal's operating system, thus improving the user experience, increasing user retention, and minimizing losses for the application vendor.
[0231] Reference Figure 4 This diagram illustrates a structural block diagram of a data processing apparatus according to this application, applied to a terminal. The terminal runs a development environment containing the source code of the application. The apparatus includes:
[0232] The third acquisition module 21 is used to acquire the circuit breaker code and the function name of the function that needs to be circuit-broken in the source code of the application.
[0233] The second configuration module 22 is used to configure the circuit breaker code in the source code of the function that needs to be circuit-broken according to the function name;
[0234] The compilation module 23 is used to compile the source code of the application configured with the circuit breaker code to obtain the executable file of the application. The binary file of the function that needs to be circuit-breaker in the executable file of the application contains the circuit breaker binary file corresponding to the circuit breaker code.
[0235] To ensure that during the execution of the binary file of the function requiring circuit breaking among multiple functions involved in the business function of the executable file in the main thread, when the execution reaches the circuit breaking binary file configured in advance in the binary file of the function requiring circuit breaking, the duration of the continuous execution of the binary file of the function requiring circuit breaking in the main thread is detected; if the duration of continuous execution is greater than or equal to a first preset duration, the binary file of the function requiring circuit breaking is skipped, and the binary file of the function that is executed after the function requiring circuit breaking among the multiple functions involved in the business function is executed. The main thread is allocated to the executable file by the operating system of the terminal running the executable file.
[0236] In one optional implementation, the third acquisition module includes:
[0237] The third acquisition unit is used to acquire function names from a pre-set set of preset functions; the function names in the preset set of preset functions include the function names of at least one function in the source code of the new version of the application.
[0238] The fourth acquisition unit is used to obtain the function name of the function that needs to be circuit-broken based on the function name in the preset function set.
[0239] In one optional implementation, the development environment has pre-defined plugins;
[0240] The configuration module includes:
[0241] The first configuration unit is used to automatically configure the circuit breaking code in the source code of the function that needs to be circuit broken based on the function name in the preset function set according to the preset plugin in the development environment.
[0242] In an optional implementation, configuring the circuit-breaking code in the source code of the function requiring circuit breaking according to the function name includes:
[0243] A determining unit is used to determine the source code of the function corresponding to the function name in the source code of the application.
[0244] The second configuration unit is used to insert the circuit breaker code into the source code of the function corresponding to the function name at least one line interval.
[0245] In one optional implementation, the functions that need to be circuit-broken include at least: functions added by the new version of the application's executable file relative to the current version of the application's executable file; functions added by the current version of the application's executable file relative to the previous version of the application's executable file; functions in the application's executable file that the main thread needs to execute during the application's startup process; designated functions in the application; and / or functions involved in designated business functions in the application's executable file.
[0246] In this application, the circuit breaker code is obtained, as well as the function name of the function that needs to be circuit-broken in the application's source code. The circuit breaker code is configured in the source code of the function that needs to be circuit-broken based on the function name. The source code of the application with the circuit breaker code configured is compiled to obtain the application's executable file. The binary file of the function that needs to be circuit-broken in the application's executable file contains the circuit breaker binary file corresponding to the circuit breaker code.
[0247] To ensure that during the execution of the binary files of functions that require circuit breaking among the multiple functions involved in the business functionality of the executable file in the main thread, when the execution reaches the circuit breaking binary file configured in advance in the binary file of the function that requires circuit breaking, the duration of the execution of the binary file of the function that requires circuit breaking in the main thread is detected; if the duration of the execution is greater than or equal to a first preset duration, the binary file of the function that requires circuit breaking is skipped, and the binary file of the function that is in the execution order after the function that requires circuit breaking among the multiple functions involved in the business functionality is executed. The main thread is allocated to the executable file by the operating system of the terminal running the executable file.
[0248] This application ensures that the continuous execution time of the binary file containing the function requiring circuit breaking in the main thread does not exceed a first preset duration. Since the first preset duration is less than the duration during which the terminal's operating system needs to interrupt the main thread's execution, the continuous execution time of the binary file containing the function requiring circuit breaking in the main thread does not exceed the second preset duration. This avoids the main thread being interrupted by the terminal's operating system, thereby improving the user experience, increasing user retention of the application, and minimizing losses for the application vendor.
[0249] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0250] Optionally, embodiments of the present invention also provide an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described data processing method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0251] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described data processing method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0252] Figure 5 This is a block diagram illustrating an electronic device 800. For example, the electronic device 800 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0253] Reference Figure 5 The electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0254] Processing component 802 typically controls the overall operation of electronic device 800, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component 802 may include one or more modules to facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.
[0255] Memory 804 is configured to store various types of data to support the operation of device 800. Examples of this data include instructions for any application or method operating on electronic device 800, contact data, phonebook data, messages, images, videos, etc. Memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0256] Power supply component 806 provides power to various components of electronic device 800. Power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 800.
[0257] Multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 808 includes a front-facing camera and / or a rear-facing camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0258] Audio component 810 is configured to output and / or input audio signals. For example, audio component 810 includes a microphone (MIC) configured to receive external audio signals when electronic device 800 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 804 or transmitted via communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
[0259] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0260] Sensor assembly 814 includes one or more sensors for providing state assessments of various aspects of electronic device 800. For example, sensor assembly 814 may detect the on / off state of device 800, the relative positioning of components such as the display and keypad of electronic device 800, changes in position of electronic device 800 or a component of electronic device 800, the presence or absence of user contact with electronic device 800, orientation or acceleration / deceleration of electronic device 800, and temperature changes of electronic device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 814 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0261] Communication component 816 is configured to facilitate wired or wireless communication between electronic device 800 and other devices. Electronic device 800 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 816 receives broadcast signals or broadcast operation information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 816 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0262] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0263] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by a processor 820 of an electronic device 800 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0264] Figure 6This is a block diagram of an electronic device 1900 shown in this application. For example, the electronic device 1900 can be provided as a server.
[0265] Reference Figure 6 The electronic device 1900 includes a processing component 1922, which further includes one or more processors, and memory resources represented by memory 1932 for storing instructions, such as application programs, that can be executed by the processing component 1922. The application programs stored in memory 1932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 1922 is configured to execute instructions to perform the methods described above.
[0266] Electronic device 1900 may also include a power supply component 1926 configured to perform power management of electronic device 1900, a wired or wireless network interface 1950 configured to connect electronic device 1900 to a network, and an input / output (I / O) interface 1958. Electronic device 1900 can operate on an operating system stored in memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.
[0267] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0268] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0269] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.
[0270] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0271] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0272] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0273] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0274] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0275] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0276] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A data processing method, characterized in that, The method is applied to a terminal, wherein an executable file of an application is running on the terminal, and the terminal's operating system allocates a main thread to the executable file; the method includes: During the execution of the binary file of one of the multiple functions involved in the business function of the executable file by the main thread, if the execution reaches the circuit breaker binary file configured in advance in the binary file of the function, the duration of the execution of the binary file of the function by the main thread is detected. If the continuous execution duration is greater than or equal to a first preset duration, skip the binary file of the one function and execute the binary file of the function that is executed after the one function among the multiple functions involved in the business function; Wherein, the first preset duration is less than the second preset duration, and if the continuous execution duration of the main thread executing the binary file of the function in the executable file is greater than or equal to the second preset duration, then the main thread is interrupted by the operating system of the terminal.
2. The method according to claim 1, characterized in that, The binary file of the function includes multiple sub-binary files, and at least two of the multiple sub-binary files are configured with the circuit breaker binary file.
3. The method according to claim 1, characterized in that, The method further includes: Determine whether the server corresponding to the application has a configuration file for updating the executable file of the application, wherein the configuration file includes at least the circuit breaker binary file and the function name of the function of the application that needs to be circuit breakered; If the configuration file exists on the server, obtain the configuration file from the server; Configure the circuit breaker binary file in the binary file of the function corresponding to the function name in the executable file of the application according to the configuration file.
4. The method according to claim 3, characterized in that, The method further includes: Upon receiving a startup operation that launches the executable file of the application in the terminal, the following steps are performed: determining whether the server corresponding to the application has a configuration file for updating the executable file of the application; if the configuration file exists in the server, obtaining the configuration file from the server; and configuring the circuit breaker binary file in the binary file of the function corresponding to the function name in the executable file of the application according to the configuration file. Launch the executable file of the application that has been configured with the circuit breaker binary.
5. The method according to claim 1, characterized in that, The executable files of the applications installed on the terminal include the executable files of the current version of the applications; The method further includes: Determine whether the server corresponding to the application has the executable file of the new version of the application; the binary file of the function that needs to be circuit-broken in the executable file of the new version of the application has been configured with the circuit-broken binary file; If the server has an executable file of a new version of the application, obtain the executable file of the new version of the application from the server; Replace the current version of the executable file of the application with the new version of the executable file.
6. The method according to claim 5, characterized in that, The method further includes: Upon receiving a launch operation that launches the current version of the executable file of the application in the terminal, the following steps are performed: determining whether the server corresponding to the application has a new version of the executable file of the application; if the server has a new version of the executable file of the application, obtaining the new version of the executable file of the application from the server; and replacing the current version of the executable file of the application with the new version of the executable file of the application. Launch the new version of the executable file for the application.
7. The method according to claim 5, characterized in that, The executable file of the new version of the application is obtained by compiling the source code of the new version of the application. The source code of the functions that need to be circuit-broken in the new version of the application contains the circuit-broken code corresponding to the circuit-broken binary file.
8. The method according to claim 7, characterized in that, The functions that need to be circuit-broken include functions whose names are in a pre-set set of preset functions. The function names in the preset set include the names of at least one function in the source code of the new version of the application. The circuit-broken code in the source code of the function that needs to be circuit-broken is automatically configured in the source code of the function that needs to be circuit-broken by a preset plugin in the development environment where the source code of the current version of the application is located, based on the function names in the preset set.
9. The method according to any one of claims 1-8, characterized in that, The functions that require circuit breaking include at least: functions added by the new version of the executable file of the application relative to the current version of the executable file of the application; functions added by the current version of the executable file of the application relative to the previous version of the executable file of the application; functions in the executable file of the application that the main thread needs to execute during the startup process; designated functions in the application; and / or functions involved in designated business functions in the executable file of the application.
10. The method according to claim 1, characterized in that, The duration of the process of detecting the binary file of the function executed by the main thread includes: Create a child thread; The child thread obtains the message loop state data of the main thread recorded in the message loop function of the main thread; The execution duration of the binary file of the function executed by the main thread is obtained based on the message loop state data.
11. A data processing method, characterized in that, Applied to a terminal, the terminal running a development environment containing the source code of an application, the method includes: Obtain the circuit breaker code, and obtain the function name of the function that needs to be circuit breaker in the source code of the application; Configure the circuit breaker code in the source code of the function that needs to be circuit-broken according to the function name; The source code of the application configured with the circuit breaker code is compiled to obtain the executable file of the application. The binary file of the function that needs to be circuit-broken in the executable file of the application contains the circuit breaker binary file corresponding to the circuit breaker code. To ensure that during the execution of the binary file of the function requiring circuit breaking among multiple functions involved in the business function of the executable file in the main thread, when the execution reaches the circuit breaking binary file configured in advance in the binary file of the function requiring circuit breaking, the duration of the continuous execution of the binary file of the function requiring circuit breaking in the main thread is detected; if the duration of continuous execution is greater than or equal to a first preset duration, the binary file of the function requiring circuit breaking is skipped, and the binary file of the function that is executed after the function requiring circuit breaking among the multiple functions involved in the business function is executed. The main thread is allocated to the executable file by the operating system of the terminal running the executable file.
12. The method according to claim 11, characterized in that, The step of obtaining the function names of the functions requiring circuit breaking in the application's source code includes: Obtain the function names from a pre-set set of preset functions; the function names in the preset set include the function names of at least one function in the source code of the new version of the application; The function name that needs to be circuit-broken is obtained from the function name in the preset function set.
13. The method according to claim 12, characterized in that, The development environment has preset plugins; The step of configuring the circuit-breaking code in the source code of the function that needs to be circuit-broken according to the function name includes: Based on the preset plugin in the development environment, the circuit breaker code is automatically configured in the source code of the function that needs to be circuit-broken according to the function name in the preset function set.
14. The method according to claim 11, characterized in that, The step of configuring the circuit-breaking code in the source code of the function that needs to be circuit-broken according to the function name includes: The source code of the function corresponding to the function name is determined in the source code of the application. In the source code of the function corresponding to the function name, the circuit breaker code is inserted at least once every other line of code.
15. The method according to any one of claims 11-14, characterized in that, The functions that require circuit breaking include at least: functions added by the new version of the executable file of the application relative to the current version of the executable file of the application; functions added by the current version of the executable file of the application relative to the previous version of the executable file of the application; functions in the executable file of the application that the main thread needs to execute during the startup process; designated functions in the application; and / or functions involved in designated business functions in the executable file of the application.
16. A data processing apparatus, characterized in that, An apparatus applied to a terminal, wherein an executable file of an application runs on the terminal, and the terminal's operating system allocates a main thread to the executable file; the apparatus includes: The detection module is used to detect the duration of execution of the binary file of the main thread executing the binary file of the function that is one of the multiple functions involved in the business function of the executable file when the main thread executes the binary file of the function that is configured to trigger the circuit breaker in advance in the binary file of the function. An execution module is configured to, when the continuous execution duration is greater than or equal to a first preset duration, skip the binary file of the first function and execute the binary file of the function that is in the execution order after the first function among the multiple functions involved in the business function; Wherein, the first preset duration is less than the second preset duration, and if the continuous execution duration of the main thread executing the binary file of the function in the executable file is greater than or equal to the second preset duration, then the main thread is interrupted by the operating system of the terminal.
17. The apparatus according to claim 16, characterized in that, The device further includes: The first determining module is used to determine whether the server corresponding to the application has a configuration file for updating the executable file of the application, wherein the configuration file includes at least the circuit breaker binary file and the function name of the function of the application that needs to be circuit breakered; The first acquisition module is used to acquire the configuration file from the server if the configuration file is present in the server. The first configuration module is used to configure the circuit breaker binary file in the binary file of the function corresponding to the function name in the executable file of the application, according to the configuration file.
18. The apparatus according to claim 17, characterized in that, The device further includes: The first determining module is further configured to: upon receiving a launch operation of the executable file of the application launched in the terminal, determine whether the server corresponding to the application has a configuration file for updating the executable file of the application. The first startup module is used to start the executable file of the application with the configured circuit breaker binary file when the configuration file is obtained from the server and the circuit breaker binary file is configured in the binary file of the function corresponding to the function name in the executable file of the application according to the configuration file.
19. The apparatus according to claim 16, characterized in that, The executable files of the applications installed on the terminal include the executable files of the current version of the applications; The device further includes: The second determining module is used to determine whether the server corresponding to the application has an executable file of a new version of the application; the binary file of the function that needs to be circuit-broken in the executable file of the new version of the application has been configured with the circuit-broken binary file; The second acquisition module is used to acquire the executable file of the new version of the application from the server if the server has the executable file of the new version of the application. The replacement unit is used to replace the current version of the executable file of the application with a new version of the executable file of the application.
20. The apparatus according to claim 19, characterized in that, The device further includes: The second determining module is further configured to: upon receiving a launch operation that launches the current version of the executable file of the application in the terminal, determine whether the server corresponding to the application has a new version of the executable file of the application; The second startup module is used to launch the new version of the application's executable file when the new version of the application's executable file is obtained from the server and the current version of the application's executable file is replaced with the new version of the application's executable file.
21. The apparatus according to claim 16, characterized in that, The detection module includes: Create a unit for creating child threads; The first acquisition unit is used to acquire the message loop state data of the main thread recorded in the message loop function of the main thread based on the child thread; The second acquisition unit is used to acquire the continuous execution duration of the binary file of the main thread executing the function based on the message loop state data.
22. A data processing apparatus, characterized in that, Applied to a terminal, the terminal running a development environment containing the source code of an application, the device includes: The third acquisition module is used to acquire the circuit breaker code and the function name of the function that needs to be circuit breaker in the source code of the application. The second configuration module is used to configure the circuit-breaking code in the source code of the function that needs to be circuit-broken according to the function name; The compilation module is used to compile the source code of the application configured with the circuit breaker code to obtain the executable file of the application. The binary file of the function that needs to be circuit-broken in the executable file of the application contains the circuit breaker binary file corresponding to the circuit breaker code. To ensure that during the execution of the binary file of the function requiring circuit breaking among multiple functions involved in the business function of the executable file in the main thread, when the execution reaches the circuit breaking binary file configured in advance in the binary file of the function requiring circuit breaking, the duration of the continuous execution of the binary file of the function requiring circuit breaking in the main thread is detected; if the duration of continuous execution is greater than or equal to a first preset duration, the binary file of the function requiring circuit breaking is skipped, and the binary file of the function that is executed after the function requiring circuit breaking among the multiple functions involved in the business function is executed. The main thread is allocated to the executable file by the operating system of the terminal running the executable file.
23. The apparatus according to claim 22, characterized in that, The third acquisition module includes: The third acquisition unit is used to acquire function names from a pre-set set of preset functions; the function names in the preset set of preset functions include the function names of at least one function in the source code of the new version of the application. The fourth acquisition unit is used to obtain the function name of the function that needs to be circuit-broken based on the function name in the preset function set.
24. The apparatus according to claim 23, characterized in that, The development environment has preset plugins; The configuration module includes: The first configuration unit is used to automatically configure the circuit breaking code in the source code of the function that needs to be circuit broken based on the function name in the preset function set according to the preset plugin in the development environment.
25. The apparatus according to claim 22, characterized in that, The step of configuring the circuit-breaking code in the source code of the function that needs to be circuit-broken according to the function name includes: A determining unit is used to determine the source code of the function corresponding to the function name in the source code of the application. The second configuration unit is used to insert the circuit breaker code into the source code of the function corresponding to the function name at least one line interval.
26. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the data processing method as described in any one of claims 1 to 15.
27. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the data processing method as described in any one of claims 1 to 15.
Citation Information
Patent Citations
Message processing method and device, server and storage medium
CN111555950A
Apparatus and method for thread data processing
US20190205123A1