Function processing method and device

By compiling the objective function into an executable program on the function computing platform and executing it in a target virtual machine based on the kernel, the platform's insufficient support for multiple programming languages ​​and performance overhead is solved, and resource isolation and efficient execution between functions are achieved.

CN119829062APending Publication Date: 2025-04-15CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411725901.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

Current functional computing platforms have limitations in supporting multiple programming languages, especially with less support for languages ​​with high security and performance such as Rust. Due to the dependence on intermediate layers such as WebAssembly, additional performance overhead is introduced, resulting in latency in function execution and waste of resources.

Method used

By compiling the objective function into an executable program and executing it in a kernel-based target virtual machine, the hardware virtualization characteristics of the KVM virtual machine are utilized to provide each function with an independent operating environment, ensuring resource isolation, reducing intermediate layers, and avoiding performance overhead.

Benefits of technology

It realizes resource isolation between functions, improves the security and performance of function execution, adapts to the high security requirements of modern cloud computing environments, and provides reliable guarantees for function calculation in multi-tenant scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829062A_ABST
    Figure CN119829062A_ABST
Patent Text Reader

Abstract

The invention provides a function processing method and device, and relates to the technical field of cloud computing, and the method comprises the steps: responding to a target operation request, and determining a target function needing to be called by the target operation request; compiling the target function into an executable program, wherein the executable program comprises a memory layout defined for the target function; and starting a target virtual machine based on the kernel, and executing the executable program in a memory region corresponding to the target virtual machine based on the memory layout. According to the method, the virtual machine based on the kernel is used for processing the function, and the executable program obtained by compiling the function is directly run in the corresponding memory area. On the premise of reducing intermediate layers and performing subtraction on extra performance overhead, mutual interference and data leakage between different functions are avoided. The method not only adapts to the high requirement of a modern cloud computing environment for security, but also provides reliable guarantee for function computing in a multi-tenant scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of cloud computing, and in particular to a function processing method and device. Background Art

[0002] With the rapid development of cloud computing technology, serverless computing has gradually become a new computing model, especially in the field of function computing (FaaS), which has received widespread attention and application. Function computing allows developers to run separate code functions in the cloud without having to manage the underlying infrastructure. This flexibility and efficiency allows developers to focus on the implementation of business logic and reduce operation and maintenance costs.

[0003] However, the current function computing platform has certain limitations in supporting multiple programming languages. Many popular programming languages, such as Rust, have gradually gained attention in system programming due to their efficiency and security, but their application in function computing is still relatively scarce. In related technologies, most function computing solutions rely on intermediate layers such as WebAssembly (WASM) for code execution. Although this multi-layer structure provides security, it also introduces additional performance overhead, resulting in delays in function execution and waste of resources. Summary of the invention

[0004] The embodiments of the present disclosure provide a function processing method and device, aiming to solve the problems existing in the above-mentioned background technology.

[0005] In order to solve the above technical problems, the present disclosure is implemented as follows: In a first aspect, an embodiment of the present disclosure provides a function processing method, the method comprising: In response to the target operation request, determining a target function to be called by the target operation request; Compiling the target function into an executable program, wherein the executable program includes a memory layout defined for the target function; A kernel-based target virtual machine is started, and based on the memory layout, the executable program is executed in a memory area corresponding to the target virtual machine.

[0006] Optionally, compiling the target function into an executable program includes: Specifying a memory layout for the executable program, the memory layout comprising a code area and a shared memory area, wherein the code area is a memory area for loading and executing the executable program, and the shared memory area is a memory area for interaction between the target virtual machine and the host machine; Based on the memory layout, compile the target function to generate the executable program; After executing the executable program in the memory area corresponding to the target virtual machine, the method further includes: The execution result of the executable program is obtained from the code area, and the execution result is written into the shared memory area.

[0007] Optionally, compiling the target function based on the memory layout to generate the executable program includes: Determine an operation type of a target operation corresponding to the target operation request; Determine whether the operation type of the target operation is a computing operation; In a case where the operation type belongs to a computing operation, allocating corresponding memory space for the executable program in the target virtual machine according to the memory layout, the memory layout also including a data area; Parsing the target operation request, obtaining a first data resource required for executing the executable program, and writing the first data resource into the data area; In the target virtual machine, a first data resource required by the executable program is loaded from the data area, and the executable program is loaded and executed in the code area.

[0008] Optionally, compiling the target function based on the memory layout to generate the executable program includes: Determine an operation type of a target operation corresponding to the target operation request; Determine whether the operation type of the target operation is a computing operation; When the operation type does not belong to a computing operation, obtaining a second data resource required to perform the target operation from a remote network end; Writing, in the shared memory area of ​​the target virtual machine, an interaction event for instructing the host machine to execute the target operation; The interactive event is monitored and responded to through the listener in the host machine, and the target operation is executed.

[0009] Optionally, after monitoring and responding to the interaction event and executing the target operation through a listener in the host machine, the method further includes: Writing the execution result of the host machine for the target operation into the shared memory area of ​​the target virtual machine; The state of the interaction event is modified in the shared memory area of ​​the target virtual machine to instruct the target virtual machine to continue executing the unfinished task thread.

[0010] Optionally, parsing the target operation request to obtain a first data resource required for executing the executable program, and writing the first data resource into the data area includes: Parsing the target operation request to obtain a first data resource required to execute the executable program; In the data area of ​​the target virtual machine, encapsulating the first data resource into a corresponding data sequence according to a parameter type of the first data resource; An unsigned integer array is generated according to the data sequence, and the integer length and array content of the integer array are written into the data area of ​​the target virtual machine.

[0011] Optionally, the loading of the first data resource required for the executable program from the data area includes: Read the integer length and array content in the data area of ​​the target virtual machine; Determine a data sequence corresponding to the integer array according to the integer length and the array content; The data sequence is deserialized according to a preset deserialization rule to obtain the first data resource.

[0012] Optionally, starting the kernel-based target virtual machine includes: Parsing the target operation request to obtain a uniform resource locator and a request method of the target operation request; Check whether the uniform resource locator and request method of the target operation request conform to the preset request rules; In a case where the uniform resource locator and the request method of the target operation request conform to the request rule, determining a startup path of the target virtual machine according to the uniform resource locator; Based on the startup path, determining a target virtual machine corresponding to the target function from a plurality of different kernel-based virtual machines; The target virtual machine is started.

[0013] Optionally, compiling the target function includes: The target function is compiled by using a reserved function custom writing entry using a RUST tool chain, wherein the RUST tool chain is used to convert the target function based on the RUST language into a code corresponding to the executable program.

[0014] In a second aspect, an embodiment of the present disclosure provides a function processing device, the device comprising: A determination module, configured to determine, in response to a target operation request, a target function to be called by the target operation request; A compiling module, used for compiling the target function into an executable program, wherein the executable program includes a memory layout defined for the target function; The execution module is used to start a kernel-based target virtual machine and execute the executable program in a memory area corresponding to the target virtual machine based on the memory layout.

[0015] Optionally, the compiling module includes: A designation submodule, used to specify a memory layout for the executable program, the memory layout including a code area and a shared memory area, wherein the code area is a memory area for loading and executing the executable program, and the shared memory area is a memory area for interaction between the target virtual machine and the host machine; A compiling submodule, used for compiling the target function based on the memory layout to generate the executable program; The device also includes: The first writing module is used to obtain the execution result of the executable program from the code area and write the execution result into the shared memory area.

[0016] Optionally, the compiling module includes: A first operation type determination submodule, used to determine the operation type of the target operation corresponding to the target operation request; A first judgment submodule, used to judge whether the operation type of the target operation is a computing operation; an allocation submodule, configured to allocate corresponding memory space for the executable program in the target virtual machine according to the memory layout when the operation type belongs to a computing operation, wherein the memory layout also includes a data area; A parsing submodule, configured to parse the target operation request, obtain a first data resource required for executing the executable program, and write the first data resource into the data area; The loading submodule is used to load the first data resource required by the executable program from the data area in the target virtual machine, and to load and execute the executable program in the code area.

[0017] Optionally, the compiling module includes: A first operation type determination submodule, used to determine the operation type of the target operation corresponding to the target operation request; A first judgment submodule, used to judge whether the operation type of the target operation is a computing operation; A remote acquisition submodule, configured to acquire, when the operation type does not belong to a computing operation, a second data resource required to perform the target operation from a remote network end; An event writing submodule, used for writing an interactive event for instructing the host machine to execute the target operation in the shared memory area of ​​the target virtual machine; The monitoring submodule is used to monitor and respond to the interaction event and execute the target operation through the listener in the host machine.

[0018] Optionally, the device further comprises: A second writing module, used for writing the execution result of the host machine for the target operation into the shared memory area of ​​the target virtual machine; The state modification module is used to modify the state of the interaction event in the shared memory area of ​​the target virtual machine to instruct the target virtual machine to continue executing the unfinished task thread.

[0019] Optionally, the parsing submodule includes: A parsing unit, configured to parse the target operation request to obtain a first data resource required to execute the executable program; an encapsulation unit, configured to encapsulate the first data resource into a corresponding data sequence in a data area of ​​the target virtual machine according to a parameter type of the first data resource; A serialization unit is used to generate an unsigned integer array according to the data sequence, and write the integer length and array content of the integer array into the data area of ​​the target virtual machine.

[0020] Optionally, the execution module includes: A target operation request parsing submodule, used for parsing the target operation request to obtain a uniform resource locator and a request method of the target operation request; A checking submodule, used to check whether the uniform resource locator and request method of the target operation request conform to a preset request rule; a startup path determination submodule, configured to determine the startup path of the target virtual machine according to the uniform resource locator when the uniform resource locator and the request method of the target operation request conform to the request rule; A target virtual machine determination submodule, used to determine a target virtual machine corresponding to the target function one-to-one from a plurality of different kernel-based virtual machines based on the startup path; The startup submodule is used to start the target virtual machine.

[0021] Optionally, the compiling module includes: The RUST compilation submodule is used to customize the entry through the reserved function and compile the target function using the RUST tool chain. The RUST tool chain is used to convert the target function based on the RUST language into the code corresponding to the executable program.

[0022] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: The present invention uses a kernel-based virtual machine to process functions, and directly runs the executable program compiled from the function in its corresponding memory area. The executable program not only contains the logic of the function, but also defines the memory layout for its specific needs. The hardware virtualization characteristics of the KVM virtual machine provide an independent operating environment for each function, ensuring resource isolation between functions. While reducing the middle layer and subtracting additional performance overhead, it avoids mutual interference and data leakage between different functions. It not only meets the high security requirements of modern cloud computing environments, but also provides reliable guarantees for function computing in multi-tenant scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0024] Figure 1 It is a schematic diagram of the steps of a function processing method provided by an embodiment of the present disclosure; Figure 2 is a schematic diagram of an operating environment of a kernel-based virtual machine in an embodiment of the present disclosure; Figure 3 is a schematic diagram of the memory layout defined by the executable program in an embodiment of the present disclosure; Figure 4 It is a structural block diagram of a function processing device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0025] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0026] In the related technologies, most function computing solutions rely on intermediate layers such as WebAssembly (WASM) to execute code. Although this multi-layer structure provides security, it also introduces additional performance overhead, resulting in delays in function execution and resource waste. The core idea of ​​this disclosure is based on KVM (Kernel-based Virtual Machine) technology. By compiling functions into executable programs and running them in a dedicated virtual machine environment, the hardware virtualization characteristics of KVM are effectively utilized to achieve resource isolation between functions while reducing the intermediate layer and removing additional performance overhead. It ensures that each function is executed efficiently in an independent environment, so as to achieve the technical effect of optimizing memory management, reducing interference between functions, and supporting the flexible use of multiple programming languages, especially the Rust language known for its security and performance.

[0027] Figure 1 is a schematic diagram of the steps of a function processing method provided by an embodiment of the present disclosure, such as Figure 1 As shown, the method includes: Step S101 , in response to a target operation request, determining a target function to be called by the target operation request.

[0028] The target operation request is a request issued by a user or other service. For example, suppose a user wants to perform a specific process on an image, such as adjusting the brightness and contrast of the image. The target function to be called is a function specifically used to process images. The target function can include multiple sub-functions to implement corresponding multiple sub-functions, such as adjusting the brightness of the image and adjusting the contrast of the image.

[0029] Step S102: compile the target function into an executable program, wherein the executable program includes a memory layout defined for the target function.

[0030] The executable program is generated by compiling the target function and can be loaded and executed by a virtual machine or a runtime environment. During the compilation process, a memory layout is defined for the executable program, and the memory layout refers to the organizational structure of each part of the executable program in the memory. After compilation and memory layout definition, the generated executable program contains the execution code of the target function and its memory layout information, and can be directly loaded and executed in the virtual machine at runtime.

[0031] Step S103, starting a kernel-based target virtual machine, and executing the executable program in a memory area corresponding to the target virtual machine based on the memory layout.

[0032] Start a kernel-based target virtual machine, also known as a KVM virtual machine, according to pre-configured parameters. KVM (Kernel-based Virtual Machine) is part of the Linux kernel and can transform the Linux operating system into a type 1 hypervisor, allowing multiple virtual machines to run on it. The target virtual machine is a virtual machine among multiple virtual machines that is used to process the target function, that is, each of the multiple virtual machines corresponds to the function to be processed one by one. Figure 2 Schematic diagram of the operating environment of a kernel-based virtual machine in the embodiment of the present disclosure. In the KVM environment, multiple threads can be created to process the tasks of the virtual machine. Each thread can be responsible for the management and execution of one or more virtual machines. Figure 2 , thread1 and thread2 can manage different virtual machines respectively, or process different tasks in the same virtual machine. Each thread has a VM-loop, which is a loop structure responsible for executing the instructions of the virtual machine and processing events. In a multi-threaded environment, VM-loop is responsible for scheduling different virtual machine tasks and performing context switching. In VM-loop, exe means executing instructions in the virtual machine, which is the code of the virtual machine operating system or application. KVM will convert these instructions into operations that the host can understand. T: hypercall is the representation of hypercall. Hypercall is the interface between the virtual machine and the virtual machine monitor, which allows the virtual machine to request the host to perform certain privileged operations. When the virtual machine needs to access the resources of the host (such as network, storage, etc.) or perform privileged operations (such as memory management, device control), it requests KVM to process through hypercall.

[0033] When starting the target virtual machine, certain computing resources (such as CPU, memory, storage, etc.) are allocated to it to ensure that the target virtual machine can run independently. Based on the memory layout of the executable program, the corresponding memory area is divided in the target virtual machine's memory, and the compiled executable program is loaded into the target virtual machine's memory. The code and data segments of the executable program can be directly copied to the corresponding memory area of ​​the target virtual machine. Once the executable program is loaded into the target virtual machine's memory, the target virtual machine will start to execute the executable program.

[0034] The present invention uses a kernel-based virtual machine to process functions, and directly runs the executable program compiled from the function in its corresponding memory area. The executable program not only contains the logic of the function, but also defines the memory layout for its specific needs. The hardware virtualization characteristics of the KVM virtual machine provide an independent operating environment for each function, ensuring resource isolation between functions. While reducing the middle layer and subtracting additional performance overhead, it avoids mutual interference and data leakage between different functions. It not only meets the high security requirements of modern cloud computing environments, but also provides reliable guarantees for function computing in multi-tenant scenarios.

[0035] In an optional implementation, compiling the target function into an executable program includes: Step S201, specifying a memory layout for the executable program, the memory layout including a code area and a shared memory area, wherein the code area is a memory area for loading and executing the executable program, and the shared memory area is a memory area for interaction between the target virtual machine and the host machine; In this embodiment, the memory layout of the executable program includes a code area and a shared memory area. The code area is a memory area used to store the target function logic, which is loaded into the code area and executed when the executable program is executed. The shared memory area is used for data exchange between the target virtual machine and the host machine. For example, it transfers input parameters, operating status, result data, etc. The shared memory area must have read and write permissions and support two-way data exchange.

[0036] Step S202: compile the target function based on the memory layout to generate the executable program.

[0037] It can be understood that the code is explicitly bound to the code area and the interactive data is bound to the shared memory area during compilation, that is, the role of each part of the target function memory has been determined. The compiled binary file embeds the memory layout information to guide the target virtual machine to load correctly during runtime.

[0038] In an optional implementation, compiling the target function based on the memory layout to generate the executable program includes: Step S2021: Determine the operation type of the target operation corresponding to the target operation request.

[0039] Going back to the example mentioned above, suppose the user wants to adjust the brightness and contrast of an image. The request parameters include: input image (delivered in binary stream form), parameter value for adjusting brightness (such as +20), and parameter value for adjusting contrast (such as 1.2 times). That is, the target operation request is a computational task for adjusting the brightness and contrast of the image. By analyzing the target operation request, the specific operation type of the target operation request is determined. It can be concluded that the request type is a computational operation, and pixel-level adjustment of the image is required.

[0040] Step S2022, determining whether the operation type of the target operation is a computing operation.

[0041] Considering that computing type requests usually involve higher computing resource requirements, such as CPU and memory. These tasks require higher CPU and memory resources, and may involve multiple parallel operations during execution. The KVM virtual machine provides good resource isolation capabilities, which can ensure that computing type requests run in an independent environment. Therefore, processing computing type requests in the KVM virtual machine can make good use of the advantages of KVM technology to achieve effective isolation and management of resources, which not only improves security, but also prevents resource competition between different requests, ensuring that computing-intensive tasks can obtain the required computing resources without being affected by other requests.

[0042] Step S2023, when the operation type belongs to a computing operation, a corresponding memory space is allocated to the executable program in the target virtual machine according to the memory layout, and the memory layout also includes a data area.

[0043] In this example, brightness and contrast adjustment is a typical computing operation, which belongs to the operation type of computing operation. According to the memory layout, a corresponding memory space is allocated to the executable program in the target virtual machine. Figure 3 is a schematic diagram of the memory layout defined by the executable program in the embodiment of the present disclosure, such as Figure 3 As shown, in addition to the code area and shared memory area, the memory layout also includes a data area, which is used to store temporary data required when running the target function. Figure 3 The total space occupied by an executable program with a total memory size of 128MB in memory is shown. The first 96MB is allocated to the data area, that is, the data area can store a large number of variables and data structures. The last 32MB is allocated to the code area, and VIO_BUFFER is the area representing the shared memory area.

[0044] Step S2024: parse the target operation request, obtain a first data resource required to execute the executable program, and write the first data resource into the data area.

[0045] Parse the content of the target operation request and identify the required input parameters and data. For example, in a request to adjust the brightness and contrast of an image, the input image, brightness parameters, and contrast parameters all need to be extracted. Based on the parsing results, the required first data resource will be determined. In this example, the first data resource may include a binary stream of the input image, brightness and contrast adjustment parameters, etc. The extracted first data resource is written to the previously allocated data area to ensure that the executable program can access the required input data when it is executed.

[0046] Step S2025: In the target virtual machine, the first data resource required by the executable program is loaded from the data area, and the executable program is loaded and executed in the code area.

[0047] The first data resource is read from the data area. The compiled executable program is loaded into the code area. At this time, the logic code of the target function is stored in the code area and is ready for execution. Once the data resources and code are ready, the execution process of the executable program will be started. In this process, the target virtual machine will process the input data according to the code logic, such as adjusting the brightness and contrast of the image.

[0048] After executing the executable program in the memory area corresponding to the target virtual machine, the method further includes: acquiring an execution result of the executable program from the code area, and writing the execution result into the shared memory area.

[0049] After the execution of the executable program is completed, the output results are generated and returned to the host through the shared memory area for subsequent processing or response to user requests. Specifically, after the execution of the executable program is completed, the virtual machine will check the execution status of the executable program to confirm whether the executable program has ended normally. This can be achieved by checking the return value or status code to ensure that there are no exceptions in the program. Once it is confirmed that the program has ended normally, the execution result is read from the code area, which can be a predefined variable or data structure. After obtaining the execution result, it is written to the shared memory area so that the host can access these results.

[0050] In an optional implementation, compiling the target function based on the memory layout to generate the executable program includes: Step S301: determine the operation type of the target operation corresponding to the target operation request.

[0051] Step S302: determine whether the operation type of the target operation is a computing operation.

[0052] Step S301 and step S302 are similar to step S2021 and step S2022, and are not described again here.

[0053] Step S303: when the operation type does not belong to a computing operation, obtain a second data resource required to execute the target operation from a remote network end.

[0054] In the case where the operation type does not belong to computing resources, contrary to the above, the target operation request will no longer be processed in the target virtual machine. Assume that the request sent by the user is an HTTP request with the following content: { "operation": "fetch_data", "source": "http: / / example.com / data" }; The "fetch_data" operation is a non-computational operation because its purpose is to obtain data from a remote location rather than to perform computation. Since the operation type is not a computational operation, the second data resource is obtained from the remote network. For example, an HTTP request is sent to a specified URL (such as http: / / example.com / data) and the response data is obtained. Assume that the returned data is in JSON format and the content is as follows: { "data": [1, 2, 3, 4, 5] }; The data is the second data resource required to perform the non-computing operation.

[0055] Step S304: writing an interactive event for instructing the host machine to execute the target operation into the shared memory area of ​​the target virtual machine.

[0056] Write an interaction event in the shared memory area of ​​the target virtual machine to instruct the host to execute the target operation. The interaction event can be a flag or message indicating that the "fetch_data" operation needs to be executed. Assuming that the starting address of the shared memory area is 0x2000, write the event identifier at this address, for example: 0x2000: "execute_fetch_data".

[0057] Step S305: monitor and respond to the interaction event through the listener in the host machine, and execute the target operation.

[0058] The host is configured with a listener to continuously monitor the interactive events in the shared memory area. For example, the listener checks whether there is a new event identifier at address 0x2000. When the listener detects that the event identifier is "execute_fetch_data", the target operation will be executed using the acquired second data resource.

[0059] Through the above steps, the shared memory area interacts with the host, and the host finally executes the target operation. The above steps correspond to the processing flow of the computing operation type, ensuring flexible processing of different types of operation requests and effective use of network resources.

[0060] In an optional embodiment, after monitoring and responding to the interaction event and executing the target operation through the listener in the host machine, the method also includes: writing the execution result of the host machine for the target operation into the shared memory area of ​​the target virtual machine; modifying the state of the interaction event in the shared memory area of ​​the target virtual machine to instruct the target virtual machine to continue executing the unfinished task thread.

[0061] After the listener responds to the interaction event, the host performs the target operation. For example, if the target operation is to obtain data from the remote, the host sends a request and receives the response data. Assume that the data successfully obtained by the host from the remote is as follows: { "result": [10, 20, 30, 40, 50] The host writes this execution result to the shared memory area of ​​the target virtual machine. Assuming that the starting address of the shared memory area is 0x2000, the host writes the result to this address, for example, 0x2000: [10, 20, 30, 40, 50]. Here, the host stores the result data in the shared memory in an appropriate format so that the target virtual machine can read it later. After writing the execution result, the host modifies the state of the interaction event to indicate that the target virtual machine can continue to execute the unfinished task thread, ensuring that the target virtual machine knows that the host's operation has been completed and can continue to process subsequent tasks. Assuming that the original interaction event state is a flag bit in the shared memory area, indicating "waiting for execution". The host modifies it to the "execution completed" state. Assuming that the state identifier is at the address 0x2004 in the shared memory area, the host modifies the value of the address to the new state, for example, 0x2004: "completed". The target virtual machine will periodically check the interaction event state in the shared memory area in its execution loop and check the state identifier at the address 0x2004. Once the target virtual machine detects that the state has been changed to "completed", it will continue to execute the unfinished task thread.

[0062] In this embodiment, after the host executes the target operation, it can effectively pass the result to the target virtual machine and instruct the virtual machine to continue to execute the unfinished task by modifying the state of the interaction event. This realizes efficient collaboration between the host and the virtual machine, ensuring the smooth operation and effective use of resources.

[0063] In an optional implementation, parsing the target operation request, obtaining the first data resource required to execute the executable program, and writing the first data resource into the data area includes: parsing the target operation request, obtaining the first data resource required to execute the executable program; in the data area of ​​the target virtual machine, encapsulating the first data resource into a corresponding data sequence according to a parameter type of the first data resource; generating an unsigned integer array according to the data sequence, and writing the integer length and array content of the integer array into the data area of ​​the target virtual machine.

[0064] The following further illustrates step S2024 with reference to an example.

[0065] For example, a target operation request looks like this: { "operation": "calculate", "parameters": { "input1": 5, "input2": 10 } } The received target operation request is parsed to extract the first data resource required for executing the executable program. In this example, the first data resource may be the values ​​of input1 and input2, that is, 5 and 10.

[0066] Determine based on the parameter type of the first data resource (such as integer, floating point number, string, etc.). Assume that in this example, input1 and input2 are both integers. Encapsulate these parameters into corresponding data sequences. Data sequences refer to organizing parameters in a specific format for subsequent processing. In this example, the parameters can be encapsulated into a simple array data_sequence = [5, 10].

[0067] Convert the encapsulated data sequence into an unsigned integer array. That is, all values ​​will be converted to unsigned integer format to ensure that they can be processed correctly in the virtual machine. Assuming that each parameter in the data sequence is converted to an unsigned integer, the resulting array is as follows: unsigned_integer_array = [5, 10]. Calculate the length of the unsigned integer array. In this example, the length is 2. Write the length and contents of the integer array to the data area of ​​the target virtual machine.

[0068] In an optional embodiment, the loading of the first data resource required for the executable program from the data area includes: reading the integer length and array content in the data area of ​​the target virtual machine; determining a data sequence corresponding to the integer array based on the integer length and the array content; and deserializing the data sequence according to a preset deserialization rule to obtain the first data resource.

[0069] Read the integer length stored in the data area. Assuming that the length of the array is stored at the starting address 0x3000 of the data area, the virtual machine will perform a read operation: length = read(0x3000) / / Assume that the length read is 2. Next, read the corresponding amount of array content from the data area based on the length read. Assume that the array content starts at address 0x3004: array_content = read(0x3004, length) / / The content read is [5, 10]. Construct the corresponding data sequence based on the integer length read and the array content. In this example, the array content read is [5, 10], so the data sequence will be: data_sequence = [5, 10].

[0070] Deserialization is the process of converting serialized data back to the original data structure. The data sequence is processed according to the preset deserialization rules, which may include the identification of data types and the parsing of data formats. For example, assuming that each element in the data sequence is an integer, it will be deserialized according to the integer type. According to the deserialization rules, the data sequence [5,10] will be converted back to the original first data resource. In this example, the result of deserialization can be a data structure (such as an array or an object), represented as: { "params": [5, 10] }After the above steps, the first data resource required by the executable program is finally obtained.

[0071] In an optional embodiment, the starting of the kernel-based target virtual machine includes: parsing the target operation request to obtain the uniform resource locator and request method of the target operation request; checking whether the uniform resource locator and request method of the target operation request comply with preset request rules; if the uniform resource locator and request method of the target operation request comply with the request rules, determining the starting path of the target virtual machine according to the uniform resource locator; based on the starting path, determining a target virtual machine corresponding to the target function one-to-one from a plurality of different kernel-based virtual machines; and starting the target virtual machine.

[0072] The target operation request includes a uniform resource locator (URL) and a request method (such as GET, POST, etc.). For example, suppose the content of the target operation request is as follows: URL: http: / / example.com / api / function Method: POST Extract the uniform resource locator (URL) and request method from the target operation request. According to the above example, after parsing, the uniform resource locator (URL) is obtained: http: / / example.com / api / function; request method: POST. Verify whether the extracted URL and request method meet the preset request rules. These rules can be defined by the system administrator, and only requests that meet specific formats or conditions can be processed. For example, the preset rules require that the URL must start with / api / and the request method can only be GET or POST. If the request meets the rules, it will continue to execute; if not, an error response is returned. If the URL and request method of the target operation request meet the preset rules, determine the startup path of the target virtual machine based on the content of the URL. The startup path refers to an internally defined path used to point to the target virtual machine or its configuration. Find the target virtual machine that corresponds to the target function one by one among multiple existing kernel-based virtual machines. That is, according to the previously determined startup path, find the virtual machine instance that matches it. Once the target virtual machine is determined, perform the startup operation. The startup operation can include steps such as allocating resources, initializing the virtual machine environment, and loading necessary programs. After the target virtual machine is started, it will be ready to receive and process subsequent operation requests.

[0073] Through the above steps, a kernel-based target virtual machine can be effectively started, ensuring that the request can be correctly processed and the target virtual machine can run in a suitable environment.

[0074] In an optional implementation, compiling the target function includes: compiling the target function using a RUST tool chain through a reserved function custom writing entry, wherein the RUST tool chain is used to convert the RUST language-based target function into a code corresponding to the executable program.

[0075] The disclosed embodiment provides a reserved entry for developers, in which the developers can write their own target functions. The entry is a specific code location, which can be a function definition, allowing developers to implement specific functions according to requirements.

[0076] The RUST toolchain is a set of tools for developing and compiling RUST language programs, including compilers (such as rustc), package managers (such as cargo), etc. It can convert RUST code into executable programs. After the developer has written the target function, the RUST toolchain will be called to compile the function. The compilation process converts the RUST source code into machine code or executable programs so that the program can run in the target virtual machine. The compiled executable program is a binary file that contains the logic of the target function and contains all the necessary code to implement the functions written by the developer.

[0077] The RUST language was designed with performance in mind and is capable of generating efficient machine code. Its compiler has strong optimization capabilities and can provide efficient execution without sacrificing performance. In addition, RUST is known for its memory safety. It reduces problems such as memory leaks and data competition through mechanisms such as ownership, borrowing, and lifecycles, allowing RUST programs to run more safely in concurrent scenarios. It can be seen that the RUST language provides strong concurrency support, allowing developers to write efficient concurrent programs without introducing common concurrency problems in traditional programming languages. This makes RUST an ideal choice in the Function Compute service, which can effectively improve the execution efficiency and security of functions.

[0078] Figure 4 is a structural block diagram of a function processing device provided by an embodiment of the present disclosure, such as Figure 4 As shown, the device comprises: A determination module 301 is used to determine, in response to a target operation request, a target function to be called by the target operation request; A compiling module 302, configured to compile the target function into an executable program, wherein the executable program includes a memory layout defined for the target function; The execution module 303 is used to start a kernel-based target virtual machine and execute the executable program in a memory area corresponding to the target virtual machine based on the memory layout.

[0079] In one embodiment, the compiling module includes: A designation submodule, used to specify a memory layout for the executable program, the memory layout including a code area and a shared memory area, wherein the code area is a memory area for loading and executing the executable program, and the shared memory area is a memory area for interaction between the target virtual machine and the host machine; A compiling submodule, used for compiling the target function based on the memory layout to generate the executable program; The device also includes: The first writing module is used to obtain the execution result of the executable program from the code area and write the execution result into the shared memory area.

[0080] In one embodiment, the compiling module includes: A first operation type determination submodule, used to determine the operation type of the target operation corresponding to the target operation request; A first judgment submodule, used to judge whether the operation type of the target operation is a computing operation; an allocation submodule, configured to allocate corresponding memory space for the executable program in the target virtual machine according to the memory layout when the operation type belongs to a computing operation, wherein the memory layout also includes a data area; A parsing submodule, configured to parse the target operation request, obtain a first data resource required for executing the executable program, and write the first data resource into the data area; The loading submodule is used to load the first data resource required by the executable program from the data area in the target virtual machine, and to load and execute the executable program in the code area.

[0081] In one embodiment, the compiling module includes: A first operation type determination submodule, used to determine the operation type of the target operation corresponding to the target operation request; A first judgment submodule, used to judge whether the operation type of the target operation is a computing operation; A remote acquisition submodule, configured to acquire, when the operation type does not belong to a computing operation, a second data resource required to perform the target operation from a remote network end; An event writing submodule, used for writing an interactive event for instructing the host machine to execute the target operation in the shared memory area of ​​the target virtual machine; The monitoring submodule is used to monitor and respond to the interaction event and execute the target operation through the listener in the host machine.

[0082] In one embodiment, the device further comprises: A second writing module, used for writing the execution result of the host machine for the target operation into the shared memory area of ​​the target virtual machine; The state modification module is used to modify the state of the interaction event in the shared memory area of ​​the target virtual machine to instruct the target virtual machine to continue executing the unfinished task thread.

[0083] In one embodiment, the parsing submodule includes: A parsing unit, configured to parse the target operation request to obtain a first data resource required to execute the executable program; an encapsulation unit, configured to encapsulate the first data resource into a corresponding data sequence in a data area of ​​the target virtual machine according to a parameter type of the first data resource; A serialization unit is used to generate an unsigned integer array according to the data sequence, and write the integer length and array content of the integer array into the data area of ​​the target virtual machine.

[0084] In one embodiment, the execution module includes: A target operation request parsing submodule, used for parsing the target operation request to obtain a uniform resource locator and a request method of the target operation request; A checking submodule, used to check whether the uniform resource locator and request method of the target operation request conform to a preset request rule; a startup path determination submodule, configured to determine the startup path of the target virtual machine according to the uniform resource locator when the uniform resource locator and the request method of the target operation request conform to the request rule; A target virtual machine determination submodule, used to determine a target virtual machine corresponding to the target function one-to-one from a plurality of different kernel-based virtual machines based on the startup path; The startup submodule is used to start the target virtual machine.

[0085] In one embodiment, the compiling module includes: The RUST compilation submodule is used to customize the entry through the reserved function and compile the target function using the RUST tool chain. The RUST tool chain is used to convert the target function based on the RUST language into the code corresponding to the executable program.

[0086] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, devices, electronic devices, and storage media. Therefore, the embodiments of the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present disclosure may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0087] The embodiments of the present disclosure are described with reference to the flowcharts and / or block diagrams of the methods and devices according to the embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing terminal device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded into a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable terminal device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0088] Although the preferred embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present disclosure.

[0089] Finally, it should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "include..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements. A function processing method and device provided by the present disclosure are described in detail above. The principle and implementation method of the present disclosure are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and its core idea of ​​the present disclosure; at the same time, for those of ordinary skill in the art, according to the idea of ​​the present disclosure, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present disclosure.

Claims

1. A function processing method, characterized in that: The method comprises: In response to the target operation request, determining a target function to be called by the target operation request; Compiling the target function into an executable program, wherein the executable program includes a memory layout defined for the target function; A kernel-based target virtual machine is started, and based on the memory layout, the executable program is executed in a memory area corresponding to the target virtual machine.

2. The method according to claim 1, characterized in that: The compiling the target function into an executable program comprises: Specifying a memory layout for the executable program, the memory layout comprising a code area and a shared memory area, wherein the code area is a memory area for loading and executing the executable program, and the shared memory area is a memory area for interaction between the target virtual machine and the host machine; Based on the memory layout, compile the target function to generate the executable program; After executing the executable program in the memory area corresponding to the target virtual machine, the method further includes: The execution result of the executable program is obtained from the code area, and the execution result is written into the shared memory area.

3. The method according to claim 2, characterized in that The compiling the target function based on the memory layout to generate the executable program includes: Determine an operation type of a target operation corresponding to the target operation request; Determine whether the operation type of the target operation is a computing operation; In a case where the operation type belongs to a computing operation, allocating corresponding memory space for the executable program in the target virtual machine according to the memory layout, the memory layout also including a data area; Parsing the target operation request, obtaining a first data resource required for executing the executable program, and writing the first data resource into the data area; In the target virtual machine, a first data resource required by the executable program is loaded from the data area, and the executable program is loaded and executed in the code area.

4. The method according to claim 2, characterized in that: The compiling the target function based on the memory layout to generate the executable program includes: Determine an operation type of a target operation corresponding to the target operation request; Determine whether the operation type of the target operation is a computing operation; When the operation type does not belong to a computing operation, obtaining a second data resource required to perform the target operation from a remote network end; Writing, in the shared memory area of ​​the target virtual machine, an interaction event for instructing the host machine to execute the target operation; The interactive event is monitored and responded to through the listener in the host machine, and the target operation is executed.

5. The method according to claim 4, characterized in that After the listener in the host machine monitors and responds to the interaction event and performs the target operation, the method further includes: Writing the execution result of the host machine for the target operation into the shared memory area of ​​the target virtual machine; The state of the interaction event is modified in the shared memory area of ​​the target virtual machine to instruct the target virtual machine to continue executing the unfinished task thread.

6. The method according to claim 3, characterized in that The step of parsing the target operation request, obtaining a first data resource required for executing the executable program, and writing the first data resource into the data area includes: Parsing the target operation request to obtain a first data resource required to execute the executable program; In the data area of ​​the target virtual machine, encapsulating the first data resource into a corresponding data sequence according to a parameter type of the first data resource; An unsigned integer array is generated according to the data sequence, and the integer length and array content of the integer array are written into the data area of ​​the target virtual machine.

7. The method according to claim 6, characterized in that The first data resource required for loading the executable program from the data area includes: Read the integer length and array content in the data area of ​​the target virtual machine; Determine a data sequence corresponding to the integer array according to the integer length and the array content; The data sequence is deserialized according to a preset deserialization rule to obtain the first data resource.

8. The method according to claim 1, characterized in that: The starting of the kernel-based target virtual machine includes: Parsing the target operation request to obtain a uniform resource locator and a request method of the target operation request; Check whether the uniform resource locator and request method of the target operation request conform to the preset request rules; In a case where the uniform resource locator and the request method of the target operation request conform to the request rule, determining a startup path of the target virtual machine according to the uniform resource locator; Based on the startup path, determining a target virtual machine corresponding to the target function from a plurality of different kernel-based virtual machines; The target virtual machine is started.

9. The method according to claim 2, characterized in that: The compiling of the target function comprises: The target function is compiled by using a reserved function custom writing entry using a RUST tool chain, wherein the RUST tool chain is used to convert the target function based on the RUST language into a code corresponding to the executable program.

10. A function processing device, characterized in that: The device comprises: A determination module, configured to determine, in response to a target operation request, a target function to be called by the target operation request; A compiling module, used for compiling the target function into an executable program, wherein the executable program includes a memory layout defined for the target function; The execution module is used to start a kernel-based target virtual machine and execute the executable program in a memory area corresponding to the target virtual machine based on the memory layout.