Sandbox fast creation method and system for server non-aware computing scenario
By reusing the pre-initialized instance state using the sandbox fork primitive and leveraging the template instance cache pool and Supervisor component, the high startup latency and low efficiency of the memory partition sandbox system are resolved, enabling rapid instance creation.
Patent Information
- Application Number
- CN202411176686.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2044-08-26
AI Technical Summary
Existing memory partitioning sandbox systems suffer from high startup latency and low instance creation efficiency in certain scenarios.
A rapid sandbox creation mechanism with memory partitioning is adopted. By reusing the pre-initialized instance state through the sandbox fork primitive, and utilizing the template instance cache pool and Supervisor component, combined with the CheriBSD operating system kernel, the rapid creation of sandbox instances is achieved.
It reduces sandbox cold start latency, improves instance creation efficiency, and solves the problem of high cold start overhead in memory partitioned sandbox systems under server-invisible computing.
Smart Images

Figure CN119149129B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of cloud computing, in particular to a function sandbox mechanism and a function cold start optimization mechanism in a server-unaware computing scenario. BACKGROUND
[0002] Server-unaware computing is a new cloud computing service mode, which enables users to focus on business innovation without worrying about specific underlying infrastructure and without additional learning costs to have agile and efficient cloud business development and deployment experience. In a server-unaware computing system, a sandbox mechanism is a key security measure that can isolate the execution environment and ensure that the code runs in a controlled and secure environment. The sandbox mechanism can resist various potential security threats, such as cross-function data leakage and untrusted code execution. When the server-unaware computing platform processes an external incoming function request, if the function instance corresponding to the request does not exist at this time, the function instance needs to be cold started. At this time, the server-unaware computing platform needs to create a function instance in real time, complete sandbox creation and application code loading, and then continue to execute the application logic to process the function call request. Compared with the case where the function instance exists when the request arrives, the request processing process of the function in the cold start case involves an additional sandbox creation process and has a higher call delay.
[0003] For example, the existing patent application for a kind of based on remote loading's customizable APP fusion method with publication number CN115987959A, the existing method includes: constructing APP fusion architecture, through APP main application based on remote loading dynamic introduction APP sub application in APP fusion architecture and carry out APP fusion, wherein through APP main application according to custom configuration APP sub application, according to configuration fusion loading APP sub application, and render APP sub application, provide data and event support for APP sub application, meet the communication needs between APP sub application;And through APP main application uses the way of webcomponent container combination webview sandbox to isolate the APP sub application loaded in isolation. However, the foregoing existing sandbox isolation mechanism is mainly based on container or virtual machine isolation mechanism, which is based on the process isolation mechanism provided by the operating system, and has a large isolation pin. Process involves more system resources, needs more initialization steps when creating, and different instances are independent of each other, cannot share instances to reduce cold start delay. For example, the existing patent application for a kind of eBPF memory isolation method and system based on kernel state memory isolation hardware characteristics with publication number CN116127445A, the existing method includes: step S1: call auxiliary function;Step S2: the landing function checks whether the parameters of auxiliary function call are legal;If not pass the check, error processing will be carried out, and the execution of the entire eBPF program is ended;If pass the check, enter step S3;Step S3: update PKRS temporary exit sandbox;Step S4: synchronize shadow object back to kernel object;Step S5: call real auxiliary function;Step S6: synchronize kernel object back to shadow object;Step S7: update the value of PKRS to re-enter the sandbox;Step S8: end calling auxiliary function. However, the foregoing sandbox system based on memory partition isolation mechanism uses user state memory isolation mechanism to realize memory isolation, does not need to involve the state switching of kernel and user state in the stages of sandbox scheduling switching and sandbox memory isolation setting, can provide higher isolation performance;And multiple sandbox instances safely share process instances, have fewer initialization steps and lower cold start overhead. Therefore, exploring memory partition sandbox mechanism with low cold start delay plays an important role in improving server perception-free computing service quality for cloud vendors.
[0004] The existing memory partition sandbox mechanism can be divided into two categories according to the provided isolation level: weak isolation sandbox mechanism and strong isolation sandbox mechanism. For the weak isolation sandbox mechanism, since it does not isolate application system resources, its cold start delay is low and memory overhead is low, but the isolation security provided is poor;For the strong isolation sandbox mechanism, it provides additional system resource isolation through library operating system mechanism, and has good security. However, since it introduces an additional library operating system mechanism, it introduces additional initialization steps in the instance startup process, increasing the cold start delay.
[0005] Existing technologies suffer from technical problems such as high startup latency and low instance creation efficiency in memory partitioning sandbox systems under certain scenarios. Summary of the Invention
[0006] The technical problem to be solved by this invention is: how to solve the technical problems of high startup latency and low instance creation efficiency of memory partition sandbox systems in specific scenarios in the prior art.
[0007] This invention solves the above-mentioned technical problems by employing the following technical solution: A method for rapid sandbox creation for server-insensitive computing scenarios includes:
[0008] S1. For server-insensitive computing scenarios, a rapid creation mechanism for memory partition sandboxes is built and utilized to address the high cold start latency of the memory partition sandbox system in this scenario. In the CAP-VM memory partition sandbox system, a template instance cache pool component and a Supervisor component are added for sandbox cold start operations. The cache pool component maintains the template instance corresponding to the function, enabling the template instance corresponding to the function to complete the sandbox fork operation. The Supervisor component implements the sandbox fork primitive based on the modified sandbox runtime and CheriBSD operating system kernel data.
[0009] S2. Obtain and utilize application initialization process similarity information. For memory partitioning sandbox scenarios, use offline pre-initialized instances and reuse the pre-initialized instance state during online calls for instance creation operations.
[0010] S3. Utilize the integrated operating system kernel and sandbox runtime to optimize the instance creation operation of the sandbox, set the sandbox fork primitive, and create a new instance based on the existing instance through the sandbox fork primitive.
[0011] This invention proposes a rapid creation mechanism for memory partitioned sandboxes in server-insensitive computing scenarios. By providing the sandbox fork primitive, it reuses the pre-initialized instance state, thereby skipping the sandbox instance cold start process, reducing sandbox cold start latency, and solving the problem of high cold start overhead in memory partitioned sandbox systems under server-insensitive computing.
[0012] This invention leverages the similarity of application initialization processes to skip the instance initialization process and accelerate instance creation in memory partitioning sandbox scenarios by using offline pre-initialized instances and reusing the pre-initialized instance state during online invocation.
[0013] In a more specific technical solution, S1 includes:
[0014] S11. Enables the sandbox system to perform pre-maintenance operations on the template instance corresponding to the function, and performs new instance creation operations based on the template instance corresponding to the function through the sandbox fork primitive.
[0015] S12. When a pre-defined function is deployed to the system, a sandbox fork cold start optimization operation is performed based on the parameter configuration information and the template instance corresponding to the function.
[0016] S13. When a function request arrives, first check if the template instance cache pool contains a template instance corresponding to the function;
[0017] S14. If so, a new instance is created using the sandbox fork primitive to complete the function request;
[0018] S15. If not, perform a cold start operation to trigger the offline creation of a template instance and add the offline creation module instance to the template instance cache pool so that when the current function is called, a cold start is accelerated by forking the template instance.
[0019] S16. Based on the resource type, design the fork mechanism in the sandbox fork primitive, use the Supervisor component, and establish a debugging relationship with the sandbox runtime process through the ptrace system call operation to monitor and adjust the state of the sandbox runtime process.
[0020] S17. Utilize the sandbox file resource namespace mechanism to virtualize system file descriptor resources and configure the state of file resources in the sandbox fork operation.
[0021] This invention utilizes the integration of the operating system kernel and the sandbox runtime to accelerate the sandbox creation process. It designs a sandbox fork primitive, which allows for the rapid creation of new instances based on existing sandbox instances.
[0022] In a more specific technical solution, in S16, the call parameter combination of the ptrace system is used to adjust the process state of the sandbox runtime, implement the sandbox instance thread resource interruption mechanism and status acquisition mechanism, and expose the sandbox instance thread resource interruption mechanism and status acquisition mechanism to the sandbox runtime through inter-process pipe communication.
[0023] In more specific technical solutions, the fork mechanism in S16 includes: a fork mechanism for thread resources, a fork mechanism for memory resources, and a fork mechanism for file resources.
[0024] In a more specific technical solution, within the thread resource fork mechanism, a Supervisor component is designed and utilized to change the state of sandbox threads during runtime.
[0025] In more specific technical solutions, the thread resource fork mechanism also includes: thread interruption mechanism and thread copying mechanism.
[0026] In a more specific technical solution, in S16, the memory resource fork mechanism includes a memory resource operating system partition call pfork mechanism. The parameters received by the memory resource operating system partition call pfork mechanism include: template instance memory partition start address template, pre-created new instance memory partition start address addr, and memory partition length len.
[0027] This invention designs a memory partitioning sandbox fork mechanism and implements the sandbox system Bootless-tfork based on the existing memory partitioning system CAP-VM. The design idea of this system is to efficiently reuse the offline pre-initialized instance state to complete the instance initialization process through the sandbox fork primitive, thereby skipping the instance initialization stage, accelerating instance creation, and reducing function cold start latency.
[0028] In a more specific technical solution, in S16, within the file resource fork mechanism, during the process fork system call, a new process instance is generated through fork to hold a copy of the original process's file descriptor in order to access files already opened by the original process.
[0029] In more specific technical solutions, the file resource fork mechanism also includes: sandbox file resource namespace mechanism and host file resource related processing.
[0030] In more specific technical solutions, sandbox rapid creation systems for server-insensitive computing scenarios include:
[0031] The high cold start latency tuning module is designed for server-insensitive computing scenarios. It builds and utilizes a rapid creation mechanism for memory partition sandboxes to address the high cold start latency of the memory partition sandbox system in this scenario. In the CAP-VM memory partition sandbox system, a template instance cache pool component and a Supervisor component are added for sandbox cold start operations. The cache pool component maintains the template instances corresponding to functions, enabling the template instances corresponding to functions to complete the sandbox fork operation. The Supervisor component implements the sandbox fork primitive based on the modified sandbox runtime and CheriBSD operating system kernel data.
[0032] The online invocation processing module is used to obtain and utilize application initialization process similarity information. For memory partitioning sandbox scenarios, it uses offline pre-initialized instances and reuses the pre-initialized instance state during online invocation for instance creation operations. The online invocation processing module is connected to the high-cold startup latency tuning module.
[0033] The new instance creation module is used to optimize the instance creation operation of the sandbox by integrating the operating system kernel and sandbox runtime. It sets the sandbox fork primitive and creates a new instance based on the existing instance through the sandbox fork primitive. The new instance creation module is connected to the online call processing module.
[0034] This invention proposes a rapid creation mechanism for memory partitioned sandboxes in server-insensitive computing scenarios. By providing the sandbox fork primitive, it reuses the pre-initialized instance state, thereby skipping the sandbox instance cold start process, reducing sandbox cold start latency, and solving the problem of high cold start overhead in memory partitioned sandbox systems under server-insensitive computing.
[0035] This invention leverages the similarity of application initialization processes to skip the instance initialization process and accelerate instance creation in memory partitioning sandbox scenarios by using offline pre-initialized instances and reusing the pre-initialized instance state during online invocation.
[0036] This invention utilizes the integration of the operating system kernel and the sandbox runtime to accelerate the sandbox creation process. It designs a sandbox fork primitive, which allows for the rapid creation of new instances based on existing sandbox instances.
[0037] This invention designs a memory partitioning sandbox fork mechanism and implements the sandbox system Bootless-tfork based on the existing memory partitioning system CAP-VM. The design idea of this system is to efficiently reuse the offline pre-initialized instance state to complete the instance initialization process through the sandbox fork primitive, thereby skipping the instance initialization stage, accelerating instance creation, and reducing function cold start latency.
[0038] This invention solves the technical problems of high startup latency and low instance creation efficiency of memory partitioning sandbox systems in specific scenarios in the prior art. Attached Figure Description
[0039] Figure 1 This is a schematic diagram of the basic steps of the rapid sandbox creation method for server-insensitive computing scenarios according to Embodiment 1 of the present invention;
[0040] Figure 2 This is a schematic diagram of the data flow processing of the sandbox rapid creation system for server-insensitive computing scenarios in Embodiment 1 of the present invention;
[0041] Figure 3 This is a schematic diagram of data flow processing for the sandbox thread interruption mechanism in Embodiment 1 of the present invention;
[0042] Figure 4 This is a schematic diagram of the data flow processing of the sandbox thread state extraction mechanism in Embodiment 1 of the present invention;
[0043] Figure 5This is a schematic diagram of the pfork system call semantics in Embodiment 1 of the present invention;
[0044] Figure 6 This is a schematic diagram of the file resource fork mechanism in Embodiment 1 of the present invention. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0046] Example 1
[0047] like Figure 1 As shown, the method for rapid sandbox creation in server-insensitive computing scenarios provided by this invention includes:
[0048] S1. For server-insensitive computing scenarios, a memory partitioning sandbox rapid creation mechanism is built and utilized to handle the high startup latency of the memory partitioning sandbox system in this scenario.
[0049] like Figure 2 As shown, in the overall architecture of the sandbox rapid creation system for server-insensitive computing scenarios in this embodiment, a template instance cache pool component and a Supervisor component are added to the original CAP-VM memory partitioning sandbox system implementation to accelerate the sandbox cold start process. The cache pool component is used to maintain the template instance corresponding to the function, ensuring that the corresponding template instance exists so that the sandbox fork operation can be completed; the sandbox fork primitive is implemented by adding the Supervisor component and modifying the sandbox runtime and CheriBSD operating system kernel. In the sandbox rapid creation system for server-insensitive computing scenarios, the sandbox system needs to maintain the template instance of the corresponding function instance in advance. The template instance refers to the sandbox instance that has completed the initialization process and is loaded into memory in advance. The sandbox fork primitive can be used to create a new instance based on the template instance. In this embodiment, the sandbox fork primitive is similar to the existing process fork system call. Through this fork primitive, a new instance with the same state as the current instance can be created. The state of system resources such as threads, address space, and files is consistent with the template instance, and the new instance and the original instance can run independently and hold different resource copies.
[0050] In this embodiment, when a function is deployed to the system, the sandbox fork cold start optimization mentioned in this invention can be enabled by configuring whether to save a template instance for the function. When a function request arrives, the system first checks whether a template instance of the corresponding function exists in the template instance cache pool. If it exists, a new instance is created using the sandbox fork primitive to complete the function request; if it does not exist, a complete instance cold start process is performed. Furthermore, while completing the above cold start, an offline creation of the template instance and its addition to the cache pool are triggered, allowing subsequent calls to the function to be accelerated by forking the template instance. The design of this fork primitive can vary depending on the type of resource being processed, including but not limited to: fork mechanisms for thread resources, fork mechanisms for memory resources, and fork mechanisms for file resources.
[0051] In the thread resource fork mechanism of this embodiment, an additional Supervisor component is designed to change the state of sandbox threads during runtime. Operations in the thread resource fork mechanism include, but are not limited to, thread interruption and thread copying. In this embodiment, the thread interruption mechanism occurs before the actual fork operation in the sandbox. Interrupting the threads within the sandbox ensures that the sandbox instance is in a consistent state, allowing execution to continue in subsequent new instances based on this state. In this embodiment, the sandbox thread resource copying mechanism includes, but is not limited to, obtaining the thread resource state of an existing sandbox instance and creating a thread object in a new sandbox instance with a state consistent with the existing template instance.
[0052] like Figure 3 As shown, in the sandbox thread fork mechanism of this embodiment, the sandbox runtime first sends a thread interruption request to the Supervisor component through a shared pipe. The request content includes the thread instance ID contained in the sandbox instance. After receiving the thread interruption request, the Supervisor component initiates an interruption request to the CheriBSD kernel by specifying the PTRACE_ATTACH parameter through the ptrace system call. After receiving the system call, the CheriBSD kernel sends a SIGSTOP signal to the specified thread according to its internal implementation, causing it to be interrupted. After sending the signal to the specified thread, the system call returns. After completing the system call, the Supervisor component completes the thread interruption request processing and sends the request back to the sandbox snapshot module.
[0053] like Figure 4 As shown in this embodiment, after the sandbox thread is interrupted, the thread fork mechanism needs to extract the sandbox thread state information and construct a new instance thread resource based on this information. Figure 4This section demonstrates how the thread information extraction mechanism is implemented in the Botless-tfork system. Similar to the thread interruption mechanism, this system utilizes the operating system's ptrace system call mechanism, which is completed collaboratively by the Supervisor and the sandbox snapshot module. Using the ptrace system call parameter with PTRACE_GETREGS, the register values of a specified thread can be obtained when the traced process is paused. The overall process is as follows: During the sandbox thread replication process, after the thread is interrupted in the previous step, the snapshot module can again request the Supervisor to obtain the thread register status. Upon receiving the request, the Supervisor component obtains the current register status of the specified thread one by one using the ptrace PTRACE_GETREGS parameter. After receiving the system call request, the CheriBSD kernel reads the corresponding user-mode register status of the thread in the kernel and writes it back to the specified memory area of the user-mode Supervisor. Finally, after the system call returns, the Supervisor component obtains the register status of the specified thread and writes the response back to the snapshot module through a pipe, completing the extraction of thread resource metadata.
[0054] In this embodiment, a newly added Supervisor component is used. It establishes a debugging relationship with the sandbox runtime process via the ptrace system call, enabling monitoring and modification of the sandbox runtime process state. In this embodiment, the parameter combinations of the ptrace system call are used to change the state of the sandbox runtime process, completing the interruption and state acquisition mechanism for sandbox instance thread resources, and exposing it to the sandbox runtime through inter-process pipe communication. In the sandbox fork operation of this embodiment, the sandbox runtime completes the thread resource fork operation by pipe-calling the relevant services provided by the Supervisor component.
[0055] In the implementation of the memory resource fork mechanism in this embodiment, a new memory resource operating system call, pfork, meaning a partition fork mechanism, is designed. This system call receives three parameters: template specifies the starting address of the template instance's memory partition, addr specifies the starting address of the new instance's memory partition to be created, and len specifies the memory partition length. Using these three parameters, the pfork system call can identify the memory partition corresponding to the template instance and the memory partition of the new instance created by the sandbox fork operation, and complete the fork operation of the memory partition. In this embodiment, the introduction of the pfork system call does not require introducing excessive support for sandbox objects into the kernel; it only needs to reuse existing processes and memory-mapped objects. Furthermore, the sandbox mechanism is only involved when executing the sandbox fork operation, avoiding deep coupling between the sandbox mechanism and the operating system kernel, thus preventing increased sandbox overhead.
[0056] like Figure 5 As shown, in this embodiment, within the semantics of the pfork system call, after the pfork system call is executed, the process's address space will undergo the following changes: a new memory mapping will be set within the new instance's memory partition, where the number of memory mappings is consistent with that within the template instance's partition. Furthermore, the memory mappings within the new instance are consistent with the memory mapping status at the corresponding offset position in the template instance, meaning they possess the same protection permissions and memory content. Figure 5 Memory segments are identified by the same color.
[0057] In the file resource fork mechanism of this embodiment, during the process fork system call, the new process instance generated by fork holds a copy of the original process's file descriptors, which can be used to access files already opened by the original process. After the sandbox fork operation is completed, the file resources held by the sandbox have a similar effect.
[0058] In this embodiment, the implementation of the pfork system call reuses the memory mapping flags and kernel functions for handling page protection errors involved in the process fork system call. When pfork is called, it first obtains the memory partition range of the template instance and the new instance, and checks whether the new instance's memory partition is valid and whether any mappings already exist within the partition. If mappings exist, they are deleted first. Then, the pfork system call scans all memory mappings within the template instance and processes them according to their type: for shared mappings and read-only private mappings, it creates the corresponding memory mapping on the new memory partition, sets the memory mapping object to the memory object corresponding to the original mapping, and updates the current reference count of the memory object; for writable private mappings, the pfork system call first updates the page table corresponding to the template memory partition to remove write permissions and sets the MAP_ENTRY_COW flag, and then, similar to the above process, creates the mapping at the specified location in the new memory partition and updates the memory object's reference count. After creating a corresponding mapping in the new partition for each mapping within the template partition, the pfork system call returns. After the pfork system call is completed, any page exceptions triggered by future access to the relevant pages will reuse the existing exception handling mechanism. The MAP_ENTRY_COW flag will be checked to determine whether to perform a page copy operation, ultimately ensuring that the two memory partitions have the same initial state and can be modified independently.
[0059] like Figure 6 As shown, in this embodiment, the file resource fork mechanism can be divided into a sandbox file resource namespace mechanism and host file resource related processing.
[0060] In this embodiment, a sandbox file resource namespace mechanism is designed to virtualize system file descriptor resources and complete the state configuration of file resources during the sandbox fork operation. Under the sandbox mechanism, all file operations of applications within the sandbox must be completed by the sandbox runtime through the host call mechanism. The sandbox runtime performs file operations on the system file descriptors implemented by the actual operating system. In this embodiment, by configuring the file resources referenced within the sandbox to be mapped to different host file resources through the namespace mechanism, file descriptor sharing between different sandboxes can be achieved. Furthermore, the sandbox file resource namespace mechanism maintains the operation data of sandbox instances on file resources by intercepting file I / O operations within the sandbox. The overall copying and sharing of sandbox instance file resources can be completed by modifying the namespace mapping. At the same time, to avoid file resource operation conflicts, the file resource fork mechanism needs to restrict the host file resource to read-only before sharing file resources between different sandbox instances, to prevent exceptions caused by different sandbox instances performing write operations on the shared file.
[0061] S2. Leveraging the similarity of application initialization processes, for memory partitioning sandbox scenarios, offline pre-initialized instances are used, and the pre-initialized instance state is reused during online invocation to skip the instance initialization process and perform instance creation operations.
[0062] S3. By integrating the operating system kernel and sandbox runtime, the sandbox creation operation is accelerated. The sandbox fork primitive is designed to create a new instance based on an existing sandbox instance.
[0063] In summary, this invention proposes a rapid creation mechanism for memory partition sandboxes in server-insensitive computing scenarios. By providing the sandbox fork primitive, it reuses the pre-initialized instance state, thereby skipping the sandbox instance cold start process, reducing sandbox cold start latency, and solving the problem of high cold start overhead in memory partition sandbox systems under server-insensitive computing.
[0064] This invention leverages the similarity of application initialization processes to skip the instance initialization process and accelerate instance creation in memory partitioning sandbox scenarios by using offline pre-initialized instances and reusing the pre-initialized instance state during online invocation.
[0065] This invention utilizes the integration of the operating system kernel and the sandbox runtime to accelerate the sandbox creation process. It designs a sandbox fork primitive, which allows for the rapid creation of new instances based on existing sandbox instances.
[0066] This invention designs a memory partitioning sandbox fork mechanism and implements the sandbox system Bootless-tfork based on the existing memory partitioning system CAP-VM. The design idea of this system is to efficiently reuse the offline pre-initialized instance state to complete the instance initialization process through the sandbox fork primitive, thereby skipping the instance initialization stage, accelerating instance creation, and reducing function cold start latency.
[0067] This invention solves the technical problems of high startup latency and low instance creation efficiency of memory partitioning sandbox systems in specific scenarios in the prior art.
[0068] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for rapid sandbox creation in server-insensitive computing scenarios, characterized in that, The method includes: S1. For server-insensitive computing scenarios, a rapid creation mechanism for memory partition sandboxes is constructed and utilized to address the high cold start latency of the memory partition sandbox system in this scenario. In the CAP-VM memory partition sandbox system, a template instance cache pool component and a Supervisor component are added for sandbox cold start operations. The cache pool component maintains the template instances corresponding to functions, enabling the template instances corresponding to functions to complete the sandbox fork operation. The Supervisor component implements the sandbox fork primitive based on the modified sandbox runtime and CheriBSD operating system kernel data. Specifically, based on the resource type, the fork mechanism in the sandbox fork primitive is designed, and the Supervisor component is used to establish a debugging relationship with the sandbox runtime process through the ptrace system call operation, thereby monitoring and adjusting the state of the sandbox runtime process. S2. Obtain and utilize application initialization process similarity information. For memory partitioning sandbox scenarios, use offline pre-initialized instances and reuse the pre-initialized instance state during online calls for instance creation operations. S3. Utilize the integrated operating system kernel and sandbox runtime to optimize the instance creation operation of the sandbox, set the sandbox fork primitive, and create a new instance based on the existing instance through the sandbox fork primitive.
2. The method for rapid sandbox creation in server-insensitive computing scenarios according to claim 1, characterized in that, S1 includes: S11. The sandbox system performs pre-maintenance operations on the template instance corresponding to the function, and performs a new instance creation operation based on the template instance corresponding to the function through the sandbox fork primitive; S12. When the pre-configured function is deployed to the system, a sandbox fork cold start optimization operation is performed based on the parameter configuration information and the template instance corresponding to the function. S13. When a function request arrives, first check if the template instance cache pool contains the template instance corresponding to the function; S14. If so, a new instance is created using the sandbox fork primitive to complete the function request; S15. If not, perform a cold start operation to trigger the offline creation of a template instance, add the offline created template instance to the template instance cache pool, and accelerate the cold start by forking the template instance when the current function is called. S16. Based on the resource type, design the fork mechanism in the sandbox fork primitive, use the Supervisor component, and establish a debugging relationship with the sandbox runtime process through the ptrace system call operation to monitor and adjust the state of the sandbox runtime process. S17. Utilize the sandbox file resource namespace mechanism to virtualize system file descriptor resources and configure the state of file resources in the sandbox fork operation.
3. The method for rapid sandbox creation in server-insensitive computing scenarios according to claim 2, characterized in that, In step S16, the call parameter combination of the ptrace system is used to adjust the process state of the sandbox runtime, implement the sandbox instance thread resource interruption mechanism and the state acquisition mechanism, and expose the sandbox instance thread resource interruption mechanism and the state acquisition mechanism to the sandbox runtime through inter-process pipe communication.
4. The method for rapid sandbox creation in server-insensitive computing scenarios according to claim 2, characterized in that, The fork mechanism in S16 includes: thread resource fork mechanism, memory resource fork mechanism and file resource fork mechanism.
5. The method for rapid sandbox creation in server-insensitive computing scenarios according to claim 4, characterized in that, In the thread resource fork mechanism, the Supervisor component is designed and utilized to change the state of sandbox threads during runtime.
6. The method for rapid sandbox creation in server-insensitive computing scenarios according to claim 4, characterized in that, The thread resource fork mechanism also includes: thread interruption mechanism and thread copying mechanism.
7. The method for rapid sandbox creation in server-insensitive computing scenarios according to claim 4, characterized in that, In the memory resource fork mechanism, a memory resource operating system partition call pfork mechanism is designed. The parameters received by the memory resource operating system partition call pfork mechanism include: template instance memory partition start address template, pre-created new instance memory partition start address addr, and memory partition length len.
8. The method for rapid sandbox creation in server-insensitive computing scenarios according to claim 4, characterized in that, In the file resource fork mechanism, during the process fork system call, a new process instance is generated by fork to hold a copy of the original process's file descriptor in order to access files already opened by the original process.
9. The method for rapid sandbox creation in server-insensitive computing scenarios according to claim 8, characterized in that, The file resource fork mechanism also includes: a sandbox file resource namespace mechanism and host file resource related processing.
10. A rapid sandbox creation system for server-insensitive computing scenarios, used to execute the rapid sandbox creation method for server-insensitive computing scenarios as described in any one of claims 1 to 9, characterized in that, The system includes: The high cold start latency tuning module is designed for server-insensitive computing scenarios. It builds and utilizes a rapid creation mechanism for memory partition sandboxes to address the high cold start latency of the memory partition sandbox system in this scenario. In the CAP-VM memory partition sandbox system, a template instance cache pool component and a Supervisor component are added for sandbox cold start operations. The cache pool component maintains the template instances corresponding to functions, enabling the template instances corresponding to the functions to complete the sandbox fork operation. The Supervisor component implements the sandbox fork primitive based on the modified sandbox runtime and CheriBSD operating system kernel data. The online invocation processing module is used to obtain and utilize application initialization process similarity information. For the memory partition sandbox scenario, it uses offline pre-initialized instances and provides instance creation operations based on the state of the pre-initialized instances reused during online invocation. The online invocation processing module is connected to the high-cold startup latency tuning module. The new instance creation module is used to optimize the instance creation operation of the sandbox by integrating the operating system kernel and sandbox runtime, setting the sandbox fork primitive, and creating a new instance based on the existing instance through the sandbox fork primitive. The new instance creation module is connected to the online call processing module.
Citation Information
Patent Citations
Customizable APP fusion method based on remote loading
CN115987959A
EBPF memory isolation method and system based on kernel mode memory isolation hardware characteristics
CN116127445A
Function calculation cold start acceleration method based on lightweight security container
CN113672343A
System and method for reducing cold start latency of serverless functions
US20200081745A1