Code hot reloading method and device, electronic equipment and storage medium

By obtaining module dependency relationship data to generate hot reload instructions and perform incremental patch updates, the problem of insufficient real-time dynamic analysis in hot reload scenarios is solved, and efficient and stable code updates and system recovery is achieved. It is suitable for industries such as finance and medical care that have high stability requirements.

CN120255936APending Publication Date: 2025-07-04PING AN HEALTH INSURANCE CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510331316.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-19
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

The existing technology lacks real-time dynamic analysis and intelligent tuning capabilities in thermal reload scenarios, resulting in the difficulty of solving performance problems during thermal reload in time in industries such as finance and medical care, which affects system stability and efficiency.

Method used

By obtaining the module dependency relationship data of the target project, generating hot reload instructions, using the snapshot mechanism to save application status data, and generating incremental patches through incremental compilation tools for module-level hot reloading, combining automated testing to ensure system stability and accuracy.

Benefits of technology

Module-level incremental update is realized, which reduces system load and update delay, improves the accuracy and efficiency of hot reload, and avoids system failures caused by dependency conflicts. It is suitable for scenarios with high stability requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120255936A_ABST
    Figure CN120255936A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses a code hot reloading method and device, electronic equipment and a storage medium. The method comprises the steps of obtaining dependency relationship data of modules contained in a target project in operation through a preset first analysis tool; when it is monitored that a first code file corresponding to the target project changes, a first hot reloading instruction is generated according to the dependency relationship data and first module information corresponding to the changed first code file; according to the first hot reloading instruction, using a preset snapshot mechanism to store current first application state data of the target project; generating a first incremental patch corresponding to the first code file through a preset incremental compiling tool according to the first hot reloading instruction; and thermally reloading the first module corresponding to the first code file in the target project according to the first incremental patch, and recovering the running state of the target project according to the first application state data. According to the method, project codes are dynamically analyzed in real time, and the intelligent thermal overload capacity of the project is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a code hot reloading method, device, electronic device, and storage medium. Background Art

[0002] In the field of Web application development and operation and maintenance, the hot reloading technology has greatly improved the development and operation and maintenance efficiency by virtue of its characteristic of being able to update code without restarting the application. At the same time, various front-end performance monitoring and optimization tools have emerged in the current stage to monitor the performance of Web applications and analyze potential problems. However, these tools have some problems in the hot reloading scenario. Static analysis is the main method of most existing tools. During the hot reloading process, it is difficult to capture performance problems in real time when facing code updates, complex data interactions, and dynamic user operations. Moreover, the tools lack the ability of automatic and intelligent optimization. Developers can only manually troubleshoot and adjust, which is both time-consuming and laborious. In industries such as finance and healthcare, which have extremely high requirements for system stability, data accuracy, and response speed, the impact of the foregoing problems is more serious. For example, in the financial industry, businesses such as stock trading and fund transfer are time-sensitive. If performance problems during hot reloading cannot be solved in time, it may lead to trading delays and cause huge losses. Another example is that in the medical industry, applications such as remote medical diagnosis and electronic medical record systems have extremely high requirements for stability. Existing tools cannot provide hot reloading optimization solutions for different devices and network environments, which may affect the diagnosis efficiency and accuracy. In addition, the technical data provided by the tools is also difficult for non-professionals to operate. Summary of the Invention

[0003] The main technical problem to be solved by the embodiments of this application is the lack of real-time dynamic analysis and intelligent optimization capabilities in the prior art in the hot reloading scenario.

[0004] To solve the above technical problem, the first technical solution adopted by the embodiments of this application is: to provide a code hot reloading method, including: obtaining dependency relationship data of modules included in a target project in operation through a preset first analysis tool; when it is monitored that a first code file corresponding to the target project changes, generating a first hot reloading instruction according to the dependency relationship data and first module information corresponding to the changed first code file; according to the first hot reloading instruction, using a preset snapshot mechanism to save first application state data of the target project at present; generating a first incremental patch corresponding to the first code file according to the first hot reloading instruction through a preset incremental compilation tool; hot reloading the first module corresponding to the first code file in the target project according to the first incremental patch, and restoring the running state of the target project according to the first application state data.

[0005] Optionally, after the step of hot reloading the first module corresponding to the first code file in the target project according to the first incremental patch, the following steps are included: obtaining a second module associated with the first module in the target project according to the dependency data; after the hot reloading of the first module corresponding to the first incremental patch is completed, performing hot reloading on the second module according to the result of the hot reloading of the first module; updating the dependency data according to the results after the hot reloading of the first module and the second module.

[0006] Optionally, the step of saving the current first application state data of the target project using a preset snapshot mechanism according to the first hot reloading instruction includes: verifying whether the format of the first hot reloading instruction conforms to a preset syntax rule, and if the first hot reloading instruction does not conform, stopping the execution of the first hot reloading instruction; if the first hot reloading instruction conforms, checking whether the target project is running normally and operable, and checking whether the dependency environment of the target project is normal; if the target project is running normally and operable, and the dependency environment of the target project is normal, selecting a matching target snapshot strategy according to the running data and dependency environment of the target project; loading the target snapshot strategy, obtaining the first snapshot data of the target project according to the configuration parameters of the target snapshot strategy, and storing the first snapshot data at a preset storage location.

[0007] Optionally, the step of generating a first hot reloading instruction according to the dependency data and the first module information corresponding to the first code file when it is detected that the first code file corresponding to the target project has changed includes: when it is detected by a pre-deployed file system monitoring program that the first code file has changed, verifying whether the hash value of the first code file is consistent before and after the change; if it is inconsistent before and after the change, obtaining the change association data of the first code file in the target project; obtaining the first module information corresponding to the first code file and the second module information associated with the first module information from the dependency data; performing hot reloading rule matching according to the change association data and the second module information to obtain a hot reloading rule matching result; assembling the first hot reloading instruction using the hot reloading rule matching result, the change association data, the first module information, and the second module information.

[0008] Optionally, the step of generating the first incremental patch corresponding to the first code file by the preset incremental compilation tool according to the first hot reload instruction includes: reading the configuration file of the preset incremental compilation tool, and loading the preset incremental compilation tool according to the configuration file; performing syntax parsing on the received first hot reload instruction to determine whether the first hot reload instruction conforms to the preset syntax rules; if it conforms to the preset syntax rules, extracting the corresponding patch association data from the syntax parsing result of the first hot reload instruction, and generating the first incremental patch by the incremental compilation tool according to the patch association data; after the generation of the first incremental patch is completed, verifying the first incremental patch; if the first incremental patch has an exception, repeating the steps between reading the configuration file of the preset incremental compilation tool and generating the first incremental patch by the incremental compilation tool according to the patch association data until the newly generated first incremental patch passes the verification, or the number of repetitions is greater than the preset repetition threshold.

[0009] Optionally, after the step of obtaining the dependency relationship data of the modules included in the target project in operation by the preset first analysis tool, the method further includes: extracting the code features and context information of the code files of the modules of the target project by the preset large model; performing logical association analysis on the extracted code features and context information by the preset large model using predefined patterns and rules to obtain implicit dependency relationships; updating the implicit dependency relationships to the dependency relationship data.

[0010] Optionally, after the step of hot reloading the first module corresponding to the first code file in the target project according to the first incremental patch and restoring the running state of the target project according to the first application state data, the method further includes: executing a pre-customized automated test case to obtain an automated test result, or monitoring the current system state of the target project; verifying the first hot reload operation corresponding to the first incremental patch according to the automated test result or the current system state; if the first hot reload operation has an exception, rolling back the first module corresponding to the first code file in the target project to the version before the first hot reload operation.

[0011] To solve the above technical problems, the second technical solution adopted in the embodiments of the present application is: to provide a code hot reloading device, including: a dependency data module, configured to obtain dependency data of modules included in a target project in operation through a preset first analysis tool; a hot reloading instruction module, configured to generate a first hot reloading instruction according to the dependency data and first module information corresponding to the first code file whose change is detected when it is detected that the first code file corresponding to the target project changes; an application status data module, configured to save current first application status data of the target project using a preset snapshot mechanism according to the first hot reloading instruction; an incremental patch generation module, configured to generate a first incremental patch corresponding to the first code file according to the first hot reloading instruction through a preset incremental compilation tool; a hot reloading execution module, configured to hot reload the first module corresponding to the first code file in the target project according to the first incremental patch and restore the running state of the target project according to the first application status data.

[0012] To solve the above technical problems, the third technical solution adopted in the embodiments of the present application is: to provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the code hot reloading method as described above.

[0013] To solve the above technical problems, the fourth technical solution adopted in the embodiments of the present application is: to provide a non-volatile computer-readable storage medium storing computer-executable instructions, and when the computer-executable instructions are executed by an electronic device, the electronic device is enabled to execute the code hot reloading method as described above.

[0014] Different from the related art, the present application dynamically analyzes the dependency data of target project modules, combines the code file changes to generate targeted hot reloading instructions in real time, realizes module-level incremental updates, reduces redundant code processing compared with traditional full-scale compilation, and significantly reduces system load and update latency. Using dependency data to drive the generation of hot reloading instructions can automatically identify the scope of influence of code changes, reduce manual intervention, improve the accuracy of hot reloading, and effectively avoid system failures caused by dependency conflicts. Description of the Drawings

[0015] One or more embodiments are exemplarily illustrated by corresponding drawings. These exemplary illustrations do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, unless otherwise stated, and the drawings in the figures do not constitute a scale limitation.

[0016] Figure 1 It is a schematic diagram of the operating environment of the code hot reloading method provided by the embodiments of the present application.

[0017] Figure 2 It is a schematic diagram of the execution flow of the code hot reloading method provided by the embodiments of the present application.

[0018] Figure 3 It is a schematic diagram of the execution flow for generating hot reloading instructions in the code hot reloading method provided by the embodiments of the present application.

[0019] Figure 4 It is a schematic diagram of the execution flow for generating incremental patches in the code hot reloading method provided by the embodiments of the present application.

[0020] Figure 5 It is a schematic diagram of the system structure of the code hot reloading device provided by the embodiments of the present application.

[0021] Figure 6 It is a schematic diagram of the hardware structure of an electronic device for executing the code hot reloading method provided by the embodiments of the present application. Detailed implementation manners

[0022] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0023] It should be noted that if there is no conflict, the various features in the embodiments of the present application can be combined with each other, and all are within the protection scope of the present application. In addition, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different module division from that in the device schematic diagram or a different order from that in the flowchart.

[0024] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs. The terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not used to limit the present application. The term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.

[0025] For the convenience of understanding this embodiment, first, a code hot reloading method disclosed in the embodiments of the present application will be introduced in detail. Please refer to Figure 1 , Figure 1 It is a schematic diagram of the operating environment of the code hot reloading method provided by the embodiments of the present application, as shown in Figure 1As shown, the execution entity of the code hot reloading method provided by the embodiments of the present application is generally an electronic device with certain computing capabilities, such as a computer device. In some possible implementation manners, the code hot reloading method can be implemented by a processor calling computer-readable instructions stored in a memory. Among them, Figure 1 the computer device in Figure 1 can be a server. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. It can be understood that

[0026] Please continue to refer to Figure 2 , Figure 2 which is a schematic diagram of the execution process of the code hot reloading method provided by the embodiments of the present application. As Figure 2 shown, it includes the following steps:

[0027] S1. Obtain dependency relationship data of modules included in a running target project through a preset first analysis tool.

[0028] As an alternative implementation, after the above step S1, the code features and context information of the code files of the modules of the target project can also be extracted through a preset large model. For example, when a function uses data in a certain specific format, the large model will analyze the source of this data and determine whether it depends on the processing functions of other modules. Then, the preset large model uses predefined patterns and rules to perform logical association analysis on the extracted code features and context information to obtain implicit dependencies. For example, if a function often calls a specific function in another module to complete a certain task, the large model can judge the existence of an implicit dependency based on this pattern. In addition, the interaction relationships between multiple code files and modules can also be analyzed to find potential implicit dependencies across files and modules. The large model will track the function call chain, variable reference relationships, etc., and analyze across different files and modules. For example, when a function in one module calls a function in another module, the large model will analyze whether there is an implicit dependency in this call. Finally, update the implicit dependency relationship to the dependency relationship data. For example, in a medical diagnosis assistance system, a certain function is used to generate a patient's condition diagnosis report, and this function uses data in a certain specific format, such as structured data containing the patient's various examination indicators. The large model will analyze the source of this data and determine whether it depends on the processing functions of other modules. For example, these examination indicator data may be collected by the data collection module and processed by the data cleaning module, and the large model can identify the potential dependency relationship between the condition diagnosis report generation function and the data collection and cleaning modules. Another example is that a function in the transaction execution module of a financial system calls the account balance query function in the fund management module, and the large model will analyze whether there is an implicit dependency in this call, such as whether the transaction execution depends on the account having sufficient balance.

[0029] S2. When it is monitored that the first code file corresponding to the target project has changed, generate a first hot reload instruction according to the dependency relationship data and the first module information corresponding to the changed first code file.

[0030] As an alternative implementation, please continue to refer to Figure 3 , Figure 3 is a schematic execution flow diagram for generating a hot reload instruction in the code hot reload method provided by the embodiments of the present application. As Figure 3 shown, it includes the following steps S21 to S25.

[0031] S21. When it is monitored by a pre-deployed file system monitoring program that the first code file has changed, verify whether the hash value of the first code file is consistent before and after the change.

[0032] S22. If it is inconsistent before and after the change, obtain the change association data of the first code file in the target project.

[0033] Among them, in a complete business process, code files cooperate with each other. If the first code file changes, other related code files will be recorded. For example, in an e-commerce project, if the code file for the product addition function is modified, the code files corresponding to functions such as inventory management and order generation associated with it belong to the changed associated data. Secondly, there is an input-output relationship of data between code files. If the first code file changes, the associated data will include other code files involved in the data flow. For example, in a data analysis project, if the data collection code file is modified, the associated data cleaning and data analysis code files become the changed associated data.

[0034] S23. Obtain the first module information corresponding to the first code file and the second module information associated with the first module information from the dependency relationship data.

[0035] S24. Perform hot reloading rule matching based on the changed associated data and the second module information to obtain the hot reloading rule matching result.

[0036] Among them, the hot reloading rules are a series of pre-established conditions and operation instructions, used to specify which modules need to be hot reloaded and how to perform hot reloading under different code change situations. These rules can be formulated based on various factors such as business logic, code structure, and data dependencies. For example: Rule 1: If the change in the first code file affects the data input and output of a certain second module, then the second module needs to be hot reloaded. Rule 2: When the change in the first code file involves the core business logic shared with a certain second module, the second module must be hot reloaded. Compare the changed associated data and the second module information with the predefined hot reloading rules one by one. During the comparison process, analyze whether the changed associated data and the second module information meet the conditions of a certain rule. For example: If the changed associated data shows that the change in the first code file has caused a change in the data input format of a certain second module, and there is a rule in the predefined rules that "hot reloading is required when the data input format of the second module changes", then it is considered that the rule matches successfully.

[0037] S25. Assemble the first hot reloading instruction using the hot reloading rule matching result, the changed associated data, the first module information, and the second module information.

[0038] Among them, steps S21 to S25 can accurately identify the modules and operations that need to be hot reloaded by verifying the file hash value to determine code changes, obtaining the changed associated data and module information, and matching according to the predefined rules. Finally, assembling the instructions can respond to code changes in a timely manner, ensure the stable operation of the system, and improve the development and maintenance efficiency.

[0039] S3. According to the first hot reload instruction, use the preset snapshot mechanism to save the current first application state data of the target project.

[0040] As an optional implementation manner, step S3 above may specifically include: verifying whether the format of the first hot reload instruction conforms to the preset syntax rules. If the first hot reload instruction does not conform, stop executing the first hot reload instruction. If the first hot reload instruction conforms, check whether the target project is running normally and operable, and check whether the dependent environment of the target project is normal, and evaluate the current running state of the target project to ensure that it is in a stable and operable state. Check whether the process of the project is running normally, whether there are situations such as excessive resource occupation and abnormal errors. If the project is in an unstable state, corresponding processing may be required first, such as pausing some functions and releasing resources, to ensure the smooth progress of the snapshot saving operation. Check whether the environment on which the target project depends is normal, including database connections, network services, third-party libraries, etc. Ensure that these dependent environments can provide services normally, otherwise it may cause the saved application state data to be incomplete or inaccurate. If the target project is running normally and operable, and the dependent environment of the target project is normal, select a matching target snapshot strategy according to the running data and dependent environment of the target project. Load the target snapshot strategy, obtain the first snapshot data of the target project according to the configuration parameters of the target snapshot strategy, and store the first snapshot data in the preset storage location. This step first verifies the format of the hot reload instruction to ensure that the instruction is compliant, then comprehensively checks the project running state and dependent environment to ensure system stability and operability, and then matches the target snapshot strategy to obtain and store the snapshot data, which can save the current state of the project, provide an accurate and complete data basis for subsequent operations, and reduce the risk of errors.

[0041] S4. Use the preset incremental compilation tool to generate a first incremental patch corresponding to the first code file according to the first hot reload instruction.

[0042] As an optional implementation manner, please continue to refer to Figure 4 , Figure 4 which is a schematic diagram of the execution process of generating an incremental patch in the code hot reload method provided by the embodiments of the present application. As shown in Figure 4 , it includes the following steps S41 to S45.

[0043] S41. Read the configuration file of the preset incremental compilation tool, and load the preset incremental compilation tool according to the configuration file.

[0044] Among them, the incremental compilation tool is a compilation tool used in the software development process. Its core function is that when only partial code modifications occur, it only recompiles the modified code parts and the related code affected by these changes, rather than comprehensively compiling the entire project's code. This method can significantly reduce the time and resource consumption required for compilation and improve development efficiency. For example, Gradle in Java projects, Webpack in JavaScript projects, and Make in C++ projects.

[0045] S42. Perform syntax parsing on the received first hot reload instruction to determine whether the first hot reload instruction conforms to the preset syntax rules.

[0046] S43. If it conforms to the preset syntax rules, extract the corresponding patch association data from the syntax parsing result of the first hot reload instruction, and generate the first incremental patch according to the patch association data through the incremental compilation tool.

[0047] Among them, the incremental patch is a file that only contains the parts of the code or data that have changed since the last version. During software development and maintenance, when the code file is modified, the incremental patch records the differences of these modifications instead of the content of the entire file. Using incremental patches can update the system more efficiently because only these changed parts need to be transmitted and applied, without redeploying the entire software version, thus reducing the data transmission volume and the time required for updates. For example, the account management module of the bank's core system may have code modifications due to changes in business requirements, such as adding support for new account types. The incremental patch generated by the incremental compilation tool according to the patch association data will record the definition of the new account type, the related business logic processing code, etc. The bank can apply this incremental patch to the core system during the system maintenance time at night to quickly update the function of the account management module without having to redeploy the entire huge bank core system, thus saving time and resources. Another example is that the electronic medical record system may modify the code of the medical record data storage and management module according to new medical regulations or changes in business processes. The incremental patch will record the content of these modifications, such as newly added medical record fields, adjusted data storage formats, etc. Medical institutions can quickly update the function of the electronic medical record system by applying this incremental patch, ensure that the management of medical record data meets the latest requirements, and at the same time avoid the risks and costs that may be brought by redeploying the entire system.

[0048] S44. After the generation of the first incremental patch is completed, verify the first incremental patch.

[0049] S45. If there is an abnormality in the first incremental patch, repeat the steps between reading the configuration file of the preset incremental compilation tool and generating the first incremental patch by the incremental compilation tool according to the patch association data until the newly generated first incremental patch passes the verification, or the number of repetitions exceeds the preset repetition threshold.

[0050] Among them, steps S41 - S45 utilize the incremental compilation tool to only recompile the code change parts and the affected code, avoiding full compilation, significantly reducing the compilation time and resource consumption, improving the development and maintenance efficiency, performing syntax parsing on the hot reload instructions to ensure that the instructions conform to the preset rules, laying a foundation for accurately generating incremental patches subsequently, avoiding compilation problems caused by incorrect instructions, verifying the generated incremental patches, and repeating the generation if there are abnormalities, ensuring that the finally applied patches are accurate and error - free, and improving the stability and reliability of the system.

[0051] S5. Hot reload the first module corresponding to the first code file in the target project according to the first incremental patch, and restore the running state of the target project according to the first application status data.

[0052] As an optional implementation manner, after the above step S5, the second module associated with the first module in the target project can also be obtained according to the dependency relationship data. Then, after the hot reload of the first module corresponding to the first incremental patch is completed, the second module is hot reloaded according to the result of the hot reload of the first module. For example, in a stock trading system, when the real - time stock price update module completes the hot reload, if the hot reload is successful and the algorithm or data source for obtaining the stock price is updated, then the trading risk assessment module also needs to be hot reloaded because the new stock price data may affect the result of the risk assessment, so the code of the trading risk assessment module needs to be updated in a timely manner to ensure the accuracy of the risk assessment. Another example is in a medical system. When the patient symptom input module completes the hot reload, such as updating the symptom input format or adding new symptom options, at this time, the disease diagnosis and reasoning module also needs to be hot reloaded because the new symptom input may affect the logic of the disease diagnosis, so the disease diagnosis and reasoning module needs to update its algorithm and rules accordingly to adapt to the new symptom input. Finally, the dependency relationship data is updated according to the results of the hot reloads of the first module and the second module. Determining the associated second module with the help of the dependency relationship data, hot reloading the second module according to the result of the hot reload of the first module can ensure the coordination and functional consistency between system modules. Updating the dependency relationship data can accurately reflect the system state, improve the maintainability, and effectively avoid potential risks in module updates.

[0053] As another alternative implementation, after the above step S5, it is also possible to execute pre-customized automated test cases to obtain automated test results, or monitor the current system state of the target project. For example, in a medical system, for the first incremental patch for the update of the image recognition algorithm, the test cases will use a large number of historical medical image data of different types and different resolutions for testing to check whether the system can accurately identify the disease characteristics in the images and obtain automated test results. At the same time, the current state of the system is monitored in real time, such as the response time of the server, the memory occupancy, etc., to ensure the stable operation of the system when processing image data. Then, the first hot reload operation corresponding to the first incremental patch is verified according to the automated test results or the current system state. For example, in a financial system, if the automated test finds that there is an error in the calculation of transaction fees, or it is monitored that the concurrent processing ability of the system decreases, resulting in delays or even losses in the processing of transaction orders, then there may be a problem with the first hot reload operation. For example, there may be a flaw in the new transaction fee calculation logic, resulting in inaccurate calculation results. Finally, if there is an abnormality in the first hot reload operation, the first module corresponding to the first code file in the target project is rolled back to the version before the first hot reload operation. After the first incremental patch is introduced by hot reload, executing pre-customized automated test cases can verify whether the system can still operate its core business functions normally and accurately after the update, ensuring that the hot reload operation does not damage the original functions. When the first hot reload operation is verified to be abnormal, the first module corresponding to the first code file in the target project can be rolled back to the version before the hot reload operation, providing fault tolerance for hot reload, reducing the risk during the hot reload process, and reducing the business interruption time and potential losses.

[0054] The code hot reload method provided by the embodiments of this application, by adopting a module-level hot reload mechanism, enables the system to achieve code updates at the lowest cost. Compared with the traditional overall update method, this refined update strategy avoids unnecessary resource consumption, significantly reduces the update delay and system load, enabling the system to quickly respond to code changes and maintain stable operation while being efficient. In terms of state retention and user experience, through the state retention mechanism, when code is reloaded, the running state of the application remains unchanged. In terms of high reliability and automatic rollback, the automatic rollback mechanism when hot reload fails plays a key role. It ensures that the system can quickly recover to the previous stable state when encountering hot reload problems, avoiding system failures caused by hot reload and guaranteeing the high reliability of the system, especially suitable for scenarios with extremely high stability requirements, such as financial trading systems. In terms of efficient dependency management, the intelligent dependency management mechanism ensures the correctness and consistency of module updates. In a complex system, there are tight dependencies between modules. This mechanism can accurately identify and handle these dependencies, reducing errors caused by dependency problems and making system updates smoother and more efficient.

[0055] Please continue to refer to Figure 5 , Figure 5 which is a schematic structural diagram of a code hot reload device provided by an embodiment of the present application. As shown in Figure 5 , the code hot reload device 50 includes: a dependency data module 51, a hot reload instruction module 52, an application status data module 53, an incremental patch generation module 54, and a hot reload execution module 55.

[0056] The dependency data module 51 is used to obtain dependency data of modules included in a target project in operation through a preset first analysis tool.

[0057] The hot reload instruction module 52 is used to generate a first hot reload instruction according to the dependency data and first module information corresponding to the first code file whose change is detected when it is detected that a first code file corresponding to the target project has changed.

[0058] The application status data module 53 is used to save current first application status data of the target project using a preset snapshot mechanism according to the first hot reload instruction.

[0059] The incremental patch generation module 54 is used to generate a first incremental patch corresponding to the first code file according to the first hot reload instruction through a preset incremental compilation tool.

[0060] The hot reload execution module 55 is used to hot reload the first module corresponding to the first code file in the target project according to the first incremental patch, and restore the running state of the target project according to the first application status data.

[0061] As an optional implementation manner, the hot reload execution module 55 is further specifically used to obtain a second module associated with the first module in the target project according to the dependency data; after the hot reload of the first module corresponding to the first incremental patch is completed, hot reload the second module according to the result of the hot reload of the first module; update the dependency data according to the results after the hot reload of the first module and the second module.

[0062] As an alternative implementation, the application status data module 53 is further specifically configured to verify whether the format of the first hot reload instruction conforms to a preset syntax rule. If the first hot reload instruction does not conform, the execution of the first hot reload instruction is stopped; if the first hot reload instruction conforms, it is checked whether the target project is running normally and operable, and whether the dependency environment of the target project is normal; if the target project is running normally and operable, and the dependency environment of the target project is normal, a matching target snapshot policy is selected according to the running data and dependency environment of the target project; the target snapshot policy is loaded, and the first snapshot data of the target project is obtained according to the configuration parameters of the target snapshot policy, and the first snapshot data is stored in a preset storage location.

[0063] As an alternative implementation, the hot reload instruction module 52 is further specifically configured to, when it is monitored by a pre-deployed file system monitoring program that the first code file has changed, verify whether the hash value of the first code file is consistent before and after the change; if it is inconsistent before and after the change, obtain the change association data of the first code file in the target project; obtain the first module information corresponding to the first code file and the second module information associated with the first module information from the dependency relationship data; perform hot reload rule matching according to the change association data and the second module information to obtain a hot reload rule matching result; use the hot reload rule matching result, the change association data, the first module information and the second module information to assemble the first hot reload instruction.

[0064] As an alternative implementation, the incremental patch generation module 54 is further specifically configured to read the configuration file of the preset incremental compilation tool, and load the preset incremental compilation tool according to the configuration file; perform syntax parsing on the received first hot reload instruction to determine whether the first hot reload instruction conforms to a preset syntax rule; if it conforms to the preset syntax rule, extract the corresponding patch association data from the syntax parsing result of the first hot reload instruction, and generate the first incremental patch according to the patch association data through the incremental compilation tool; after the generation of the first incremental patch is completed, verify the first incremental patch; if the first incremental patch has an exception, repeat the steps from reading the configuration file of the preset incremental compilation tool to generating the first incremental patch according to the patch association data through the incremental compilation tool until the newly generated first incremental patch passes the verification, or the number of repetitions is greater than a preset repetition threshold.

[0065] As an alternative implementation, the dependency data module 51 is further specifically configured to extract code features and context information from the code files of the modules of the target project through a preset large model; perform logical association analysis on the extracted code features and context information by using predefined patterns and rules through the preset large model to obtain implicit dependencies; update the implicit dependencies to the dependency data.

[0066] As an alternative implementation, the hot reloading execution module 55 is further specifically configured to execute pre-customized automated test cases to obtain automated test results, or monitor the current system state of the target project; verify the first hot reloading operation corresponding to the first incremental patch according to the automated test results or the current system state; if an exception occurs in the first hot reloading operation, roll back the first module corresponding to the first code file in the target project to the version before the first hot reloading operation.

[0067] It should be noted that the above code hot reloading device can execute the code hot reloading method provided in the embodiments of the present application, and has the corresponding functional modules and beneficial effects of the execution method. For the technical details not described in detail in the embodiments of the code hot reloading device, reference can be made to the code hot reloading method provided in the embodiments of the present application.

[0068] Figure 6 is a schematic hardware structure diagram of an electronic device for executing the code hot reloading method provided in the embodiments of the present application. As Figure 6 shown, the electronic device 600 includes:

[0069] One or more processors 610 and a memory 620. Figure 6 Here, one processor 610 is taken as an example.

[0070] The processor 610 and the memory 620 can be connected through a bus or other means. Figure 6 Here, the connection through the bus is taken as an example.

[0071] The memory 620, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions / modules corresponding to the code hot reloading method in the embodiments of the present application. The processor 610 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions, and modules stored in the memory 620, that is, implements the code hot reloading method in the above method embodiments.

[0072] The memory 620 may include a program storage area and a data storage area. The program storage area may store an operating system and application programs required for at least one function. The data storage area may store data created according to the use of the code hot reload device, etc. In addition, the memory 620 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 620 may optionally include a memory remotely disposed relative to the processor 610, and these remote memories may be connected to the code hot reload device through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0073] The one or more modules are stored in the memory 620 and, when executed by the one or more processors 610, perform the code hot reload method in any of the above method embodiments. For example, perform the Figure 2 method steps S1 to S5 described above, Figure 3 method steps S21 to S25 described above, Figure 4 method steps S41 to S45 described above, to implement Figure 5 the functions of the modules 51-55 in

[0074] The above product can execute the method provided in the embodiments of the present application, and has corresponding functional modules and beneficial effects for executing the method. For technical details not described in detail in this embodiment, reference may be made to the method provided in the embodiments of the present application.

[0075] The embodiments of the present application provide a non-volatile computer-readable storage medium storing computer-executable instructions, which when executed by one or more processors, such as Figure 6 one of the processors 610, enable the one or more processors to execute the code hot reload method in any of the above method embodiments. For example, perform the Figure 2 method steps S1 to S5 described above, Figure 3 method steps S21 to S25 described above, Figure 4 method steps S41 to S45 described above, to implement Figure 5 the functions of the modules 51-55 in

[0076] The embodiments of the present application provide a computer program product, the computer program product includes a computer program stored on a non-volatile computer-readable storage medium, the computer program includes program instructions, and when the program instructions are executed by the electronic device, the electronic device is enabled to execute the code hot reload method in any of the above method embodiments. For example, perform theFigure 2 Steps S1 to S5 in Figure 3 Steps S21 to S25 in Figure 4 Steps S41 to S45 in achieve Figure 5 the functions of modules 51 - 55 in

[0077] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0078] Through the description of the above embodiments, those of ordinary skill in the art can clearly understand that each embodiment can be implemented by means of software plus a general - purpose hardware platform, and of course, it can also be implemented by hardware. Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer - readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a magnetic disk, an optical disk, a read - only memory (ROM), or a random access memory (RAM), etc.

[0079] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; under the idea of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the present application as described above. For the sake of brevity, they are not provided in detail; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A code hot reloading method, characterized in that, Including: Obtaining dependency relationship data of modules included in a target project during operation through a preset first analysis tool; When it is detected that a first code file corresponding to the target project has changed, generating a first hot reload instruction according to the dependency relationship data and first module information corresponding to the changed first code file; According to the first hot reload instruction, using a preset snapshot mechanism to save the current first application state data of the target project; Generating a first incremental patch corresponding to the first code file by a preset incremental compilation tool according to the first hot reload instruction; Hot reloading the first module corresponding to the first code file in the target project according to the first incremental patch, and restoring the running state of the target project according to the first application state data.

2. The code hot reloading method according to claim 1, wherein After the step of hot reloading the first module corresponding to the first code file in the target project according to the first incremental patch, including: Obtaining a second module associated with the first module in the target project according to the dependency relationship data; After the hot reloading of the first module corresponding to the first incremental patch is completed, hot reloading the second module according to the result of the hot reloading of the first module; Updating the dependency relationship data according to the results after the hot reloading of the first module and the second module.

3. The code hot reloading method according to claim 1, wherein The step of using a preset snapshot mechanism to save the current first application state data of the target project according to the first hot reload instruction includes: Verifying whether the format of the first hot reload instruction conforms to a preset syntax rule, and if the first hot reload instruction does not conform, stopping the execution of the first hot reload instruction; If the first hot reload instruction conforms, checking whether the target project is running normally and operable, and checking whether the dependency environment of the target project is normal; If the target project is running normally and operable, and the dependency environment of the target project is normal, selecting a matching target snapshot strategy according to the running data and dependency environment of the target project; Loading the target snapshot strategy, obtaining first snapshot data of the target project according to the configuration parameters of the target snapshot strategy, and storing the first snapshot data at a preset storage location.

4. The code hot reloading method according to claim 1, wherein The step of generating a first hot reload instruction according to the dependency relationship data and first module information corresponding to the changed first code file when it is detected that a first code file corresponding to the target project has changed includes: When it is detected by a pre-deployed file system monitoring program that the first code file has changed, verifying whether the hash value of the first code file is consistent before and after the change; If it is inconsistent before and after the change, obtaining the change association data of the first code file in the target project; Obtaining the first module information corresponding to the first code file from the dependency relationship data, and second module information associated with the first module information; Performing hot reload rule matching according to the change association data and the second module information to obtain a hot reload rule matching result; Assemble the first hot reload instruction using the result of the hot reload rule matching, the changed associated data, the first module information, and the second module information.

5. The code hot reloading method according to claim 1, wherein The step of generating the first incremental patch corresponding to the first code file by the preset incremental compilation tool according to the first hot reload instruction includes: Read the configuration file of the preset incremental compilation tool and load the preset incremental compilation tool according to the configuration file; Perform syntax parsing on the received first hot reload instruction to determine whether the first hot reload instruction conforms to the preset syntax rules; If it conforms to the preset syntax rules, extract the corresponding patch associated data from the syntax parsing result of the first hot reload instruction, and generate the first incremental patch by the incremental compilation tool according to the patch associated data; After the generation of the first incremental patch is completed, verify the first incremental patch; If there is an abnormality in the first incremental patch, repeat the steps between reading the configuration file of the preset incremental compilation tool and generating the first incremental patch by the incremental compilation tool according to the patch associated data until the newly generated first incremental patch passes the verification, or the number of repetitions is greater than the preset repetition threshold.

6. The code hot reloading method according to claim 1, wherein, After the step of obtaining the dependency relationship data of the modules included in the target project in operation by the preset first analysis tool, it further includes: Extract the code features and context information of the code files of the modules of the target project by the preset large model; Use the predefined patterns and rules by the preset large model to perform logical association analysis on the extracted code features and context information to obtain implicit dependency relationships; Update the implicit dependency relationships to the dependency relationship data.

7. The code hot reloading method according to claim 1, characterized in that After the step of hot reloading the first module corresponding to the first code file in the target project according to the first incremental patch and restoring the running state of the target project according to the first application state data, it further includes: Execute the pre-customized automated test cases to obtain the automated test results, or monitor the current system state of the target project; Verify the first hot reload operation corresponding to the first incremental patch according to the automated test results or the current system state; If there is an abnormality in the first hot reload operation, roll back the first module corresponding to the first code file in the target project to the version before the first hot reload operation.

8. A code hot reloading device, characterized in that, Includes: Dependency relationship data module, used to obtain the dependency relationship data of the modules included in the target project in operation by the preset first analysis tool; Hot reload instruction module, used to generate the first hot reload instruction according to the dependency relationship data and the first module information corresponding to the first code file when it is detected that the first code file corresponding to the target project has changed; Application state data module, used to save the current first application state data of the target project using the preset snapshot mechanism according to the first hot reload instruction; An incremental patch generation module, configured to generate a first incremental patch corresponding to the first code file according to the first hot reloading instruction by using a preset incremental compilation tool; A hot reloading execution module, configured to hot reload the first module corresponding to the first code file in the target project according to the first incremental patch, and restore the running state of the target project according to the first application state data.

9. An electronic device, characterized in that, Comprising: At least one processor; And A memory communicatively connected to the at least one processor; wherein The memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the code hot reloading method according to any one of claims 1-7.

10. A non-volatile computer-readable storage medium, characterized in that, The non-volatile computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by an electronic device, the electronic device is caused to execute the code hot reloading method according to any one of claims 1-7.

Citation Information

Cited By

  • Visual API application interface hot loading method and system based on script engine

    CN120848982A