Fast application multi-ad slot dynamic pre-rendering and high eCPM exposure revenue optimization method
By constructing a pre-rendered task graph and recycling set, the ad allocation and pre-rendering are optimized, solving the resource coordination problem under the constraints of terminal memory and the time variation of ad position viewport, thereby improving ad exposure revenue and resource utilization efficiency.
Patent Information
- Application Number
- CN202611436463.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-16
- Publication Date
- 2026-11-27
AI Technical Summary
Given the limited terminal memory and the varying time it takes for ad slots to enter the viewport, how can we coordinate the adjustment of ad allocation with the pre-rendering of multiple ad slots to ensure that ad instance replacement adapts to the exposure sequence and the actual resource constraints of the terminal?
By constructing a pre-rendered task graph, a recycling set covering all references to cached items to be released is generated. Combined with actual memory release confirmation, an alternative scheme that increases expected exposure revenue is selected, and the allocation is switched when candidate ad instances are ready, avoiding resource waste and conflicts.
It effectively coordinates ad allocation and pre-rendering, reduces resource consumption, increases ad exposure revenue, and avoids resource conflicts and unnecessary pre-rendering tasks caused by memory changes.
Smart Images

Figure CN123185409A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ad allocation and pre-rendering control technology in Internet advertising services, and in particular to a method for dynamic pre-rendering and exposure revenue optimization of multiple ad slots in quick apps. Background Technology
[0002] In internet advertising services, mobile applications can pre-fetch ads and store them in the terminal cache, then invoke the corresponding ad content when the ad slots are ready to be displayed. For quick apps with multiple ad slots on a page, the time it takes for an ad slot to enter the viewport varies with page scrolling and user actions. Furthermore, the ad content needs to undergo rendering processing from acquisition to the formation of a hookable ad instance. Therefore, the ad allocation and display process is affected not only by the ad's validity period and display opportunities but also by the terminal's processing time and available memory.
[0003] US Patent Document No. US10410252B2, entitled "Energy-efficient content serving," and published on September 10, 2019, discloses a client-oriented content prefetching allocation scheme. According to the specification in that document... Figures 1 to 3 The corresponding description describes a process where mobile clients pre-fetch ads from an ad server and store them in an ad cache. A prediction component is used to predict the number of ad slots that may appear in subsequent time periods and the probability of each ad slot being available, based on application usage. The ad server allocates ads based on their expiration dates and display probabilities, and can adjust the allocation according to the ad status reported by the clients. The document also describes a method for distributing ads to multiple clients based on display probabilities.
[0004] The aforementioned document describes the ad pre-fetching and allocation adjustment process, but the fact that ad content has been cached does not mean that the corresponding ad instance has been rendered and is ready for display. In multi-ad slot scenarios with limited terminal memory, the pre-rendering of candidate ads may compete with other ad tasks for available memory, and the actual time an ad slot enters the viewport may be earlier than the ready time of the candidate ad instance. If existing caches are removed or related tasks are canceled to initiate the pre-rendering of candidate ads, these operations may also change the availability status of other ad instances and the completion time of subsequent tasks. In this case, even if the candidate ad instance is not used for the current exposure of the target ad slot, the resource adjustments that have already occurred may still affect the pre-rendering execution of other ad slots.
[0005] The ad status feedback in the aforementioned literature provides a basis for allocation adjustments, but ad expiration deadlines, expected display opportunities, and pre-fetched ad status cannot be directly equated with the actual memory usage and ad instance readiness status during the terminal pre-rendering process. Under the conditions of resource contention and exposure timing changes, whether the ad allocation results can be executed also depends on the changes in available memory and related task status during ad instance replacement.
[0006] Therefore, under the conditions of limited terminal memory and varying ad slot entry times into the viewport, how to coordinate ad allocation adjustments and multi-ad slot pre-rendering execution to adapt ad instance replacement to the exposure sequence of each ad slot and the actual resource constraints of the terminal is a technical problem that needs to be solved. Summary of the Invention
[0007] To overcome the aforementioned technical deficiencies, the present invention aims to provide a method for dynamic pre-rendering and exposure revenue optimization of multiple ad slots in fast applications. This method involves establishing a pre-rendering task graph for candidate ads within an internet advertising service, constructing a recycling set that covers all references to be released cached items, with reference deregistration independent of candidate ad instance readiness and retained instance reference deregistration. The impact of recycling and task waiting changes on relevant ad slots is incorporated into the expected exposure revenue projection. In the projection branch where the target ad slot first enters the viewport, the projected reference deregistration and instance cancellation states are retained, and a replacement scheme that increases the total expected exposure revenue relative to maintaining the current allocation is selected. When the retained instances continuously occupy memory and the updated available memory, confirmed by actual memory release, meets the peak increase in memory, memory is reserved once and pre-rendering is initiated. During execution, memory is allocated from the updated set. The system compares the expected exposure benefits of continuing and stopping the replacement process. If the expected exposure benefits of continuing the replacement are not greater than those of stopping the replacement, the replacement is canceled and the subsequent stages are stopped. Simultaneously, if the replacement is not canceled and the candidate ad instance is ready first, the system switches the allocation, releases the reference of the reserved instance, and attaches the still valid candidate ad instance when the target ad position enters the viewport. If the target ad position enters the viewport first, the still valid reserved instance is attached, the stage that has not been started is canceled, and the memory of in-transit tasks and unconfirmed release cache items is continuously calculated. This solves the technical problem that it is difficult to coordinate the adjustment of ad allocation and the pre-rendering execution of multiple ad positions to adapt to the exposure sequence and actual resource constraints when the terminal memory is limited and the time when the ad position enters the viewport changes.
[0008] This invention discloses a method for dynamic pre-rendering and exposure revenue optimization of multiple ad slots in quick apps, applied to internet advertising services, and executed by the terminal running the quick app, including:
[0009] Obtain the expected exposure window of multiple ad slots, the validity period of matching ads, and the estimated revenue per thousand impressions; determine the candidate ads and ready-to-retain instances for the target ad slots; and build a pre-rendering task graph for the candidate ads.
[0010] Determine the peak memory usage for pre-rendering and generate a replacement scheme that includes candidate ads and a recycling set; the recycling set consists of references and covers all references to cache items to be released, and the release of each reference is independent of the release of candidate ad instances and the release of references to reserved instances;
[0011] For target ad placements and ad placements affected by changes in recycling or task waiting, the expected exposure revenue of maintaining the current allocation and implementing the replacement plan is deduced based on the estimated revenue per thousand impressions; in the deduction branch where the target ad placement first enters the viewport, the deduced reference removal and instance cancellation status are retained, the expected exposure revenue of other affected ad placements is calculated, and the replacement plan with the increased total expected exposure revenue is selected.
[0012] Perform recycling, confirm the updated available memory based on the actual memory release, and reserve the corresponding memory and start pre-rendering once when the instance continues to occupy memory and the available memory meets the peak of the new memory.
[0013] From the start of recycling to the end of replacement, the current allocation is updated based on the reference release, instance cancellation and actual memory release that have occurred. The expected exposure benefits of continuing replacement and stopping replacement are compared based on the updated allocation. If the former is not greater than the latter, the replacement is canceled and the subsequent stages are stopped.
[0014] When a candidate ad instance that has not been revoked is ready, the allocation is switched and the reserved instance reference is released. When the target ad position enters the viewport, the still valid candidate ad instance is attached. When the target ad position enters the viewport first, the still valid reserved instance is attached, the unstarted phase is revoked, and the memory of in-transit tasks and unconfirmed released cache items is continuously calculated.
[0015] Preferably, the generation of the recycling set includes:
[0016] The cache items are determined by the material content identifier and output specifications. The instance reference held by the ad instance, the read reference held during the execution phase, and the cache reference are recorded for the cache items.
[0017] Starting from the instance reference of the ad instance to be recycled, find other references of the cache item corresponding to the instance reference, and add the references that can be released by canceling the corresponding ad instance, ending the reading phase, or releasing the cache holding relationship to the recycling set until all references of the corresponding cache item are covered;
[0018] When a corresponding cached item has a reference to a retained instance, or the release of any reference depends on the completion of the pre-rendering of the candidate ad, the corresponding cached item will be excluded from the cached items to be released.
[0019] Based on the cache item identifier, duplicate cache items to be released are deduplicated, and the amount of freeable memory corresponding to the reclaimed set is determined.
[0020] Preferably, the determination of the peak value of the new memory includes:
[0021] The pre-rendered task graph is divided into the material acquisition stage, the decoding stage, and the layout stage, and the dependencies, execution memory requirements, and output memory requirements of each stage are recorded.
[0022] Set existing cached items that can continue to be used by candidate ads as fixed-occupancy items, and keep references to fixed-occupancy items until the end of the corresponding usage phase;
[0023] Based on the dependencies and the parallel relationships allowed by the pre-rendering execution end, determine the combination of stages that can be executed simultaneously, merge the same memory objects passed across stages according to the memory object identifier, calculate the additional memory requirement of each stage combination relative to the current usage, and determine the maximum value among them as the peak of the additional memory.
[0024] The available memory is obtained by subtracting the current actual usage and the amount of memory reserved but not yet allocated from the memory capacity used for ad pre-rendering. Fixed usage items and memory occupied by reserved instances are included in the current actual usage.
[0025] Preferably, the deduction of expected exposure revenue includes:
[0026] Record the allocation reference between the ad slot and the ad instance, as well as the display reference during the period when the ad instance is attached to the ad slot in the viewport;
[0027] The process of an ad placement being continuously within the viewport is defined as an exposure opportunity. The order of ad instance readiness and ad placement entering the viewport is determined based on the expected exposure window and the pre-rendered task map.
[0028] For branches where candidate ad instances are ready first, update the reference status in the order of first transferring the allocation reference of the target ad slot to the candidate ad instance, and then releasing the allocation reference of the reserved instance.
[0029] For branches where the target ad slot enters the viewport first, a display reference is established to preserve the instance. The display reference is maintained until the target ad slot exits the viewport, and the subsequent pre-rendering phase of the candidate ad is stopped.
[0030] Based on the attachable status of the ad instance in the corresponding branch, the validity period of the corresponding ad, and the probability of meeting the preset effective exposure conditions after attaching, determine the probability of the ad instance forming effective exposure. Multiply the probability of forming effective exposure by the estimated revenue per thousand exposures of the corresponding ad and divide by one thousand to obtain the expected exposure revenue of the corresponding exposure opportunity.
[0031] For the same exposure opportunity, select a projection branch according to the sequence of events, determine the expected exposure revenue of the exposure opportunity based on the displayed instances in the selected projection branch, and summarize the expected exposure revenue of each exposure opportunity.
[0032] Preferably, the deduction of expected exposure revenue further includes:
[0033] Obtain samples of page scrolling trajectory and samples of pre-rendering time consumption associated with terminal resource configuration records;
[0034] In one simulation, the same page scroll trajectory sample is applied to each ad placement under the same page layout version to determine the time when each ad placement enters and exits the viewport, and the same pre-rendering stage time sample is used to maintain the current allocation and execute the replacement scheme.
[0035] Based on the reference removal time and memory availability time in each scheme, update the startup time and ad instance readiness time of the subsequent stages respectively;
[0036] The expected exposure gains obtained from each simulation are averaged, and the average expected exposure gains are compared with those of maintaining the current allocation and implementing the replacement plan.
[0037] Preferably, the generation and selection of replacement schemes includes:
[0038] From the ads that match the target ad placement, select candidate ads whose estimated revenue per thousand impressions is greater than the estimated revenue per thousand impressions of the ad corresponding to the retained instance, and whose validity period overlaps with the expected exposure window.
[0039] For each candidate ad, multiple recycling sets are generated that cover all references of the cache items to be released. Each candidate ad is combined with its corresponding recycling set, and combinations that are less than the peak value of the corresponding new memory are excluded.
[0040] The remaining target ad slots involved in each combination, as well as the ad slots affected by instance cancellation, removal of shared cache items, or changes in task waiting, are combined to form a common evaluation set;
[0041] Within the common evaluation set, the expected exposure gains of maintaining the current allocation and executing each remaining combination are deduced separately, and replacement options are determined from the combinations that increase the total expected exposure gains relative to maintaining the current allocation.
[0042] Preferably, in the deduction branch where the target ad placement first enters the viewport:
[0043] Record the moments when references are removed, ad instances are canceled, and cached items become unavailable, according to the execution order in the simulation.
[0044] When stopping the subsequent pre-rendering phase of the candidate ad, maintain the reference release and ad instance cancellation states that have been deduced before the stop start time, and determine the release time of the read references held in the in-transit phase based on the remaining execution time of the in-transit phase;
[0045] For other ad slots affected by the reclaimed collection, the readiness time of the ad instance is re-determined based on the remaining cache items, the remaining pre-rendering stage, and the updated available memory time.
[0046] The phase re-execution and startup wait changes caused by the removal of shared cache items are propagated to the ad instances that use shared cache items or the ad slots associated with the pre-rendering phase, and the expected exposure revenue of the corresponding exposure opportunities is calculated according to the redefined ad instance readiness time.
[0047] Preferably, updating the current allocation and comparing subsequent expected exposure revenue includes:
[0048] Record the events that have occurred, such as referral removal, ad instance cancellation, phase completion, ad slot entering the viewport, and actual memory release confirmation, to form an execution status record;
[0049] Based on the execution status record, determine the ad instances that can still be attached, the remaining task dependencies, the stages in progress, and the actual memory usage, and rebuild the current allocation;
[0050] Starting from the current reconstructed allocation, we construct a continuation plan to continue executing the remaining replacement operations, and a stop plan to stop initiating subsequent stages of candidate ads and maintain the remaining allocation.
[0051] In both the continue and stop scenarios, the execution status records are kept of the events that have occurred and their corresponding states. The subsequent reference release, memory release, and ad instance readiness times are deduced, and the expected exposure revenue is compared within the same set of ad slots and the same subsequent exposure opportunities.
[0052] If the expected exposure gain of the continued plan is not greater than that of the stopped plan, the replacement is cancelled; if the target ad slot enters the viewport before the candidate ad instance is ready, the exposure branch corresponding to the retained instance is executed.
[0053] Preferably, dependency checks are performed before the collection is reclaimed, including:
[0054] A release dependency graph is established with nodes representing reference dereferencing, end of the read phase, release of cached items, and the pre-rendering phase to be started.
[0055] Directed edges are set according to the relationship that the end of the reading phase precedes the release of the reading reference, and the release of all cached item references precedes the release of the corresponding cached item. Directed edges are also set according to the relationship that the start of the pre-rendering phase precedes the end of the reading phase that depends on the start of the corresponding phase.
[0056] For the pre-rendering stage where the memory required for startup must be provided by the specified cache item to be released, a directed edge is set according to the relationship that the specified cache item to be released is released before the corresponding pre-rendering stage starts.
[0057] When a directed cycle containing a pre-rendering phase to be started exists in the dependency graph, the corresponding replacement scheme is excluded, and the selection is re-executed from the remaining replacement schemes; if the remaining replacement schemes are empty, the current allocation is maintained.
[0058] Preferably, memory reservation and pre-rendering startup include:
[0059] In the same memory allocation operation, check available memory and establish a reservation record to cover the newly added memory peak. If the reservation is successful, start pre-rendering.
[0060] Each pre-rendering stage obtains memory quota from the reserved record. After successful memory allocation, the corresponding quota is transferred from the reserved but not yet actually allocated memory amount to the actual occupied memory.
[0061] When the demand for memory objects to be allocated in the next stage exceeds the remaining quota of the reserved record, the next stage is paused, the new memory demand for the remaining stage is re-determined, the additional quota is determined by the portion of the new memory demand that exceeds the remaining quota, and the expected exposure benefits of continuing replacement and stopping replacement are re-compared.
[0062] If the expected exposure benefits of continuing the replacement are greater than those of stopping the replacement, and the available memory can cover the additional quota, then add the reserved quota in one memory allocation operation; otherwise, cancel the replacement and release the reserved but not yet allocated memory quota.
[0063] Preferably, the processing of resources after undoing the replacement includes:
[0064] Create a replacement identifier for each replacement, and associate the phase completion event, instance ready event, and actual memory release confirmation with the corresponding replacement identifier;
[0065] When undoing a replacement, stop starting stages that have not yet started, maintain read references to already started stages until the corresponding stage returns a read end event;
[0066] For instance ready events that arrive after a replacement cancellation, remove the reference to the corresponding candidate ad instance; if the target ad slot has already determined the display instance, retain the display instance;
[0067] A release request is initiated after all references to the cached item are removed, and the actual memory usage is updated after receiving confirmation of the actual memory release associated with the replacement identifier.
[0068] When all the in-transit stages of the corresponding replacement have ended and all the memory to be released has been confirmed to be released, the processing status of the corresponding replacement resource will be changed to the completed state.
[0069] Preferably, the execution control of exposure opportunities includes:
[0070] Set the pending, selected, and ended states for each exposure opportunity;
[0071] The readiness check event of the candidate ad instance and the viewport entry event of the target ad position are placed in the same serial event queue. In the same processing batch, the viewport entry event is processed first, and then the readiness check event is processed.
[0072] In the pending entry state, the allocation relationship is processed according to the execution order of the serial event queue; when processing the viewport entry event, the validity period of the corresponding advertisement of the allocated advertisement instance is checked, the still valid advertisement instance is attached, and the corresponding exposure opportunity is changed to the selected state;
[0073] In the selected state, maintain the display instance of the corresponding exposure opportunity; when the target ad slot is detected to have left the viewport, remove the display reference and change the corresponding exposure opportunity to the ended state;
[0074] The same event sequence rules as those used in serial event queues are adopted in the deduction of expected exposure revenue.
[0075] Preferably, pre-rendering is performed in an off-screen execution environment that can control memory allocation and release for the material buffer, decoding output, and layout output, including:
[0076] Associate the media buffer, decoding output, and layout output with the reserved record respectively, and record the cache item identifier, the corresponding memory allocation identifier, and the actual number of bytes allocated for each memory object;
[0077] Each pre-rendering stage requests a corresponding reserved quota before allocating memory objects, and returns the actual number of bytes allocated according to the allocation identifier after successful allocation;
[0078] After the pre-rendering stage is canceled, the actual memory occupancy record is maintained for memory objects that are still read by decoding or rendering operations until the reading is finished and all references to the corresponding cache items are released.
[0079] The allocator that performs the memory object release returns a confirmation of the actual memory release, which includes the allocation identifier and the number of bytes released. Based on the confirmation of the actual memory release, the available memory is updated, and the waiting replacement scheme is re-examined.
[0080] Preferably, the target ad placement uses a reusable ad container, and the method further includes:
[0081] Establish a display binding record for reusable ad containers, including page identifier, ad slot identifier, binding generation, and exposure opportunity identifier, and associate the instance ready event generated when the candidate ad instance is ready with the corresponding display binding record;
[0082] When a reusable ad container is re-bound to another ad slot, the original exposure opportunity is changed to an ended state, the original display reference is removed, and the binding generation is incremented.
[0083] When processing instance ready events, compare the display binding records associated with the instance ready event with the current display binding records of the reusable ad container one by one;
[0084] If the page identifier, ad slot identifier, exposure opportunity identifier, and binding generation are consistent, and the current exposure opportunity is in the pending state and the corresponding replacement has not been revoked, update the allocation relationship of the corresponding ad slot; otherwise, remove the reference to the ad instance corresponding to the instance ready event and maintain the current allocation relationship of the reusable ad container.
[0085] Preferably, in cases where multiple replacement schemes are executed concurrently and share cache items or pre-rendering stages:
[0086] Record the instance references, read references, and corresponding shared pre-rendering stages held by the replacement scheme corresponding to each replacement identifier, and record the cache item identifier and the corresponding memory allocation identifier for the shared cache item;
[0087] When one of the replacement schemes is revoked, the instance references of the revoked replacement scheme that are no longer in use are released, the read references held by the in-transit phases of the revoked replacement scheme are maintained until the corresponding phase returns the read end event, the start of the phases used only by the revoked replacement scheme is stopped, and the execution and read references of the shared pre-rendering phases still used by other replacement schemes are maintained;
[0088] After all references to the shared cache item are removed, a release request is initiated. The actual memory release confirmation is registered according to the cache item identifier and allocation identifier, and the shared available memory record is updated accordingly.
[0089] Based on the completion or cancellation status of the shared pre-rendering phase and the confirmation of actual memory release, update the current allocation of other alternative schemes, and re-compare the expected exposure gains of each alternative scheme for continuing execution versus stopping execution.
[0090] Compared with existing technologies, the above technical solution has the following advantages:
[0091] 1. This invention includes both the target ad slot and ad slots affected by recycling or task waiting changes in the evaluation scope of the replacement scheme. In the deduction branch where the target ad slot first enters the viewport, the already deduced reference removal and instance cancellation states are retained, allowing the instance readiness time and expected exposure revenue of other affected ad slots to be calculated according to the resource state after recycling. Therefore, changes in stage re-execution and startup waiting caused by the removal of shared cache items can be included in the ad replacement decision, avoiding the continued evaluation of canceled ad instances or cache items that have lost their usability as available resources. This ensures that the pre-rendering allocation decision in the internet advertising service corresponds to the actual impact of the replacement operation on multiple ad slots.
[0092] 2. This invention constructs a recycling set covering all references to cached items to be released, excluding cached items whose reference release depends on the readiness of candidate ad instances or the release of references to retained instances. Combined with release dependency verification, it identifies circular dependencies that require the completion of the pre-rendering phase to obtain startup memory. Based on this, it determines the peak amount of new memory based on pre-rendering phase dependencies, allowed parallel relationships, and memory object sharing relationships. Upon receiving confirmation of actual memory release, it updates available memory and reserves the required memory all at once while retaining instances continue to occupy memory. This ensures that pre-rendering startup has adequate memory guarantees and avoids the redundant allocation of memory that is expected to be released but has not yet been released.
[0093] 3. During the replacement process, this invention updates the current allocation based on the already occurred reference removal, instance cancellation, and actual memory release. Starting from the updated state, it compares the expected exposure gains of continuing the replacement versus stopping it, ensuring that subsequent decisions reflect resource changes during execution. When continuing the replacement no longer offers an advantage in terms of expected exposure gains, the subsequent stages are stopped. Simultaneously, the memory records of in-transit tasks and unconfirmed release cache items are maintained. This reduces resource consumption from continuing pre-rendering tasks that are no longer suitable for the current exposure timing and avoids prematurely counting still-in-use memory as available memory when reversing the replacement.
[0094] 4. This invention maintains ready-to-use instances during the pre-rendering of candidate ad instances and selects still-valid ad instances based on the order in which candidate ad instances become ready and the target ad slot enters the viewport. This ensures that when the target ad slot enters the viewport first, the reserved instances can take over the current exposure opportunity. By adopting a unified serial processing rule for instance readiness verification events and viewport entry events, and using the same event priority rule in the expected exposure revenue projection, the instance selection in the projection is consistent with the selection rule at the execution end. Combined with the retention of display instances for exposure opportunities and the binding verification of reusable ad containers, this invention avoids changing display instances due to delayed readiness events within the same exposure opportunity, or incorrectly assigning candidate ad instances from the original ad slot to the rebound ad slot.
[0095] 5. When multiple replacement schemes share a cache item or pre-rendering stage, this invention records the references held by each replacement scheme and the usage relationship of the shared pre-rendering stage. When one replacement scheme is revoked, the shared pre-rendering stage and read references that other replacement schemes still need to use are preserved, so that partial revocation will not directly interrupt the pre-rendering process on which other replacement schemes depend. By initiating the release after all references to the cache item are released, and registering the actual memory release confirmation according to the cache item identifier and allocation identifier, it is possible to avoid duplicate release calculations of shared memory or erroneous updates of the current memory record by the release confirmation of old allocations. Furthermore, the shared pre-rendering stage and memory release status are fed back to other replacement schemes, ensuring that subsequent decisions on concurrent ad pre-rendering are consistent with the actual state of shared resources. Attached Figure Description
[0097] Figure 1 A flowchart illustrating the overall process of dynamic pre-rendering and exposure revenue optimization for multiple ad slots in fast applications.
[0098] Figure 2 A flowchart illustrating the process of obtaining and matching the expected exposure window and pre-rendering stage time inputs for ad placements.
[0099] Figure 3 A flowchart for closing the garbage collection and release dependency verification process for cached item references.
[0100] Figure 4 A flowchart illustrating the memory reservation process after determining the peak memory usage for pre-rendering and confirming the actual memory release.
[0101] Figure 5 A flowchart illustrating the exposure branch projection and expected exposure revenue comparison for a multi-ad placement replacement scheme.
[0102] Figure 6 This is a flowchart illustrating the process of determining whether to continue or stop replacement based on the actual execution status, and handling resources after cancellation.
[0103] Figure 7 Flowchart for the validation process of exposure opportunity status control and reusable ad container binding.
[0104] Figure 8 This is a flowchart illustrating the shared reference handling and resource feedback process for concurrent replacement schemes. Detailed Implementation
[0106] This embodiment illustrates a method for dynamic pre-rendering and exposure revenue optimization of multiple ad slots in quick apps for internet advertising services. The terminal maintains multiple ad slots on the quick app page. Before an ad slot enters the viewport, it acquires matching ads and prepares ad instances. When a candidate ad appears, it determines whether to replace a ready-to-use instance with a candidate ad instance, considering the ad slot's expected exposure window, ad validity period, estimated revenue per thousand impressions, and pre-rendering resource status. The evaluation of the replacement scheme includes the target ad slot and other ad slots affected by cache reclamation or task waiting changes. The decision to continue or stop the replacement execution is related to actual reference dereferencing, instance cancellation, and memory release occurring on the terminal. For the overall processing procedure, please refer to [link to documentation]. Figure 1 .
[0107] In this embodiment, the terminal runs a quick app and has an execution environment capable of managing pre-rendered ad memory. The quick app page provides the execution environment with ad placement identifiers, page layout, page display status, and scroll position. The ad server provides the matching ad's creative address, ad identifier, validity period, and estimated revenue per thousand impressions. The pre-rendered execution environment provides the terminal's scheduling process with confirmations of stage completion, instance readiness, read completion, and actual memory release. The ad server is responsible for providing ad data; scheme deduction, recycling selection, memory reservation, replacement control, and display instance selection are all completed on the terminal.
[0108] The off-screen execution environment is used for acquiring, decoding, and laying out ad assets, keeping the candidate ad content separate from the visible ad container until candidate ad instances are ready. The main implementation uses a terminal runtime component that can uniformly allocate ad asset buffers, decoding outputs, and layout outputs. This component can be set in the ad rendering execution layer of the quick app runtime engine. The execution layer provides controlled memory allocation, quota reservation, and actual release notifications. If existing platform interfaces only return successful ad loading without providing controlled memory information, the successful loading notification is not considered a confirmation of memory release, nor is it used to determine if the pre-rendering startup conditions have been met.
[0109] To illustrate the calculation and control process, a set of specific calculation examples are provided below. The memory amounts, times, probabilities, and estimated revenue per thousand impressions in the examples are inputs set for illustrating the calculation process and do not represent actual performance data measured on the terminal. The memory ledger uses bytes as the basic unit, with tables represented in MiB, where 1 MiB equals 1,048,576 bytes; the time ledger uses the same terminal's monotonic clock, with tables using milliseconds or seconds as needed; the ad placement geometry uses pixels in the same page coordinate system; and the estimated revenue per thousand impressions is uniformly expressed in yuan per thousand effective impressions. Ads from different sources participating in the same revenue comparison use the same currency and the same effective impression caliber.
[0110] In this embodiment, ad slot A is the target ad slot, and ad slots B and C are other ad slots on the same page. Ad slot A already has a reserved instance, which comes from the ad creative acquisition, decoding, and layout process completed before this round of replacement, and saves an instance ready record and corresponding cache reference; the candidate ad matches the size, creative type, and container capacity of ad slot A. Ad slot B's instance references a cache to be reclaimed, and an in-transit stage of ad slot C is reading the same cache; the stage output already allocated to ad slot C is located in another cache item. After the in-transit stage ends, the reference to the shared input can be released, while the already formed output is still used by subsequent stages of ad slot C. The calculation start point is denoted as the decision time, and the times in Table 1 are all given relative to the decision time.
[0111] Table 1. Advertisement Input Conditions for Calculation Examples
[0112] Advertising target Estimated revenue per thousand impressions: RMB per thousand effective impressions Remaining validity period, seconds Exposure window in an example trajectory, seconds Decision-making moment status The reserved instance of ad slot A corresponds to the ad. 12 6 0.60 to 2.20 The instance is ready. Candidate Ads for Ad Slot A 30 6 0.60 to 2.20 Waiting for pre-rendering Ad space B 8 8 1.80 to 3.40 Instances and shared input are available Ad space C 10 10 3.00 to 4.80 There is a stage in transit for reading shared input.
[0113] The ad validity period is obtained from the validity period field on the ad server and converted into the expiration time in the terminal's monotonic clock according to the time base and timing start point corresponding to the field. When the server provides an absolute expiration time, the conversion is performed using the correspondence between the time base in the ad response and the terminal's reception time; when the server provides the remaining valid duration with the terminal's reception time as the timing start point, the expiration time is determined by adding the remaining valid duration to the reception time. If the timing start point of the remaining valid duration is earlier than the terminal's reception time, the consumed time that can be determined based on the response time information and transmission time information is deducted. When there is a clock error, instance connectivity verification is performed within the time boundary that can be confirmed to still be valid; if the time base or timing start point is insufficient to determine the boundary, the instance is not considered to have passed the validity period verification. The estimated revenue per thousand impressions is provided by the ad server and associated with the ad identifier; ads with missing revenue values or validity periods are not included in the candidate ad set for this round and will participate in subsequent decisions after the fields are completed.
[0114] The reserved instance refers to an ad instance whose material processing and layout are complete, which matches the target ad position, and which retains necessary cache references. The candidate ad instance is an ad instance formed by performing pre-rendering on the candidate ad. Instance readiness indicates that the necessary stages in the pre-rendering task graph have been completed, the output object has been registered, and the instance can be attached to the ad position after completing the validity period and binding relationship verification. Material download completion, single decoding stage completion, and ad instance readiness are recorded separately, and the three do not share a single completion state. In the main embodiment, the ad position container and public display environment have been established, and the corresponding permanent occupancy is included in the current actual occupancy; the instance layout object used for attachment is pre-formed during the pre-rendering process, and the attachment action is not based on the instance creation steps that have not yet been calculated.
[0115] like Figure 2 As shown, the terminal obtains the ad space rectangle and viewport rectangle when the page layout is completed, the scroll position changes, and the page display state changes. The rectangles of each ad space within the page are first transformed to the same coordinate system. When the page is in display mode and the ad space rectangle and viewport rectangle have a positive area intersection, the ad space is considered to have entered the viewport. When the intersection disappears or the page exits display mode, the ad space is considered to have exited the viewport. If it is necessary to distinguish between partial visibility and visibility meeting effective exposure conditions, the former is used to trigger instance selection, and the latter is used to calculate the effective exposure probability; both are processed separately. When the page exits display mode, the current continuous visible interval ends; when it re-enters display mode and meets the visibility conditions again, the timing starts from the beginning of a new continuous visible interval.
[0116] The page layout version is updated after the layout affecting the coordinates or size of the ad placement is submitted. The scroll trajectory sample saves the time offset, horizontal and vertical scroll displacement, and page display state. The displacement in the sample is normalized relative to the sample starting point, and then applied to the current page layout using the current scroll position as the starting point. The main embodiment selects a trajectory sample that matches the current page layout version, list direction, and initial scroll state, and performs piecewise linear interpolation on adjacent records in the trajectory. Taking ad placement A with its upper boundary at content coordinates of 1800 pixels, viewport height of 1200 pixels, current vertical scroll position of 0 pixels, and ad placement height of 400 pixels as an example, a predicted trajectory with a downward scrolling speed of 1000 pixels per second causes ad placement A to enter the viewport when the scroll displacement exceeds 600 pixels, and causes ad placement A to exit the viewport when the displacement reaches 2200 pixels; the interval forms the expected exposure window in the trajectory, approximately 0.60 to 2.20 seconds. Assuming the ad placement is fully visible horizontally, the predicted timeframe for a 50% visible area is 0.80 to 2.00 seconds, providing a duration sufficient to continuously meet the 1-second condition. Actual events are determined by the actual page geometry and are not replaced by predicted times.
[0117] The stage duration samples are categorized by terminal processor configuration, allowed number of worker threads, ad output specifications, creative type, and execution stage-related records. Each record includes the stage entry time, actual start time, calculation end time, and output registration time; waiting time and calculation time are saved separately. The creative acquisition stage also records the number of bytes acquired and the response status. Historical records are derived from stage events in the terminal execution environment; when there are not enough similar records, stage calibration records from the same terminal with the same output specifications can be used. For candidate ads for which there are no usable duration data, replacements relying on duration predictions will not be initiated; the existing allocation will be maintained, and corresponding stage records will continue to accumulate.
[0118] The main implementation uses a page scrolling trajectory sample and a set of stage time samples as input for a simulation. Within the same simulation, the current allocation and execution replacement schemes maintain the same trajectory, page layout version, and set of stage time samples; different schemes only change their own resource release, task cancellation, waiting, and startup relationships. The waiting time in each scheme is determined by the dependencies and resource status of this simulation, and the same waiting time in the historical record is not repeatedly added to the stage execution time. Related stage times are preferentially obtained as a group from the same execution record to avoid arbitrarily separating the material acquisition delay and decoding time relationship within the same execution. The input sequence number and sample content of each simulation are retained for recalculation based on the same input.
[0119] The effective exposure conditions are used as inputs for the advertising service configuration and remain consistent throughout the scheme comparison. One calculation condition in this embodiment is that the page is in the foreground, the ad instance is already attached, the visible area ratio reaches 50%, and the visibility condition is met continuously for 1 second. This condition is only used for calculating the effective exposure probability in this embodiment and does not represent the same rule used by all advertising platforms. The effective exposure probability after attachment can be obtained from historical records of the same ad placement type, output specification, visible duration range, and page state. Using the ad placement type, output specification, expected visible duration range, and page state obtainable in this simulation, select the corresponding condition group. The statistical value is the number of records in the condition group that meet the configuration conditions divided by the number of attachment records with complete observation results. The probability is the effective exposure probability under the condition that the instance can already be attached, and its value is from 0 to 1 and dimensionless. When there are no complete observation records in the condition group, the statistical probability cannot be calculated based on this, nor is a missing record equivalent to a probability of zero. Records where observation has not yet ended are not considered successful or failed samples. To illustrate with another statistical calculation example, if 20 complete records are set in the same condition group, and 12 of them meet the configuration conditions, then the probability calculation value is 12 divided by 20, which equals 0.60. The number of records is also an example input and does not represent the actual measured samples obtained. When exposure conditions change, the statistical records under the corresponding conditions are used, and the probability values under different conditions are not reused.
[0120] In each simulation, it is first determined whether the predicted trajectory generates an exposure opportunity. Then, it is determined whether there is an ad instance in the corresponding branch that is still valid and ready at the time of attachment. If the above conditions are met, the effective exposure probability after attachment is used. If there is a lack of exposure opportunities, the instance is not yet ready, or the ad has expired at the time of attachment, the probability of the corresponding branch forming an effective exposure is zero. The completion of pre-rendering itself is not counted as an exposure. The calculated expected exposure revenue is used for the terminal's pre-rendering and replacement decisions and does not replace the ad server's confirmation of actual exposure.
[0121] like Figure 3As shown, the terminal establishes cache entries based on the content identifier and output specifications. The content identifier can consist of the content version and content summary, while the output specifications include the width, height, pixel format, and layout specifications that affect the output content. Different cache entries are established for the same content when the output specifications are different, and ad instances only share cache entries when both the content and output specifications are identical. The ad identifier is used to distinguish the target audience for the ad, and the content identifier is used to distinguish the shareable resources. When multiple ad instances share the same content, they still retain their respective ad identifiers and corresponding exposure opportunity records.
[0122] Each cache entry stores the allocation identifier, allocated bytes, and reference set of the corresponding memory object. Instance references are established as the ad instance uses the cache entry and are released when the instance is canceled or the corresponding binding relationship is broken; read references are established before the execution phase begins reading the cache entry and are released after the read completion notification arrives; cache-held references are established by the cache retention policy and are released when the cache entry is selected for recycling and removed from the retrievable cache directory. Allocation references represent the allocation relationship between the ad slot and the ad instance, while display references represent the relationship that the ad instance needs to maintain while it is displayed within the viewport; both types of references maintain the necessary cache entry references through the respective ad instance, and it is not acceptable to simply delete the allocation record while retaining an incorrect number of freeable bytes.
[0123] Reference registration and deregistration are completed during the terminal's serial state processing. After selecting an ad instance to be reclaimed, the complete reference set of the corresponding cache item is checked starting from the instance references; if other instance references exist, it is determined whether the corresponding instance can be removed from the same reclamation check; if read references exist, it is determined whether the read phase can end independently and the earliest read end time; if cache holding references exist, operations to remove the cache from the cache directory and release the holding relationship are generated. Only when all references to the corresponding cache item have definite deregistration actions are the cache item's memory listed as freeable memory in this reclamation set.
[0124] Cache items involving reserved instances are excluded from the list of cache items to be released. Existing cache items that candidate ads continue to use are registered as fixed-occupancy items and maintained with necessary references. If the end of the read phase depends on the candidate ad instance being ready, or if the reserved instance reference must be released before the corresponding task can end, the corresponding cache item cannot provide reclaimed memory for the start of this round of candidate ads. The reclamation check is repeated until all references to the cache items to be released in this round are overwritten, or the relevant cache items are excluded. Before performing reclamation, the reference set is re-checked; if references were added previously without corresponding release actions, the reclamation set is re-evaluated, and release is not performed based on the number of expired references.
[0125] In this embodiment, the memory capacity used for ad pre-rendering is 64 MiB, and the current actual usage at the decision time is 48 MiB. This includes 8 MiB reserved for instance-exclusive cache, 4 MiB of existing cache for subsequent use by candidate ads, 12 MiB of input cache to be reclaimed jointly associated with ad slots B and C, 8 MiB of output cache already allocated for ad slot C, and 16 MiB of other controlled usage that still needs to be reserved. Each part corresponds to a different memory object, totaling 48 MiB. Other controlled usage includes containers, reference ledgers, reserved records, and stage record storage needed for this round. Record storage is pre-allocated according to the number of objects that can be registered in this round; if the capacity is insufficient, no new tasks exceeding the recording capacity will be added. If the same object appears in the resource lists of multiple instances, it is only registered once in the current actual usage.
[0126] Table 2 Example of reference closure calculation for recycled sets
[0127] Cache items Actual usage, MiB Registered citation Recycling Measurable releases, MiB Reserve instance exclusive cache 8 Preserving instance references Keep the references and exclude items to be released. 0 Candidate ads continue to use existing caches 4 Cache holds references Retain reference as a fixed occupancy item 0 Input cache associated with ad slots B and C 12 Instance references to ad slot B, read references to ad slot C, and cached references. Cancel ad slot instance B, wait for reading to complete, and release cache holding relationship. 12 Output caching of ad slot C 8 Example of ad placement C Keep the output for later stages. 0
[0128] Even if the 12MiB input cache in Table 2 appears in the resource lists of both ad slots, only 12MiB of freeable memory is counted. If only ad slot B instance is cancelled while ad slot C is still being read, the freeable amount cannot yet be transferred to available memory; only after both the read reference and the cache-held reference have been released, and the allocator confirms that the corresponding memory can be reallocated, can available memory be increased. The independent output generated after ad slot C finishes reading is still retained; whether the removed input needs to be retrieved again depends on the remaining task dependencies.
[0129] Multiple collection sets can be generated for the same candidate ad. The main implementation first lists the ad instance combinations that can be cancelled, then performs a reference closure check on each combination to obtain different cache item sets, and removes duplicates by cache item identifier. For pages with a limited number of ad instances, instance combinations can be enumerated one by one; for pages with a large number of instances, combinations can be gradually expanded according to the expected release memory and affected ad slots, but each combination entering the comparison should ultimately complete a reference coverage check, and the estimated release amount cannot replace the closed release amount. The main implementation can also first select candidate ads whose estimated revenue per thousand impressions is greater than the estimated revenue per thousand impressions of the ad corresponding to the retained instance, and whose validity period overlaps with the expected exposure window. In Table 1, 30 yuan is greater than 12 yuan, and the candidate ad meets the screening criteria; overlapping validity periods only constitute candidate screening criteria and do not replace validity period verification during attachment.
[0130] See also the dependency release check. Figure 3The terminal establishes a release dependency graph with nodes representing the end of the read phase, the release of read references, the release of instance references, the release of cached references, the release of cached items, and the pre-rendering phase to be started. The end of the read phase points to the release of read references, and the release of each cached item reference points to the release of the cached item. The end of the read phase depends on the start of the pre-rendering phase, so the graph points from the pre-rendering phase to the end of the read phase. Only when a pre-rendering phase truly needs to wait for the release of a specified cached item to obtain the required memory does the graph point from the cached item release to the pre-rendering phase. Resource requirements that can be satisfied by other available memory do not establish edges that necessarily depend on the release of the specified cached item.
[0131] The terminal performs a topological sort on the dependency graph, retrieving nodes without unmet prerequisites and deleting their corresponding outgoing edges. If nodes remain after sorting, it checks whether the loop formed by the remaining nodes includes a pre-rendering stage to be started; if so, the corresponding replacement scheme is excluded. For example, if a reading stage must wait for the subsequent stage of a candidate ad to start before it can end, and the subsequent stage of the candidate ad must wait for the reading stage to release its input cache before it can acquire memory, then this combination cannot be considered an executable replacement scheme. In the main embodiment, the reading stage of ad slot C can end independently within the existing allocation. The dereference of the reading stage does not depend on the candidate ad instance being ready, nor on the dereference of the retained instance, and therefore the loop does not exist.
[0132] like Figure 4 As shown, the pre-rendering task graph for candidate ads includes the material acquisition stage, decoding stage, and layout stage, and records the input objects, output objects, execution workspaces, stage dependencies, and allowed parallel relationships. The memory requirements of the stage workspace are given by the execution implementation; the material buffer requirements are determined by the current round's material response length and the upper limit of the block buffer; the decoding output requirements are determined by the output size, pixel format, and line alignment rules; and the layout output requirements are determined by the layout nodes, drawing instructions, and corresponding storage structures. For compressed materials whose output size is not yet determined, the corresponding stage requirements are calculated after reading the material header information or obtaining the server-side output specifications, and unknown sizes are not treated as zero.
[0133] The existing 4MiB cache used by candidate ads is counted in the current actual usage and is no longer considered as a new allocation request; however, it is maintained as a reference to prevent the existing cache from being released by other reclamation processes before the candidate ads finish using it. The same buffer passed across stages uses the same memory object identifier; multiple data edges in the task graph can point to the same object, but new memory is only counted once. If an output object is still used by subsequent stages after the production stage ends, it continues to be maintained through the aforementioned instance reference or read reference, and is retained in the set of concurrently surviving memory objects; the end of the production stage is not considered a basis for the output object being released.
[0134] The main implementation executes material acquisition, decoding, and layout in a dependent order. These three stages share a single 4MiB workspace. During stage handover, the next stage is only allowed to use the workspace after confirming that the previous stage has finished reading it. Material acquisition output is 4MiB, decoding output is 12MiB, and layout output is 4MiB. The 4MiB material acquisition output and the 4MiB workspace are retained in this example until the layout is completed before being released. The objects listed in Table 3 are all memory objects that need to be added relative to the current actual memory usage; existing fixed-occupancy items are not added again.
[0135] Table 3 shows an example of the newly added peak memory calculation.
[0136] stage Simultaneously surviving newly added memory objects Increased memory capacity, MiB Material Acquisition Stage Workspace 4MiB, Material Acquisition and Output 4MiB 8 Decoding stage Workspace 4 MiB, Material Acquisition Output 4 MiB, Decoding Output 12 MiB 20 Layout phase Workspace 4 MiB, Material Acquisition Output 4 MiB, Decoding Output 12 MiB, Layout Output 4 MiB 24
[0137] Therefore, the peak value of the newly added memory in this example is 24 MiB. A 12 MiB decoding output, for example, corresponds to an image output of 2048 pixels wide, 1536 pixels high, and 4 bytes per pixel. The number of bytes is 2048 multiplied by 1536 and then multiplied by 4, resulting in 12,582,912 bytes, or 12 MiB. This output specification is only for the memory calculation example. When the output specification is changed, the number of bytes allocated and the peak value are recalculated; 24 MiB cannot be maintained. When multiple stages are allowed to run in parallel, the maximum sum of the number of bytes of newly added objects that are simultaneously alive is taken, according to the stage combinations allowed by the execution end and the lifespan of the output objects. The execution end starts the task according to the parallel relationship used to calculate the peak value; it cannot use serial peak admission and then arbitrarily increase the parallelism.
[0138] The main implementation maintains the current actual occupied memory, the amount of memory reserved but not yet allocated, and the available memory. Available memory equals the controlled memory capacity of this round minus the first two. Each actual allocation object is registered only once. When the reserved quota is converted to actual allocation, the unallocated reserved amount is reduced and the actual occupied memory is increased; the conversion does not reduce the already deducted available memory again. Reserved instances, fixed occupied items, and objects awaiting actual release confirmation are all included in the current actual occupied memory.
[0139] Before each replacement plan enters the revenue calculation, the current available memory is added to the corresponding reclaimed set after deduplication by cache item. If the resulting value is less than the peak value of the new memory for the candidate ad, the plan is excluded. This check is only used to determine whether a plan has the possibility of meeting the memory conditions; it does not pre-count the number of bytes that have not yet been released into the available memory. After completing the memory check, release dependency verification, and revenue comparison, if there is no executable plan that increases the expected total exposure revenue, the current allocation is maintained, and this round of reclamation is not initiated.
[0140] A confirmed memory release indicates that the allocated memory has been returned to the controlled memory that can be reallocated within the current execution environment, without requiring the resident memory of the operating system processes to decrease synchronously. The main implementation uses a controlled memory pool with pages as the basic allocation unit. The size of requests in each stage is aligned upwards according to the allocation unit, and the allocation identifier is associated with the actual set of pages occupied. Quota reservation and actual page allocation use the same ledger. Requests smaller than the allocation unit are accounted for as a unit, and alignment overhead is included in the stage requirement. After all cached references are released, the allocator generates a release confirmation when the relevant reads are completed and the corresponding pages are returned to the still-allocatable set; simply deleting objects from the cache index does not generate a release confirmation.
[0141] In this example, the initial available memory is 64MiB minus 48MiB, resulting in 16MiB, which is less than the peak of 24MiB of newly added memory. After the 12MiB input buffer is actually released, the current actual usage becomes 36MiB, and the available memory becomes 28MiB. The terminal checks the available memory and establishes a 24MiB reservation record within the same serial allocation operation. After reservation, the amount of memory not yet actually allocated is 24MiB, and the available memory is 4MiB. The 8MiB corresponding to the reserved instance is still counted in the current actual usage of 36MiB. If other tasks are allowed to occupy the same amount between the check and reservation, duplicate admission will occur. Therefore, the memory check and reservation record are completed within the same protected allocation operation.
[0142] The memory values in Table 4 and below for the corresponding execution branches are calculated based on the allocation, reservation, and release changes explicitly listed in the table; the actual occupancy and reservation of other controlled objects remain unchanged between the listed states. The 4MiB of existing cache used by candidate ads is maintained with references as originally cached and is not included in the release amount when candidate ads are withdrawn. When other ad slots are newly allocated or released during actual execution, they are simultaneously recorded in the shared memory ledger.
[0143] Table 4. Calculation Example of Conversion from Reserved to Actual Occupancy
[0144] state Current actual usage, MiB MiB has been reserved but not yet allocated. Available memory, MiB Before recycling 48 0 16 After the 12MiB cache is actually released 36 0 28 After reserving 24MiB at once 36 24 4 After the workspace and media buffer are allocated 44 16 4 After decoding output allocation 56 4 4 After layout output allocation 60 0 4
[0145] In each line, the sum of the current actual occupied memory, reserved unallocated memory, and available memory is 64 MiB. After the phase ends, even if the working area or input buffer is no longer read, the current actual occupied memory is only reduced when the allocator completes the actual release. When the actual requested amount in a phase is lower than the reserved amount, the remaining quota is retained in the corresponding reservation record until it is used by subsequent phases or released when the replacement terminates. When an allocation request fails, the number of failed bytes is not included in the actual occupied memory, and no release confirmation is generated for the corresponding object. After the release confirmation process is completed, the scheme waiting for memory is notified to recheck the current available memory and the execution status of this scheme. Only if the admission conditions are still met will a reservation be established and the phase started.
[0146] like Figure 5 As shown, before selecting a replacement scheme, the terminal establishes a scheme to maintain the current allocation and a replacement scheme corresponding to the candidate ads and the recycling set. Both schemes begin the deduction process with the same decision time and the same initial resource state. The main implementation incorporates the next expected exposure opportunity of the currently registered ad slot into this round of deduction, using the latest exit time within these expected exposure windows as the endpoint of this round of deduction; both schemes use the same endpoint. For all replacement schemes to be compared, the target ad slot, the ad slot corresponding to the canceled instance, the ad slot associated with the shared cache item, and the ad slots affected by changes in worker thread or memory wait relationships are combined to form a common evaluation set. The check continues along task dependencies and resource wait relationships until the new impact no longer leads to other ad slots. The revenue of both schemes is calculated within the same set and the same group of subsequent exposure opportunities; ad slots whose state remains unchanged in the set are still counted in the same way.
[0147] The simulation employs a chronological event processing approach. Initial events include predicted ad slot entry and exit from the viewport, the expected completion of already initiated phases, and ad expiration. When executing the reclamation plan, events for instance cancellation, reference release, and expected memory release are added. Phase start and completion events are added when phase dependencies and reservation conditions are met. For each event processed, ad slot allocation, cached references, actual simulated memory usage, and the waiting queue are updated before determining the next event. Memory release wait times in the simulation can be sampled from the allocator's past records from the last read to release confirmation; actual execution always uses real release confirmations and does not increase actual available memory simply because the predicted release time has arrived.
[0148] The two branches, "ad instance ready first" and "ad slot enters viewport first," are handled in a mutually exclusive manner. When a candidate ad instance is ready, the allocation reference of the target ad slot is transferred to the candidate ad instance, the allocation reference of the reserved instance is released, and the validity of the candidate ad is checked when the target ad slot enters viewport. When the target ad slot enters viewport first, the still valid reserved instance is selected, a display reference is established, and the subsequent stages of the candidate ad are stopped; the already started stages continue to retain read references until the read is completed. Within the same exposure opportunity, the revenue of the candidate ad and the revenue of the reserved instance cannot be added as two exposures simultaneously.
[0149] When deducing the subsequent stages of candidate ads, the instances canceled, dereferenced, and cached removal states that have occurred before the stated time are retained. For other ad slots, the corresponding exposure probability is calculated only if a new attachable instance can be formed based on the remaining cache items and tasks; if a canceled instance does not have a subsequent preparation path that can be completed before exposure, the effective exposure probability of the branch corresponding to the canceled instance is zero. If there are still consumers after the shared input is removed, the acquisition or decoding stages that still need to be completed are re-executed according to the input production relationship of the task graph. The worker thread occupation, memory allocation, and startup waiting caused by the re-execution continue to propagate to the relevant ad slots until the ready times in the current evaluation set have been updated. The re-execution of the required stages does not restore the canceled instance records to their original ready state.
[0150] This example illustrates branch selection using five equally weighted iterations. Table 5 only lists the two moments that determine the target ad placement branch. The candidate ad instance readiness time includes the time for recycling wait, memory reservation wait, stage execution, and readiness verification; the target ad placement entry time into the viewport comes from the corresponding trajectory sample. The values in the table are calculation conditions used to illustrate the selection process and do not represent five actual terminal tests conducted.
[0151] Table 5. Example of Calculation for Target Ad Placement Branch Selection
[0152] Deduction sequence number Expected entry time into viewport, milliseconds Expected ready time during continued preparation, in milliseconds Select branch 1 600 400 Candidate Ad Examples 2 520 360 Candidate Ad Examples 3 480 420 Candidate Ad Examples 4 700 500 Candidate Ad Examples 5 180 260 Reserved instances
[0153] To demonstrate revenue calculation separately, the effective exposure probability of the target ad placement after being attached to each selected branch is assumed to be 0.60. Maintaining the current allocation, the probabilities of ad placements B and C forming effective exposures are 0.60 and 0.40, respectively. After implementing the replacement scheme, the effective exposure probabilities of ad placement B in the five iterations are 0, 0.40, 0.40, 0.20, and 0, respectively, and those of ad placement C are 0.30, 0.40, 0.40, 0.40, and 0.25, respectively. These probabilities serve as the given inputs for this example, and Table 6 only shows the revenue calculations under the given branch and probability inputs. In actual implementation, the effective exposure probability of each branch is determined by the readiness and validity period judgments and historical exposure statistics. Branches with a non-zero probability for ad placement B correspond to remaining preparation paths that can be completed before the corresponding exposure; branches with a zero probability correspond to remaining paths that failed to form effective instances in time after being recycled, and the probabilities before cancellation cannot be used after the instance is cancelled.
[0154] Maintaining the current allocation, the expected exposure revenue for the target ad slot is 12 multiplied by 0.60 and divided by 1000, yielding 0.00720 yuan; ad slot B is 8 multiplied by 0.60 and divided by 1000, yielding 0.00480 yuan; and ad slot C is 10 multiplied by 0.40 and divided by 1000, yielding 0.00400 yuan, totaling 0.01600 yuan. When implementing the replacement plan, in four out of five simulations for the target ad slot, candidate ad instances were selected, and one instance was retained. The average expected exposure revenue for the target ad slot is the sum of four 0.01800 yuan and one 0.00720 yuan, divided by 5, yielding 0.01584 yuan. The average effective exposure probability for ad slot B is 0.20, corresponding to 0.00160 yuan, and the average effective exposure probability for ad slot C is 0.35, corresponding to 0.00350 yuan.
[0155] Table 6. Calculation of Expected Exposure Revenue within the Same Evaluation Set
[0156] Ad space Maintain the current allocation, yuan Execute the replacement scheme, Yuan Difference, Yuan First 0.00720 0.01584 0.00864 Second 0.00480 0.00160 -0.00320 C 0.00400 0.00350 -0.00050 total 0.01600 0.02094 0.00494
[0157] Under the input conditions of this example, the difference between the total expected exposure revenue of the replacement scheme and the current allocation scheme is 0.00494 yuan; after the actual release of the 12MiB recycling set, the available memory can meet the peak of 24MiB additional memory, therefore the combination can be selected as the replacement scheme. Table 6 also shows that the selected scheme does not require an increase in the expected exposure revenue of each ad slot; the changes in ad slots B and C have been included in the same comparison. If the ad slot B instance, which was canceled in the fifth simulation, is restored to its pre-cancellation state, the revenue of ad slot B in the branch will be incorrectly increased; if only the target ad slot is compared, the losses of other ad slots will also be missed.
[0158] After the scheme selection is completed, the actual recycling begins. Taking the resource conditions in Table 4 as an example, at the decision moment, the terminal cancels the instance of ad slot B and removes the corresponding instance reference, removes the input cache to be recycled from the searchable cache directory and removes the cache holding reference; the reading phase of ad slot C returns a read end event at 40 milliseconds, then removes the read reference and requests to release the cache; the allocator returns a 12MiB actual release confirmation at 80 milliseconds, and only then does the terminal update the available memory from 16MiB to 28MiB and establish a 24MiB reserved record. During the period from 40 milliseconds to 80 milliseconds, the corresponding cache no longer has any valid reads, but it is still registered as actually occupied. The time process described is used to illustrate the order of events and does not mean that the allocator has a fixed 40 millisecond release delay.
[0159] In the execution branch where the candidate ad instance is ready first, the material acquisition, decoding, and layout sequentially acquire and complete the reserved quota, passing the readiness check at 400 milliseconds. The terminal first establishes an allocation reference from the target ad slot to the candidate ad instance, then releases the allocation reference of the reserved instance, and subsequently handles the release based on the remaining references of each cache item. After the actual release of 8 MiB in the workspace and material acquisition output, and the actual release of 8 MiB in the reserved instance's exclusive cache, the current actual usage decreases from a peak of 60 MiB to 44 MiB, and the available memory becomes 20 MiB; if any of these objects still have read or display references, the values are updated only for the confirmed released portion. At 600 milliseconds, ad slot A enters the viewport, and the terminal verifies the candidate ad's validity period again and attaches the candidate ad instance.
[0160] In another execution branch where the ad placement first enters the viewport, the candidate ad creative acquisition phase ends at 120 milliseconds, the decoding phase executes from 120 milliseconds to 220 milliseconds, and the layout phase is originally scheduled to start after 220 milliseconds. Ad placement A enters the viewport at 180 milliseconds. The terminal retains the instance that is still active, cancels the layout phase that has not yet started, and releases the 4 MiB of reserved memory that has not yet been actually allocated. At this time, the workspace, creative acquisition output, and decoding output are still held by the decoding phase in transit, and the current actual usage is still 56 MiB, while the available memory changes from 4 MiB to 8 MiB. After the decoding phase finishes reading at 220 milliseconds, the terminal releases the corresponding read references and releases the candidate ad output that is no longer in use. After the confirmation of the actual release of a total of 20 MiB, the current actual usage becomes 36 MiB, the available memory becomes 28 MiB, and the retainable instance continues to be displayed until ad placement A exits the viewport. The entire branch does not restore the canceled ad placement B instance.
[0161] like Figure 6 As shown, from the start of recycling to the end of replacement, the terminal updates the execution status record upon receiving confirmations of reference release, instance cancellation, phase completion, viewport entry, or actual memory release. The update includes the time of occurrence, the replacement identifier, the ad slot or cache item identifier, the phase identifier, and the status change. The terminal reconstructs the list of still attachable instances, remaining task dependencies, in-transit tasks, and memory ledger from the record, and removes events that have occurred from the list of events to be predicted. Completed phases are no longer scheduled for execution; in-transit phases are updated with their remaining completion time based on the current execution duration; and phases not yet started are updated with their estimated start and completion times based on remaining task dependencies and corresponding execution time. Ad slots not yet in the viewport are updated with their current scroll position to indicate subsequent expected exposure windows.
[0162] During re-evaluation, both the continue and stop schemes start from the rebuilt state. The continue scheme executes the remaining recycling, reservation, and candidate ad phases; the stop scheme does not initiate subsequent candidate ad phases, maintains other remaining allocations, and continues processing the end and actual release of already initiated phases. Cancelled instances in the stop scheme are not restored as hookable instances, released operations that have been issued and are in progress continue to be processed according to feedback, and replacement operations that have not yet been issued are stopped from being issued. Both schemes use the same subsequent trajectories and time consumption samples, and keep the events and states that have occurred unchanged. The extrapolation can read a copy of the execution state record in the terminal worker thread, and when the results return to the serial event queue, it checks whether any new events affecting the comparison have been added during the process; if such events exist, the updated state is used for re-evaluation, and the results in the old state are not directly used for the current replacement.
[0163] Table 7 presents two independent subsequent calculation conditions, both assuming that the instance of ad slot B has been canceled and cannot be re-ready within the remaining window, the retained instance remains valid, and the effective exposure probability of the target ad slot after attachment remains 0.60. In the stop plan, the effective exposure probability of ad slot C is set to 0.40, therefore the subsequent expected exposure revenue of the stop plan is 0.00720 yuan plus 0.00400 yuan, i.e., 0.01120 yuan. The incurred loss from ad slot B is reflected in both the continue and stop plans and will not be deducted again only for the continue plan.
[0164] Table 7. Examples of Continuing and Stopping Calculations Based on Actual Remaining State
[0165] Subsequent calculation conditions The probability of candidate ad instances becoming ready first in the continuing scheme. Continue with the effective exposure probability of ad slot C in the plan Continued revenue from the plan, yuan Stop the plan's revenue, yuan Execute action Condition 1 0.25 0.08 0.01070 0.01120 Undo Replace Condition 2 0.50 0.10 0.01360 0.01120 Continue replacing
[0166] In condition one, the continued revenue for the target ad slot is 0.25 multiplied by 0.01800 yuan plus 0.75 multiplied by 0.00720 yuan, resulting in 0.00990 yuan. Adding the 0.00080 yuan from ad slot C, we get 0.01070 yuan, which is less than the stop plan. Therefore, the replacement is cancelled. In condition two, the continued revenue for the target ad slot is 0.50 multiplied by 0.01800 yuan plus 0.50 multiplied by 0.00720 yuan, resulting in 0.01260 yuan. Adding the 0.00100 yuan from ad slot C, we get 0.01360 yuan, which is greater than the stop plan. Therefore, the replacement continues. Although the continued revenue in condition two is lower than the 0.01600 yuan before the recovery, it cannot be stopped because the state before the recovery is no longer a stop plan that can be directly maintained at this point. The ready probability of a candidate ad instance in Table 7 represents the probability of selecting a branch of the candidate ad instance in the continuation scheme, and is calculated separately from the effective exposure probability after the instance is attached; both are dimensionless values. The probabilities in Table 7 are example inputs for calculation.
[0167] When a target ad placement actually enters the viewport, the entry event directly determines the exposure branch for this instance, without waiting for subsequent revenue calculations to complete; the revenue calculation results can only apply to replacements that have not yet ended. When a candidate ad instance passes the readiness check and completes the allocation switch, the decision to continue or stop this replacement ends, and subsequent attachment and release confirmations continue to be executed according to the exposure status and resource processing status, respectively. The same successful replacement will not be converted to a retained instance branch after the retained instance has already been dereferenced. If the candidate ad instance readiness check has been completed beforehand, it will be processed as a candidate ad allocation; if the entry event is prior, the retained instance branch will be used. If the attachment check finds that an already allocated ad has expired, the instance will not be attached, and the corresponding opportunity will be processed as if no effective exposure was generated.
[0168] When the actual demand for a stage exceeds the remaining reserved amount, the next stage is paused before allocation, and the remaining additional memory demand for the stage is recalculated. In one parameter change condition of the main embodiment, after decoding, the current actual usage is 56 MiB, the unallocated reserved amount is 4 MiB, and the available memory is 4 MiB. If the new demand for the next stage and the remaining output is calculated to be 7 MiB based on the determined number of layout nodes, then the additional amount is 7 MiB minus 4 MiB, resulting in 3 MiB. If the benefit of continuing the scheme is still greater than that of stopping the scheme and the available memory can cover 3 MiB, the reserved amount is added in a protected allocation operation, and the ledger becomes 56 MiB actually used, 7 MiB reserved but not allocated, and 1 MiB available, before further allocation is allowed.
[0169] If the newly calculated demand under the same state is 9 MiB, and the required additional quota is 5 MiB, which is greater than the current 4 MiB of available memory, then the replacement and release of the 4 MiB of originally reserved quota that was not actually allocated will be cancelled; the working area and decoding output will still be processed according to the completion of reading and actual release confirmation. If the benefit of continuing the plan is not greater than that of stopping the plan, the same cancellation process will also be performed, and the startup will not continue due to temporary sufficient memory. Each execution stage is allocated through the reserved quota, and implicit allocation cannot be completed beyond the quota first, and then the result of exceeding the quota cannot be registered afterwards.
[0170] The replacement identifier is generated when a replacement is established and persists throughout the phase completion, instance readiness, read completion, and release confirmation stages. The undo command puts a phase that has not yet started into an undo state; phases in transit continue execution until the implementation-allowed read completion position. For implementations supporting chunked decoding, reading can stop after the current block completes; for implementations that only return at the end of the entire phase, they wait for the phase to end. Both undo and redo remove the read reference based on the actual read completion event. If a candidate ad instance returns to the readiness event only after undo, the reference to the corresponding candidate ad instance is released, without changing the already determined display instance; if no display instance has been selected yet, the existing allocation of the reserved instance is maintained, awaiting the actual viewport entry event.
[0171] Resource processing status and exposure opportunity status are recorded separately. Even if an exposure opportunity has ended, the associated replacement may still be in a finishing stage or have memory awaiting actual release. The resource processing continues until all corresponding in-transit stages have ended and all objects awaiting release have been confirmed. Asynchronous interfaces associate processing records with replacement identifiers, event types, and corresponding object identifiers. Stage events are also associated with the aforementioned stage identifiers; the status is updated only once for the same completed or released notification. Events from different stages are registered separately; duplicate notifications do not deduct from memory usage again, nor do they repeatedly terminate the current display relationship.
[0172] like Figure 7 As shown, the terminal defines a single continuous period within the viewport as an exposure opportunity. To prepare for the next exposure opportunity, the terminal establishes an exposure opportunity record and an exposure opportunity identifier when associating with the pre-rendering task, initially in the "awaiting entry" state; upon actual entry into the viewport, the instance selection is recorded and the state changes to "selected"; upon actual exit from the viewport, the state changes to "completed." When an instance ready event arrives, a ready verification event for the candidate ad instance is generated and placed in the same serial event queue as the viewport entry event; within the same processing batch, the viewport entry event is processed first, followed by the ready verification event. The readiness of a candidate ad instance is determined by the completion of the ready verification and the registration of its attachable state; the instance reference cannot be prematurely released based on the moment when an asynchronous thread completes its verification earlier but has not yet finished.
[0173] When the same batch contains both instance readiness checks and viewport entry events, the instance to be retained is selected based on the viewport entry event, and the exposure opportunity is changed to the selected state. Subsequent readiness checks do not replace the displayed instance. If a candidate ad instance has already passed the check and completed the allocation transfer in the previous batch, subsequent viewport entry events use the currently allocated candidate ad instance. The currently displayed instance is maintained in the selected state until the ad slot exits the viewport, at which point the display reference is removed and it is changed to the ended state. Re-entering the viewport corresponds to a new exposure opportunity, and the selection result of the ended opportunity is not reused. Revenue projection uses the same event priority rule to avoid the projection counting the same batch as candidate ad exposures while using the retained instance during execution.
[0174] When a page uses a reusable ad container, the display binding record includes the page identifier, ad slot identifier, binding generation, and impression opportunity identifier. The instance-ready event is associated with the display binding record initiated during pre-rendering. When the container is rebound from ad slot A to another ad slot, the original impression opportunity ends, the original display reference is released, the binding generation is incremented, and a new display binding record is established. For example, if the old event carries the page identifier P, ad slot A, binding generation 7, and impression opportunity identifier A1, and the container is already bound to ad slot B, binding generation 8, and impression opportunity identifier B1, even if the old event subsequently returns, the allocation of ad slot B cannot be updated based on the old event.
[0175] When processing an instance ready event, the terminal compares the page identifier, ad slot identifier, binding generation, and exposure opportunity identifier item by item, and verifies whether the current exposure opportunity is in a pending state and whether the corresponding replacement has not been revoked. It also performs verification according to the aforementioned instance ready and validity period conditions. If all conditions are met, the allocation is updated; if the conditions are not met, the reference to the candidate ad instance corresponding to the event is removed, and the current container allocation is maintained. The same instance ready event that has already been processed by the serial queue will not re-enter the binding process. The candidate ad instance reference held by the event log and the current display reference of the container are registered separately. Resource cleanup of old events is not used as an instruction to remove other binding relationship display references.
[0176] like Figure 8 As shown, when multiple replacement schemes execute concurrently, each replacement identifier is associated with its respective instance reference, read reference, and shared pre-rendering stage usage relationship. The cache item identifier and allocation identifier jointly determine the actual occupied object. When the same cache item forms a new memory allocation due to reallocation, the new allocation identifier is used, and the release confirmation of the old allocation only corresponds to the old allocation record. When multiple replacement schemes share a registered actual allocated object, the shared memory ledger only calculates the actual occupation once. Each scheme records the usage relationship, and the total number of bytes of the shared object cannot be regarded as the exclusive reclaimable amount of each scheme.
[0177] For example, alternative schemes D and E share a 6MiB decoding output. Both schemes hold instance references, and one of them, a shared pre-rendering stage, still holds a read reference to the output, which also has a cached reference. When alternative scheme D is revoked, the instance references of D that are no longer in use are released, and the unstarted layout stage that only serves D is stopped; the read references of the in-transit stage to which D belongs are still retained until the actual read ends. When E still uses the shared pre-rendering stage, the shared pre-rendering stage continues to execute, the shared read references are retained, and the actual 6MiB occupancy is maintained. After the references corresponding to D have been released according to the aforementioned conditions, the allocator releases the output only after the instance references, shared pre-rendering stage read references, and cached references of E have also been released; the shared available memory increases only once after the 6MiB release confirmation arrives. Shared objects still held by E are not registered as pending confirmation objects for which D has initiated release; the completion of resource processing for D is based on the in-transit stage to which D belongs and the objects for which D has issued release requests. The idle worker threads caused by the termination of the exclusive phase of Ding, as well as the resource changes caused by the completion or final release of the shared pre-rendering phase, are all fed back to the current allocation and continue / stop comparison of Wu.
[0178] When concurrent schemes require additional reservations or re-admission, checks and reservations are performed sequentially according to the shared memory ledger. A single release can trigger re-checks for multiple waiting schemes, but the same available memory can only be successfully reserved once. The subsequent benefit comparison of each scheme is based on its own past events and shared actual resource status, retaining references still held by other schemes and established reservation records. This embodiment uses single-scheme successive admission and shared execution feedback, and does not replace the original selection criteria of each scheme with the combined benefits of multiple schemes.
[0179] Table 8 provides an example of calculating the memory admission boundary, maintaining the current actual usage after reclamation at 36 MiB and the peak new memory at 24 MiB, only changing the memory capacity available for ad pre-rendering. The values in the table are used to test actions when available memory is less than, equal to, and greater than the peak new memory; other memory capacities are determined using the same calculation process. This example tests the admission judgment boundary, and does not set 59 MiB to 61 MiB as the method's memory capacity range.
[0180] Table 8 Example of memory admission boundary calculation
[0181] Memory capacity, MiB Reclaimed memory available, MiB New peak memory usage, MiB Admission Results Reserved available memory, MiB 59 23 24 Do not enable candidate ad pre-rendering 23 60 24 24 Start after one reservation 0 61 25 24 Start after one reservation 1
[0182] In boundary calculations, zero available memory after reservation only indicates that the controlled ad pre-rendering quota has been fully allocated, and the page container and necessary state processing usage have been included in the current actual usage. It does not mean that all available memory on the entire terminal should be allocated to the ad budget. When changing ad output specifications, allowed parallelism, fixed occupancy items, or budget capacity, the corresponding calculations and admissions must be re-executed; only changing the capacity in the table while omitting other occupancy that changes with implementation conditions is not acceptable. The method does not treat specific memory capacity, image size, or effective exposure duration as fixed parameters that must be maintained.
[0183] In one alternative implementation, an off-screen execution environment is employed that allocates and releases memory objects one by one, suitable for terminals where the execution layer can obtain allocation receipts for each buffer and output object, but does not use the unified page pool of the main embodiment. The allocator establishes an allocation identifier for each memory object and returns the actual number of bytes. Material acquisition, decoding, and layout still first obtain the corresponding reserved quota before allocation; available memory is updated based on the controlled allocation capability that has already been confirmed for release. The allocator ensures that full quota admission is used when the reserved quota covers the allocation conditions of subsequent object requests, and cannot presume that objects of any size can be allocated solely based on the total remaining memory of the process.
[0184] For objects read asynchronously during rendering, the read completion notification and the actual release confirmation are separate. For example, if an output object occupies 6 MiB, the display reference is released at 100 milliseconds, the rendering read ends at 120 milliseconds, and at that moment the last read reference of the object is released, and all other references are also released. The allocator returns a release confirmation at 125 milliseconds. Therefore, the actual occupancy remains at 6 MiB from 100 milliseconds to 125 milliseconds, and only after 125 milliseconds is the available memory increased. The page pool return confirmation in the main embodiment and the object release confirmation in this optional method share the same technical basis, both based on the actual realizable memory. The specific receipt and allocation granularity used are determined by the execution environment. Encapsulated objects for which actual allocation or release information cannot be obtained are treated as continuously fixed-occupancy objects. When the occupancy boundary of the encapsulated object cannot be determined, the corresponding object is not included in the replacement path with calculable reclamation volume.
[0185] In another alternative implementation, a defined page progression plan and stage execution time are used as the simulation input. This approach is suitable for quick app ad pages with fixed page layouts and subsequent page transitions controlled by the terminal at set times. The terminal directly generates the expected exposure window for each ad slot based on the pre-scheduled page transition times and establishes a defined task execution trajectory for calculation according to the same terminal and the same output specification stage calibration time. The current allocation and replacement scheme maintains the same time input, retains the recovery status of events that have occurred in the failed branches, and re-evaluates the actual allocation from the updated actual allocation when the actual transition or stage event deviates from the plan.
[0186] For example, if an ad slot is scheduled to enter the viewport in 800 milliseconds, with a 60-millisecond wait time for recycling, and the material acquisition, decoding, and layout times are set to 100 milliseconds, 200 milliseconds, and 80 milliseconds respectively, and the candidate ad instance is expected to be ready in 440 milliseconds when the memory access condition is met, the candidate ad instance branch is selected based on the deduction. If the actual page switch occurs earlier than 300 milliseconds, and the candidate ad instance has not yet passed the readiness check, then the retained instance branch is executed and the subsequent stages are stopped. The optional method does not require averaging multiple random trajectories and is applicable to pages with definite advancement conditions. It shares the reference recycling, actual memory confirmation, branch exposure, and execution feedback mechanisms with the main embodiment. For pages that users can freely scroll, the trajectory samples and corresponding conditions of the main embodiment are used for prediction, and the fixed advancement time is not directly applied.
[0187] The outputs of the main embodiment and optional implementations include the allocation relationship between ad slots and display instances, the status of selected or ended exposure opportunities, the continuation or cancellation status of each replacement, and a memory ledger maintained according to actual allocation and release. Expected exposure revenue determines the computational load of these actions; actual revenue still depends on subsequent actual exposure and ad service confirmation. Page processing, pre-rendering tasks, cache reclamation, and resource feedback all target ad slot instance preparation and exposure execution, forming the ad allocation and pre-rendering control process in internet advertising services.
[0188] It should be noted that the embodiments of the present invention have better implementability and are not intended to limit the present invention in any way. Any person skilled in the art may use the above-disclosed technical content to change or modify it into equivalent effective embodiments. However, any modifications or equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention shall still fall within the scope of the technical solution of the present invention.
Claims
1. A method for dynamic pre-rendering and exposure revenue optimization of multiple ad slots in quick apps, applied to internet advertising services, characterized in that... Executed by the terminal running the quick app, including: Obtain the expected exposure window of multiple ad slots, the validity period of matching ads, and the estimated revenue per thousand impressions; determine the candidate ads and ready-to-retain instances for the target ad slots; and build a pre-rendering task graph for the candidate ads. Determine the peak memory usage for pre-rendering and generate a replacement scheme that includes candidate ads and a recycling set; the recycling set consists of references and covers all references to cache items to be released, and the release of each reference is independent of the release of candidate ad instances and the release of references to reserved instances; For target ad placements and ad placements affected by changes in recycling or task waiting, the expected exposure revenue of maintaining the current allocation and implementing the replacement plan is deduced based on the estimated revenue per thousand impressions; in the deduction branch where the target ad placement first enters the viewport, the deduced reference removal and instance cancellation status are retained, the expected exposure revenue of other affected ad placements is calculated, and the replacement plan with the increased total expected exposure revenue is selected. Perform recycling, confirm the updated available memory based on the actual memory release, and reserve the corresponding memory and start pre-rendering once when the instance continues to occupy memory and the available memory meets the peak of the new memory. From the start of recycling to the end of replacement, the current allocation is updated based on the reference release, instance cancellation and actual memory release that have occurred. The expected exposure benefits of continuing replacement and stopping replacement are compared based on the updated allocation. If the former is not greater than the latter, the replacement is canceled and the subsequent stages are stopped. When a candidate ad instance that has not been revoked is ready, the allocation is switched and the reserved instance reference is released. When the target ad position enters the viewport, the still valid candidate ad instance is attached. When the target ad position enters the viewport first, the still valid reserved instance is attached, the unstarted phase is revoked, and the memory of in-transit tasks and unconfirmed released cache items is continuously calculated.
2. The method according to claim 1, characterized in that, The generation of the recycling set includes: The cache item is determined by the material content identifier and output specification, and the instance reference held by the advertisement instance, the read reference held during the execution phase, and the cache holding reference are recorded for the cache item; Starting from the instance reference of the ad instance to be recycled, find other references of the cache item corresponding to the instance reference, and add the references that can be released by canceling the corresponding ad instance, ending the reading phase, or releasing the cache holding relationship to the recycling set, until all references of the corresponding cache item are covered; When a corresponding cache item contains a reference to the reserved instance, or when the release of any reference depends on the completion of the pre-rendering of the candidate advertisement, the corresponding cache item will be excluded from the cache items to be released. The cache items to be released are deduplicated according to their identifiers, and the amount of releasable memory corresponding to the reclaimed set is determined.
3. The method according to claim 2, characterized in that, The determination of the newly added memory peak includes: The pre-rendered task graph is divided into material acquisition stage, decoding stage and layout stage, and the dependencies, execution memory requirements and output memory requirements of each stage are recorded. Set the existing cached items that the candidate ads will continue to use as fixed-occupancy items, and keep the references to the fixed-occupancy items until the end of the corresponding usage phase; Based on the dependencies and the parallel relationships allowed by the pre-rendering execution end, determine the combination of stages that can be executed simultaneously, merge the same memory objects passed across stages according to the memory object identifier, calculate the additional memory requirement of each stage combination relative to the current usage, and determine the maximum value among them as the peak value of the additional memory. The available memory is obtained by subtracting the current actual usage and the amount of memory reserved but not yet allocated from the memory capacity used for ad pre-rendering. The fixed usage item and the memory occupied by the reserved instance are included in the current actual usage.
4. The method according to claim 1, characterized in that, The projection of the expected exposure revenue includes: Record the allocation reference between the ad slot and the ad instance, as well as the display reference during the period when the ad instance is attached to the ad slot in the viewport; The process of an ad slot being continuously within the viewport is defined as an exposure opportunity. The order of ad instance readiness and ad slot entry into the viewport is determined based on the expected exposure window and the pre-rendered task graph. For branches where candidate ad instances are ready first, update the reference status in the order of first transferring the allocation reference of the target ad slot to the candidate ad instance, and then releasing the allocation reference of the reserved instance; For the branch where the target ad slot enters the viewport first, establish a display reference for the reserved instance, maintain the display reference until the target ad slot exits the viewport, and stop the subsequent pre-rendering stage of the candidate ad from starting; Based on the attachable status of the ad instance in the corresponding branch, the validity period of the corresponding ad, and the probability of meeting the preset effective exposure conditions after attaching, the probability of the ad instance forming effective exposure is determined. The probability of forming effective exposure is multiplied by the estimated revenue per thousand exposures of the corresponding ad and then divided by one thousand to obtain the expected exposure revenue of the corresponding exposure opportunity. For the same exposure opportunity, select a projection branch according to the aforementioned sequence relationship, determine the expected exposure revenue of the exposure opportunity based on the display instances in the selected projection branch, and summarize the expected exposure revenue of each exposure opportunity.
5. The method according to claim 4, characterized in that, The projection of expected exposure revenue further includes: Obtain samples of page scrolling trajectory and samples of pre-rendering time consumption associated with terminal resource configuration records; In one simulation, the same page scroll trajectory sample is applied to each ad placement under the same page layout version to determine the time when each ad placement enters and exits the viewport, and the same pre-rendering stage time sample is used to maintain the current allocation and execute the replacement scheme. Based on the reference removal time and memory availability time in each scheme, update the startup time and ad instance readiness time of the subsequent stages respectively; The expected exposure gains obtained from each simulation are averaged, and the average expected exposure gains are compared with those of maintaining the current allocation and implementing the replacement plan.
6. The method according to claim 2, characterized in that, The generation and selection of the replacement scheme includes: From the ads that match the target ad slot, select candidate ads whose estimated revenue per thousand impressions is greater than the estimated revenue per thousand impressions of the ad corresponding to the retained instance, and whose validity period overlaps with the expected exposure window. For each candidate ad, multiple recycling sets are generated that cover all references of the cache items to be released. Each candidate ad is combined with its corresponding recycling set, and combinations that are less than the peak value of the corresponding new memory are excluded. The remaining target ad slots involved in each combination, as well as the ad slots affected by instance cancellation, removal of shared cache items, or changes in task waiting, are combined to form a common evaluation set; Within the common evaluation set, the expected exposure gains of maintaining the current allocation and executing each remaining combination are respectively deduced, and the replacement scheme is determined from the combinations that increase the total expected exposure gains relative to maintaining the current allocation.
7. The method according to claim 4, characterized in that, In the deduction branch where the target ad placement first enters the viewport: Record the moments when references are removed, ad instances are canceled, and cached items become unavailable, according to the execution order in the simulation. When stopping the subsequent pre-rendering stage of the candidate advertisement, the reference release and advertisement instance cancellation states that have been deduced before the stop start time are maintained, and the release time of the read reference held by the in-transit stage is determined according to the remaining execution time of the in-transit stage; For other ad slots affected by the reclaimed set, the readiness time of the ad instance is re-determined based on the remaining cache items, the remaining pre-rendering stage, and the updated available memory time. The changes in stage re-execution and startup wait caused by the removal of the shared cache item are propagated to the ad instances that use the shared cache item or the ad slots associated with the pre-rendering stage, and the expected exposure revenue of the corresponding exposure opportunity is calculated according to the redefined ad instance readiness time.
8. The method according to claim 7, characterized in that, Updating the current allocation and comparing subsequent expected exposure revenue includes: Record the events that have occurred, such as referral removal, ad instance cancellation, phase completion, ad slot entering the viewport, and actual memory release confirmation, to form an execution status record; Based on the execution status record, determine the ad instances that can still be attached, the remaining task dependencies, the in-process stages, and the actual memory usage, and reconstruct the current allocation; Starting from the current reconstructed allocation, we construct a continuation plan to continue executing the remaining replacement operations, and a stop plan to stop initiating subsequent stages of candidate ads and maintain the remaining allocation. In the continued and stopped scenarios, the events and corresponding states recorded in the execution state record are maintained, and the subsequent reference release, memory release and ad instance readiness time are deduced respectively. The expected exposure revenue is compared within the same set of ad slots and the same subsequent exposure opportunities. When the expected exposure gain of the continued plan is not greater than that of the stopped plan, the replacement is cancelled; when the target ad slot enters the viewport before the candidate ad instance is ready, the exposure branch corresponding to the retained instance is executed.
9. The method according to claim 2, characterized in that, Before executing the collection, perform release dependency checks, including: A release dependency graph is established with nodes representing reference dereferencing, end of the read phase, release of cached items, and the pre-rendering phase to be started. Directed edges are set according to the relationship that the end of the reading phase precedes the release of the reading reference, and the release of all cached item references precedes the release of the corresponding cached item. Directed edges are also set according to the relationship that the start of the pre-rendering phase precedes the end of the reading phase that depends on the start of the corresponding phase. For the pre-rendering stage where the memory required for startup must be provided by a specified cache item to be released, a directed edge is set according to the relationship that the specified cache item to be released is released before the corresponding pre-rendering stage starts. When the release dependency graph contains a directed loop that includes a pre-rendering phase to be started, the corresponding replacement scheme is excluded, and the selection is re-executed from the remaining replacement schemes; if the remaining replacement schemes are empty, the current allocation is maintained.
10. The method according to claim 3, characterized in that, The memory reservation and pre-rendering startup include: In the same memory allocation operation, check available memory and establish a reservation record to cover the newly added memory peak. After successful reservation, start pre-rendering. Each pre-rendering stage obtains the memory quota from the reserved record. After successful memory allocation, the corresponding quota is transferred from the reserved but not yet actually allocated memory to the actual occupied memory. When the demand for memory objects to be allocated in the next stage exceeds the remaining quota of the reserved record, the next stage is paused, the new memory demand for the remaining stage is re-determined, the additional quota is determined by the portion of the re-determined new memory demand that exceeds the remaining quota, and the expected exposure revenue of continuing replacement versus stopping replacement is re-compared. If the expected exposure benefits of continuing the replacement are greater than those of stopping the replacement, and the available memory can cover the additional quota, then the additional quota is reserved in a single memory allocation operation; otherwise, the replacement is cancelled, and the reserved but not yet allocated memory quota is released.
Citation Information
Patent Citations
Energy-efficient content serving
US10410252B2
