Serverless function compiling optimization system and method based on multi-level cache

By adopting a multi-level cache structure and a rigorous verification mechanism in the Serverless environment, the problem of difficult reuse of function compilation optimization results is solved, and efficient resource utilization and the security and reliability of optimization results are achieved.

CN120045188AInactive Publication Date: 2025-05-27SHENZHEN SHUNCHI ELECTRONIC TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510120641.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-26
Publication Date
2025-05-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the Serverless environment, the optimization results of function compilation are difficult to be effectively reused, resulting in duplicate compilation optimization overhead, difficulty in sharing optimization results, and difficult to ensure cross-instance optimization results.

Method used

A multi-level cache structure is adopted, including instance-level cache, function-level cache and global-level cache, to achieve efficient management and reuse of optimization results of different granularity, and ensure the security and reliability of optimization results through version consistency checksum applicability verification.

Benefits of technology

It significantly reduces the optimization overhead of repeated compilation of function instances, improves resource utilization efficiency, realizes effective sharing of optimization results, ensures the security and reliability of optimization results, and supports dynamic updates and management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0005258847840000071
    Figure BDA0005258847840000071
  • Figure BDA0005258847840000091
    Figure BDA0005258847840000091
  • Figure BDA0005258847840000092
    Figure BDA0005258847840000092
Patent Text Reader

Abstract

The invention provides a Serverless function compilation optimization system and method based on a multi-level cache, and is used for solving the technical problem that compilation optimization results among function instances in a Serverless environment are difficult to reuse. The system adopts a three-level cache structure, and comprises an instance level cache for storing an optimization result of a current function instance, a function level cache for storing a sharing optimization result of different instances of the same function, and a global level cache for storing a cross-function multiplexing optimization result. The optimized code segment, the calling context information, the performance index data and the version identification are stored in each level of cache. The system realizes safe reuse of an optimization result through mechanisms such as cache query matching, version consistency verification and result validity verification. The method has the beneficial effects that the compilation optimization overhead of the function instance is remarkably reduced, the reuse efficiency of an optimization result is improved, the resource consumption of repeated compilation optimization is reduced, and the method is suitable for a large-scale Serverless computing environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer software optimization compilation, and particularly to a function compilation optimization system and an optimization method applied to a Serverless computing environment. Background Art

[0002] As an emerging cloud computing paradigm, Serverless computing has important applications in the cloud computing field due to its on-demand allocation and elastic scaling characteristics. In the Serverless architecture, functions are the most basic computing units, and their execution performance directly affects the efficiency of the entire system. Code compilation optimization during the function execution process plays a key role in improving the running efficiency, especially in scenarios with high concurrency and low latency requirements, where the importance of compilation optimization becomes more prominent.

[0003] Currently, the function compilation optimization in the Serverless environment mainly adopts traditional Just-In-Time (JIT) technology solutions. This solution performs compilation optimization when the function is first executed, converting the source code or intermediate code into optimized machine code. At the same time, some platforms also adopt Ahead-Of-Time (AOT) technology to perform code optimization in advance during the function deployment stage to reduce the compilation overhead during runtime. These technologies perform well in traditional application scenarios and can effectively improve the code execution efficiency.

[0004] However, these traditional compilation optimization solutions have obvious deficiencies in the Serverless environment. First, due to the short life cycle and frequent invocations of Serverless functions, the cost of traditional JIT compilation optimization often exceeds the benefits it brings. Second, although the pre-compilation solution avoids the compilation overhead during runtime, it is difficult to perform dynamic optimization for the actual running environment. More importantly, when the same or similar functions are instantiated multiple times, each instance needs to be recompiled and optimized again, resulting in a large amount of wasted computing resources due to repeated calculations.

[0005] To solve the above problems, the industry has tried to improve the optimization effect by sharing compilation caches and other means. However, these improvement solutions often only consider the sharing of optimization results at a single level and lack systematic support for different granularity optimization requirements. In addition, there are limitations in dealing with issues such as version updates and environmental differences, and the effectiveness and security of the optimization results cannot be guaranteed.

[0006] Therefore, there is an urgent need for a compilation optimization system that can adapt to the characteristics of the Serverless environment, support the reuse of multi-level optimization results, and ensure the optimization effect at the same time. This system should be able to effectively balance the optimization cost and benefits, improve the resource utilization efficiency, and ensure the reliability and security of the optimization results. Summary of the Invention

[0007] The objective of the present invention is to solve the problem that it is difficult to effectively reuse the function compilation optimization results in the Serverless environment, including specific problems such as repeated compilation optimization overhead, difficult sharing of optimization results, and difficult guarantee of cross-instance optimization effects. In addition, the present invention also aims to provide a reliable optimization result verification mechanism to ensure the security and effectiveness of the reuse process.

[0008] To achieve the above objective, the present invention provides a Serverless function compilation optimization system and method based on a multi-level cache. The system adopts a hierarchical cache structure, including an instance-level cache, a function-level cache, and a global-level cache, to achieve efficient management and reuse of optimization results at different granularities.

[0009] Specifically, the instance-level cache of the present invention is used to store the optimization results of the current function instance, including the optimized code segment, call context information, performance metric data, and version identifier, to achieve fast access to optimization results within a single instance.

[0010] Furthermore, the function-level cache is responsible for storing the optimization results shared among different instances of the same function. Through version consistency verification and applicability verification, it ensures that the optimization results can be safely reused among different instances.

[0011] Preferably, the call context information specifically includes function call parameter types, execution environment configuration information, resource usage limits, and caller identity identifiers, which are used to ensure the exact matching and secure application of optimization results.

[0012] Preferably, the global-level cache stores general optimization results that can be reused across functions. These results have been strictly screened and verified, and have wide applicability and stable performance improvement effects.

[0013] Optionally, the cache management module of the present invention is responsible for performing addition, deletion, update operations on cache entries, conducting version consistency verification, controlling the capacity of each level of cache, and verifying the validity of cache entries.

[0014] In one embodiment, the present invention further includes a performance monitoring module for collecting the execution performance data of optimization results, counting the cache hit rate, recording resource usage, and providing a basis for cache management decisions.

[0015] In some embodiments, the system conducts multi-dimensional verification on the optimization results in the cache through a reuse verification module, including version consistency verification, execution environment compatibility check, and performance benefit evaluation.

[0016] In addition, the cache update mechanism of the present invention supports dynamically adjusting the cache content according to access frequency and performance benefits, and regularly cleaning up expired or low-value cache entries.

[0017] In a preferred embodiment, the system adopts a hierarchical query strategy. First, it searches for the matching optimization results in the instance-level cache. If not found, it then queries the function-level cache and the global-level cache in sequence to ensure the optimal query efficiency.

[0018] By adopting the above solution, the present invention has the following beneficial effects: 1. Significantly reduces the repeated compilation and optimization overhead of function instances and improves the resource utilization efficiency; 2. Achieves the effective sharing of optimization results at different granularities and expands the scope of benefit of the optimization effect; 3. Balances the relationship between access speed and sharing scope through a multi-level cache structure; 4. Establishes a perfect verification mechanism to ensure the security and reliability of the reuse of optimization results; 5. Supports dynamic update and management, ensuring the maintainability and scalability of the system.

[0019] In summary, through the innovative multi-level cache structure and strict verification mechanism, the present invention effectively solves the efficiency and reliability problems of function compilation and optimization in the Serverless environment and has important practical value. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0021] Figure 1 It is the overall architecture diagram of the system. This diagram shows the core components of the system and their interaction relationships through a three-layer structure (application layer, management layer, cache layer), and particularly describes in detail the internal composition of the three-level cache (instance cache, function cache, global cache).

[0022] Figure 2 It is the organizational structure diagram of the cache content. It shows the data structure design of the cache entries in the form of a class diagram, including the detailed attributes and association relationships of core components such as code segments, context information, performance metrics, and version identifiers.

[0023] Figure 3 It is the cache management flow chart. It shows the state transitions and processing logics of the three main processes of cache management, version control, and capacity control through a state diagram, including the complete processes such as update, verification, and failure handling.

[0024] Figure 4It is a query matching flowchart. The query process of the multi-level cache is shown through the flowchart, including key links such as LSH matching, Bloom filter check, and performance prediction, clearly demonstrating the complete path of query decision-making.

[0025] Figure 5 It is a reuse verification flowchart. The verification links such as version compatibility check, environment check, performance analysis, and decision-making, as well as the degradation handling mechanism after failure, are described using a state diagram.

[0026] Figure 6 It is a performance monitoring system diagram. The composition and data flow relationship of five main modules, namely data collection, metric processing, resource monitoring, alarm system, and performance analysis, are shown through a component diagram.

[0027] Figure 7 It is a cache update optimization diagram. Four key processes, namely update evaluation, capacity management, atomic update, and batch processing, are described using a state diagram, demonstrating the complete life cycle and optimization mechanism of cache update. Detailed implementation manners

[0028] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0029] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the accompanying drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention.

[0030] Embodiment 1: Basic system architecture

[0031] Refer to Figure 1 As shown, the Serverless function compilation optimization system based on multi-level cache adopts a layered architecture design, including three main layers: a cache layer, a management layer, and an application layer. Among them, the cache layer implements the core multi-level cache structure, the management layer provides cache management and optimization control functions, and the application layer is responsible for interacting with the Serverless running environment.

[0032] The cache layer adopts a three-level cache structure, including the instance-level cache, function-level cache, and global-level cache. The instance-level cache is at the bottom layer, directly associated with specific function instances, and is used to store the optimization results of the current instance. The function-level cache is in the middle layer and is used to store the optimization results that can be shared among different instances of the same function. The global-level cache is at the top layer and stores the general optimization results that can be reused by multiple different functions. This hierarchical cache structure design fully considers the balance between the sharing scope of optimization results and access efficiency.

[0033] Each level of the cache uses a key-value storage structure. The key is composed of the characteristic information of the optimization content, including the code segment identifier, compilation parameter characteristic values, and environment identifier, etc., and generates a unique characteristic hash value through the SHA-256 algorithm. The value part stores the actual optimization results, including the optimized code segment, call context information, performance metric data, and version identifier. The code segment is stored in binary format and the storage space occupancy is reduced through a compression algorithm.

[0034] The management layer includes three core components: the Cache Manager, Optimization Controller, and Monitor. The Cache Manager is responsible for coordinating the data flow of the three-level cache and implementing operations such as adding, deleting, modifying, and querying cache entries. The Optimization Controller is responsible for formulating optimization strategies and deciding when to perform optimization and which optimization level to use. The Monitor continuously collects system operation data to provide a basis for optimization decisions.

[0035] The application layer is integrated with the Serverless runtime environment through a standardized interface, receives function call requests, and returns the optimized execution results. This layer implements a lightweight adapter to handle the differences of different Serverless platforms and ensure the universality of the system.

[0036] The data flow process of the system is as follows: When a function call request is received, first construct a cache query key according to the function characteristic information, and search for matching optimization results in each level of the cache in the order of instance-level, function-level, and global-level. If a qualified optimization result is found, directly apply this result; if not found, real-time optimization is required, and the optimization result is stored in the corresponding level of the cache.

[0037] In actual deployment, the three - level cache can select different storage media according to specific requirements. Instance - level caches usually use memory storage to ensure the fastest access speed; function - level caches can use distributed cache systems such as Redis; global - level caches can adopt persistent storage such as distributed file systems.

[0038] In addition, the system also implements a cache consistency protection mechanism. When the function code or the running environment changes, the relevant cache entries will be automatically marked as invalid. The system ensures the correctness of the cache results through a dual - verification mechanism of version numbers and checksums.

[0039] The innovation of this architecture design lies in that through the multi - level cache structure, it realizes the differential storage and reuse of optimization results, which not only ensures the access efficiency but also improves the resource utilization rate. The scalability of the system is reflected in: the storage medium can be flexibly selected according to actual needs, the optimization strategy can be dynamically adjusted according to performance requirements, and the overall architecture supports horizontal expansion.

[0040] The system architecture in this embodiment can adapt to Serverless computing environments of different scales and can be customized according to actual needs. For example, the capacity ratio of each level of cache can be dynamically adjusted according to the load situation, or a dedicated cache layer can be added for specific types of functions.

[0041] Embodiment 2: Cache Content Organization Scheme

[0042] Refer to Figure 2 As shown, this embodiment details the organization method and specific implementation method of the stored content in the multi - level cache. This scheme realizes the efficient storage and rapid retrieval of optimization results through a structured data organization design.

[0043] The cache content is organized using a unified data structure. Each cache entry contains four main parts: the optimized code segment (Optimized Code), call context information (Context Information), performance metric data (Performance Metrics), and version identifier (Version Identifier).

[0044] The optimized code segment is stored in a special binary format, and the format definition is as follows: CodeSegment={Header,Instructions,RelocationTable,SymbolTable}(1)

[0045] Among them, the Header contains basic information of the code segment, such as code size, entry point location, etc.; Instructions stores the actual machine code instructions; the RelocationTable records the addresses that need to be relocated; the SymbolTable saves symbol reference information. The code segment is stored using a differential compression algorithm, reducing storage space occupancy by only recording the differences from the baseline version.

[0046] The call context information includes four key components: function call parameter types (Parameter Types), execution environment configuration information (Environment Configuration), resource usage limits (Resource Limits), and caller identity (Caller Identity). The parameter type information is represented using type signature strings, supporting the description of basic types and composite types. The execution environment configuration information records the characteristics of the runtime environment, including the operating system type, CPU architecture, memory model, etc. The resource usage limits define the resource constraints for function execution, including the maximum memory usage, CPU time limit, etc. The caller identity is used for access control and security verification.

[0047] The performance metric data is stored in a time series format, recording the historical execution performance of the optimization results. The calculation formula for the performance metric is as follows: PerformanceScore = α × ExecutionTime + β × ResourceUsage + γ × HitRate(2)

[0048] Among them, α, β, and γ are weight coefficients, ExecutionTime is the average execution time, ResourceUsage is the resource usage rate, and HitRate is the cache hit rate. These metrics are collected through continuous monitoring and are used to evaluate the optimization effect and guide cache management decisions.

[0049] The version identifier adopts a multi-level version control mechanism and contains the following information: VersionID = Hash(CodeHash || ContextHash || ConfigHash)(3)

[0050] Among them, CodeHash is the hash value of the source code, ContextHash is the hash value of the context information, and ConfigHash is the hash value of the configuration information. Through this combined hash method, it is ensured that the version identifier can uniquely identify a specific optimization result.

[0051] In the actual storage implementation, the three - level cache adopts different storage strategies. The instance - level cache uses memory - mapped files for storage, achieving fast read - write access; the function - level cache adopts a key - value storage system, supporting distributed access; the global - level cache uses a column - store format, optimizing the storage and query efficiency of large - scale data.

[0052] The innovative organization scheme of cache content introduces a differential storage mechanism. By recording the differences between optimization results, it significantly reduces the storage space occupancy. Meanwhile, the multi - dimensional context information design ensures the exact matching and secure application of optimization results. The design of the version - control mechanism guarantees the consistency and reliability of cache content.

[0053] The cache content organization scheme of this embodiment can be extended according to actual requirements. For example, new performance - metric dimensions can be added, or custom context - information fields can be added. The storage format can also be optimized and adjusted according to the characteristics of different storage media.

[0054] Embodiment 3: Cache Management Mechanism

[0055] Refer to Figure 3 As shown, this embodiment details the management mechanism of the multi - level cache, including the specific implementation methods of core functions such as adding, deleting, updating cache entries, version - consistency verification, capacity control, and validity verification. This mechanism is built on the system architecture of Embodiment 1 and uses the cache - content format defined in Embodiment 2.

[0056] The operations of adding, deleting, and updating cache entries are implemented using a double - buffer mechanism. When the cache content needs to be updated, the system first prepares a new cache entry in the spare buffer. After completion, it switches the primary and spare buffers through an atomic operation to ensure the atomicity and consistency of the update process. The state transition of the update operation can be expressed as: State new =UpdateFunction(State current ,Δ change )(4)

[0057] Where State current represents the current state, Δ change represents the state change amount, and UpdateFunction is the state - transition function. The read - write lock mechanism is used to protect the state - transition process to avoid concurrent - access conflicts.

[0058] The version - consistency verification adopts a multi - level verification mechanism. First, a quick comparison is made through the version number. The generation rule of the version number is as follows: Version=Hash(CodeVersion||EnvironmentVersion||ConfigVersion)(5)

[0059] Among them, CodeVersion is the code version number, EnvironmentVersion is the environment version number, and ConfigVersion is the configuration version number. When the version numbers match, the integrity of the cache item is further verified by the content checksum (Checksum). When the verification fails, the automatic cleaning mechanism is triggered to remove the inconsistent cache items.

[0060] The capacity control policy adopts an adaptive multi-level eviction algorithm. Each level of cache maintains a weight calculation formula:

[0061] Among them, AccessFrequency is the access frequency, PerformanceGain is the performance improvement effect, Size is the occupied space, and Age is the cache item age. When the cache capacity reaches the threshold, the system preferentially evicts the cache items with lower weights. The threshold is automatically adjusted by dynamically monitoring the system load.

[0062] The verification of cache item validity includes three dimensions: timeliness verification, environment compatibility verification, and performance validity verification. Timeliness verification ensures that the cache item has not exceeded the maximum validity period; environment compatibility verification checks whether the running environment meets the requirements of the cache item; performance validity verification evaluates whether the cache item continuously provides the expected performance improvement. The decision function of the verification process is: Valid = TimeValid ∧ EnvironmentValid ∧ PerformanceValid(7)

[0063] The exception handling mechanism adopts a multi-level degradation strategy. When a cache exception is detected, the system first attempts to repair the abnormal cache item; if the repair fails, the item is marked as invalid and re-optimization is triggered; if the problem persists, the cache function at the corresponding level is temporarily disabled. The exception recovery process is controlled by a state machine to ensure system stability.

[0064] The cache consistency maintenance adopts an event-based notification mechanism. When code updates, environment changes, or configuration modifications are detected, the system broadcasts invalidation notifications to all cache nodes through a message queue. The notification message includes the change type and the affected scope, and the receiving node performs the corresponding cache update operation according to this information.

[0065] The innovation of this embodiment lies in implementing an adaptive multi-level cache management mechanism, ensuring the reliability of cached content through precise version control and validity verification. Meanwhile, the dynamic capacity control strategy improves resource utilization efficiency. This mechanism can be extended according to actual needs, such as adding new verification dimensions or adjusting the weight calculation method of the eviction policy. In addition, the design of the exception handling mechanism provides the system with strong fault tolerance, ensuring stable operation under various abnormal conditions.

[0066] Embodiment 4: Query Matching Mechanism

[0067] Refer to Figure 4 As shown, this embodiment details the query matching mechanism of the multi-level cache. This mechanism is based on the system architecture of Embodiment 1, uses the cache content format defined in Embodiment 2, and works in coordination with the management mechanism of Embodiment 3.

[0068] The query matching process adopts a hierarchical search strategy, starting from the finest-grained instance-level cache and searching upward level by level. The feature vector of the query request is defined as follows: Query = {CodeID, Parameters, Environment, Configuration}(8)

[0069] Where CodeID is the code identifier, Parameters is the function parameter feature, Environment is the execution environment information, and Configuration is the configuration parameter. The system constructs a query key according to the query feature vector: QueryKey = Hash(Query) = Hash(CodeID || Parameters || Environment || Configuration) (9)

[0070] The instance-level cache query adopts a direct mapping method, and the query key is mapped to the cache slot through a hash function: Slot instance = QueryKey mod CacheSize instance (10)

[0071] When the instance-level cache misses, the system constructs a function-level query key, which ignores some instance-related parameters: FunctionKey = Hash(CodeID || Parameters || Configuration)(11)

[0072] The function-level cache uses a Bloom filter for fast searching, and the configuration parameters of the filter are:

[0073] Where m is the size of the bit array, n is the expected number of cache entries, and p is the expected false positive rate. The Bloom filter calculates the mapping positions of the query key through multiple hash functions to improve the query efficiency.

[0074] When the function-level cache also misses, the system accesses the global-level cache. The global-level query uses the Locality-Sensitive Hashing (LSH) algorithm to match by calculating the similarity between the query feature vector and the cache entry:

[0075] Where w i is the feature weight, and sim i is the similarity function for each dimension. When the similarity exceeds the preset threshold, it is determined that the match is successful.

[0076] The selection of the cache level for the query result is based on the performance benefit evaluation:

[0077] Where Frequency local is the local access frequency, Frequency global is the global access frequency, and θ 1 and θ 2 are dynamically adjusted thresholds.

[0078] The query performance optimization adopts a prefetching mechanism. The system analyzes the historical query patterns, predicts the possible subsequent queries, and preloads the relevant cache entries into a higher-level cache in advance. The prediction model uses conditional probability:

[0079] The innovation of this embodiment lies in designing an adaptive multi-level query strategy. Through feature matching at different granularities and an intelligent level selection mechanism, it achieves the optimal balance between query efficiency and matching accuracy. This mechanism can be extended according to actual needs, such as adding new feature dimensions or adjusting the similarity calculation method. In addition, the design of the prefetching mechanism provides room for optimizing query performance, enabling the system to better adapt to different access patterns.

[0080] Example 5: Reuse Verification Process

[0081] Referring to Figure 5 as shown, this embodiment details the verification process for reusing the optimization results. This process is based on the foregoing embodiments and ensures the security and effectiveness of the cache optimization results. The verification process includes three core links: version consistency verification, execution environment compatibility check, and performance benefit evaluation.

[0082] The version consistency verification adopts a multi-dimensional version comparison mechanism. The version information vector is defined as follows: Version = {CodeVersion, EnvironmentVersion, DependencyVersion, ConfigVersion} (16)

[0083] The system evaluates the version consistency by calculating the similarity of the version vectors:

[0084] where Compatible i is the compatibility check function for each dimension, and the return value is 0 or 1. The version compatibility check uses semantic version number comparison, supporting fine-grained comparison of the major version number, minor version number, and revision number.

[0085] The execution environment compatibility check is based on the environment feature matrix:

[0086] The environment compatibility score is obtained through weighted calculation:

[0087] where w ij is the feature weight, and Match ij is the feature matching function. The system determines whether the compatibility requirements are met according to the environment score: EnvCompatible = (EnvScore ≥ θ env )(20)

[0088] The performance benefit evaluation uses a statistical model for prediction. First, construct the performance feature vector: Performance = {ExecutionTime, ResourceUsage, ResponseLatency}(21)

[0089] Establish a benefit prediction model through historical performance data:

[0090] where Performance predicted is predicted through time series analysis: Performance predicted = ARIMA(HistoricalData, Parameters)(23)

[0091] The verification decision comprehensively considers the above three aspects, and the final verification result is determined by the decision function: Valid = f(VersionCompatibility, EnvCompatible, Gain > θ gain )(24)

[0092] When the verification fails, the system starts the degradation processing flow:

[0093] The verification result caching mechanism uses a Bloom filter to record the verified configuration combinations, reducing the overhead of repeated verification:

[0094] The innovation of this embodiment lies in establishing a comprehensive reuse verification system. Through multi-dimensional compatibility checks and performance evaluations, the reliability of the reuse of optimization results is ensured. This verification process can be extended according to actual needs, such as adding new verification dimensions or adjusting verification strategies. In addition, the design of the degradation processing mechanism provides the system with the ability to gracefully degrade in case of verification failure, ensuring the continuity of the service.

[0095] Example 6: Performance Monitoring System

[0096] Referring to Figure 6 As shown, this embodiment details the implementation scheme of the performance monitoring system. This system works in coordination with the foregoing embodiments to provide data support for cache management and optimization decisions. The performance monitoring system includes four core functional modules: data collection, metric calculation, resource monitoring, and performance analysis.

[0097] Performance data collection uses distributed tracing technology to implant probes at key execution points. The definition of the tracing points is as follows: TracePoint = {Timestamp, Location, MetricType, Value, Context}(27)

[0098] The system dynamically adjusts the sampling rate through a sampling control algorithm:

[0099] where TargetRate is the target sampling rate, BaselineLoad is the baseline load, CurrentLoad is the current load, and MaxRate is the maximum sampling rate. The sampled data is temporarily stored in a circular buffer:

[0100] Execution time statistics are implemented using a hierarchical timer, supporting accurate timing at the function level and code block level:

[0101] Among them, OverheadTime is the overhead time of the monitoring system itself, which is obtained through benchmark testing and compensated in the calculation.

[0102] Resource usage monitoring is implemented based on event counters, collecting resource metrics such as CPU, memory, IO, etc.: ResourceUsage = {CPU util , Memory used , IO throughput , Network traffic}(31)

[0103] The system calculates the resource utilization rate through a sliding window:

[0104] The performance metric calculation uses an online algorithm and supports incremental updates: Metric new = Metric old + α(Sample new - Metric old )(33)

[0105] Among them, α is the smoothing factor, which is adjusted through an adaptive algorithm:

[0106] The performance data is stored in a time series database, and the data model is designed as follows: DataPoint = {Timestamp, Tags, Fields, Retention}(35)

[0107] The system calculates the performance statistics through an aggregation function: Statistics = {Mean, Percentile 95 , Variance, Trend}(36)

[0108] The alarm mechanism is based on dynamic threshold detection, and the threshold calculation formula is: Threshold = μ + kσ(37)

[0109] Among them, μ is the metric mean, σ is the standard deviation, and k is a configurable sensitivity coefficient.

[0110] The innovation of this embodiment lies in achieving a low-overhead and high-precision performance monitoring mechanism. Through adaptive sampling and incremental calculation, the monitoring efficiency is ensured, and at the same time, rich performance metrics are provided to support decision optimization. The system can be extended according to actual needs, such as adding new monitoring metrics or custom statistical algorithms. In addition, the design of the alarm mechanism provides the ability to detect and handle performance problems in a timely manner, ensuring the reliable operation of the system.

[0111] Example 7: Cache Update Optimization

[0112] Refer to Figure 7 As shown, this embodiment details the implementation scheme of the cache update optimization mechanism. Based on the infrastructure of the foregoing embodiment and combined with performance monitoring data, it realizes the intelligent update and optimization of cache content.

[0113] The cache update policy is based on a multi-dimensional scoring model, and the update score calculation formula is as follows: UpdateScore = w 1 ×FrequencyScore + w 2 ×GainScore + w 3 ×CostScore(38)

[0114] The access frequency score is implemented using a decay counter:

[0115] Where λ is the decay coefficient, which is dynamically adjusted through an adaptive algorithm:

[0116] The performance gain score is calculated based on historical execution data:

[0117] Where Stability represents the stability of performance improvement:

[0118] The update cost score takes into account resource consumption and impact scope:

[0119] When the cache capacity reaches the threshold, the cleaning policy is based on value density sorting:

[0120] The system maintains a priority queue to store items to be cleaned: PriorityQueue = {Entry i |ValueDensity i<Threshold}(45)

[0121] The detection of expired cache items adopts a multi-level timeout mechanism:

[0122] The atomicity of the update operation is achieved through version control: Version new = Version old + 1, if CAS(Version old , Version new )(47)

[0123] The system optimizes the update performance through a batch processing mechanism:

[0124] The update conflict resolution adopts a priority arbitration mechanism:

[0125] The innovation of this embodiment lies in implementing an intelligent update mechanism based on multi-dimensional scoring. Through precise value evaluation and resource balancing, the efficiency and accuracy of cache updates are improved. This mechanism can be extended according to actual needs, such as adding new scoring dimensions or adjusting the cleaning strategy. In addition, the design of the atomicity guarantee mechanism ensures data consistency in concurrent update scenarios and improves the reliability of the system.

Claims

1. A Serverless function compilation optimization system based on multi-level cache, characterized in that: include: (a) A multi-level cache structure, the multi-level cache structure comprising: (b) Instance-level cache, used to store the optimization results of the current function instance; (c) Function-level cache, used to store optimization results shared between different instances of the same function; (d) A global level cache, used to store common optimization results that can be reused across functions; (e) The contents stored in each level of cache include optimized code segments, call context information, performance indicator data, and version identification.

2. The system according to claim 1, characterized in that It also includes a cache management module, which is used to: (a) Perform cache item addition, deletion and update operations; (b) Perform version consistency check; (c) Control the cache capacity at each level; (d) Verify the validity of the cache item.

3. The system according to claim 1, characterized in that The call context information includes: (a) Function call parameter types; (b) execution environment configuration information; (c) Resource usage restrictions; (d) Caller identity.

4. The system according to claim 1, characterized in that It also includes a multiplexing verification module, which is used to: (a) Verify the version consistency of cache optimization results; (b) Check the applicable conditions of the optimization results; (c) Evaluate the performance benefits of reuse.

5. The system according to claim 1, characterized in that It also includes a performance monitoring module, which is used to: (a) Collecting the execution performance data of the optimization results; (b) Statistical cache hit rate; (c) Record resource usage.

6. A Serverless function compilation optimization method based on multi-level cache, characterized in that: The following steps are involved: (a) querying a matched optimization result in a multi-level cache structure, wherein the multi-level cache structure includes an instance-level cache, a function-level cache, and a global-level cache; (b) Verify the version consistency and validity of the queried optimization results; (c) Apply the verified optimization results and monitor the execution performance; (d) Update cache content based on execution performance data.

7. The method according to claim 6, characterized in that The query matching step comprises: (a) First query the instance-level cache; (b) If the instance-level cache misses, query the function-level cache; (c) If the function-level cache misses, query the global-level cache.

8. The method according to claim 6, characterized in that Also includes a cache update step: (a) When a new optimization result is detected, it is stored in the cache of the corresponding level; (b) When the cache capacity reaches a threshold, low-value cache items are removed based on access frequency and performance benefits; (c) Regularly check and clean up expired cache items.

9. The method according to claim 6, characterized in that The verification step includes: (a) Check whether the version number of the optimization result matches the current environment; (b) Verify whether the execution conditions of the optimization results are met; (c) Evaluate the potential performance gains of reusing the optimization results.

10. The method according to claim 6, characterized in that Also includes performance monitoring steps: (a) Record the actual execution time of the optimization results; (b) Statistics on memory and CPU resource usage; (c) The performance improvement ratio brought by computing optimization.

Citation Information

Cited By

  • Cache optimization method and device for tenant configuration modification, equipment and storage medium

    CN121277845A