Resource modification method and apparatus, electronic device, storage medium, and program product
Patent Information
- Application Number
- CN202510528336.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2026-10-27
AI Technical Summary
[0004]然而,锁机制存在开销大的问题,降低软件系统的并发性能,导致软件系统的性能低
[0031]本申请实施例提供的资源修改方法、装置、电子设备、存储介质及程序产品,方法包括:接收资源修改请求,所述资源修改请求包括目标资源标识和目标修改信息;根据所述资源修改请求,确定所述目标资源标识对应的目标资源和目标脉冲时钟;将所述目标资源标记为不可用状态;根据所述目标脉冲时钟对所述目标资源对应的任务进行检测处理,得到所述目标资源对应的任务的完成时刻;在所述完成时刻根据所述目标修改信息对所述目标资源进行修改处理,得到修改资源。以上方案,通过脉冲时钟机制确定进行修改处理的完成时刻,在完成时刻进行修改处理可以避免访问冲突,相比于锁机制,可以降低开销,从而提升系统性能。
Smart Images

Figure CN122985437A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a resource modification method, apparatus, electronic device, storage medium, and program product. Background Technology
[0002] In software systems, resource management and task scheduling are among the core technical challenges. As system complexity increases, how to efficiently and securely manage shared resources (including but not limited to files or data) and ensure coordination and consistency between tasks becomes a critical issue.
[0003] In related technologies, resource management methods typically use locking mechanisms to avoid resource access conflicts and ensure the security of resource access.
[0004] However, locking mechanisms have the problem of high overhead, which reduces the concurrency performance of the software system and leads to low system performance. Summary of the Invention
[0005] This application provides resource modification methods, apparatus, electronic devices, storage media, and program products to improve system performance.
[0006] In a first aspect, embodiments of this application provide a resource modification method, comprising: receiving a resource modification request, the resource modification request including a target resource identifier and target modification information; determining a target resource and a target pulse clock corresponding to the target resource identifier according to the resource modification request; marking the target resource as unavailable; performing detection processing on the task corresponding to the target resource according to the target pulse clock to obtain the completion time of the task corresponding to the target resource; and modifying the target resource according to the target modification information at the completion time to obtain the modified resource.
[0007] Optionally, in the method described above, the resource modification request includes a request timestamp; the detection processing of the task corresponding to the target resource according to the target pulse clock to obtain the completion time of the task corresponding to the target resource includes: determining the target detection period corresponding to the target pulse clock; and determining the completion time according to the request timestamp and the target detection period.
[0008] Optionally, the method described above, determining the completion time based on the request timestamp and the target detection period, includes: determining the request time corresponding to the request timestamp; at the request time, determining the original pulse clock value of the target pulse clock, the original pulse clock value representing the completion status of the task corresponding to the target resource at the request time; starting from the request time, sequentially determining multiple detection times according to the target detection period, and sequentially determining the detection pulse clock value of the target pulse clock at each detection time, until the detection pulse clock value at any detection time is different from the original pulse clock value, then determining the detection time as the completion time.
[0009] Optionally, the method described above further includes: determining a count value of the detection time between the current time and the requested time; obtaining a count value threshold; performing verification processing on the count value according to the count value threshold to obtain a first verification result, wherein the first verification result is either verification passed or verification failed; if the first verification result is verification failed, then allocating computing resources for executing the task.
[0010] Optionally, the method described above, after marking the target resource as unavailable, further includes: determining at least one currently used module that is using the target resource; generating first status information based on the unavailable status; and sending the first status information to the at least one used module, so that the at least one used module stops generating tasks that use the target resource during the execution of the resource modification request.
[0011] Optionally, the method described above, determining at least one used module currently using the target resource, includes: determining the task queue of the target resource based on the target resource identifier, the task queue including at least one queued task; and determining the module that generates the at least one queued task as the at least one used module.
[0012] Optionally, the method described above further includes: analyzing and processing the at least one queued task to obtain the task generation pattern of the at least one used module generating queued tasks; determining the periodically used module that periodically generates tasks from the at least one used module according to the task generation pattern; performing a copying process on the target resource to obtain a resource copy, and sending the resource copy to the periodically used module so that the periodically used module can read the resource copy in advance.
[0013] Optionally, the method described above further includes: obtaining the current load and a load threshold; performing verification processing based on the current load and the load threshold to obtain a second verification result, wherein the second verification result is either verification passed or verification failed; and if the second verification result is verification failed, allocating computing resources for executing the task.
[0014] Optionally, the method described above further includes: determining multiple tasks to be executed corresponding to the target resource; merging the multiple tasks to be executed that have the same resource access type to obtain multiple merged tasks; and replacing the multiple tasks to be executed with the multiple merged tasks.
[0015] Optionally, the method described above, after modifying the target resource to obtain the modified resource, further includes: marking the resource status of the target resource as available; generating second status information based on the target resource identifier and the available status; and sending the second status information to at least one used module so that the at least one used module generates a task using the target resource.
[0016] Secondly, embodiments of this application provide a data sharing device, comprising: a receiving module for receiving a resource modification request, the resource modification request including a target resource identifier and target modification information; a determining module for determining a target resource corresponding to the target resource identifier and a target pulse clock according to the resource modification request; a marking module for marking the target resource as unavailable; a detection module for detecting and processing the task corresponding to the target resource according to the target pulse clock to obtain the completion time of the task corresponding to the target resource; and a modification module for modifying the target resource according to the target modification information at the completion time to obtain the modified resource.
[0017] Optionally, in the apparatus described above, the resource modification request includes a request timestamp; the detection module is specifically configured to determine the target detection period corresponding to the target pulse clock; the detection module is further configured to determine the completion time based on the request timestamp and the target detection period.
[0018] Optionally, in the apparatus described above, the detection module is specifically configured to determine the request time corresponding to the request timestamp; the detection module is further configured to determine the original pulse clock value of the target pulse clock at the request time, the original pulse clock value representing the completion status of the task corresponding to the target resource at the request time; the detection module is further configured to, starting from the request time, sequentially determine multiple detection times according to the target detection cycle, and sequentially determine the detection pulse clock value of the target pulse clock at each detection time, until the detection pulse clock value at any detection time is different from the original pulse clock value, then the detection time is determined as the completion time.
[0019] Optionally, the apparatus as described above further includes: a first verification module, configured to determine a count value of the detection time between the current time and the requested time; the first verification module is further configured to obtain a count value threshold, and perform verification processing on the count value according to the count value threshold to obtain a first verification result, wherein the first verification result is either verification passed or verification failed; the first verification module is further configured to allocate computing resources for executing the task if the first verification result is verification failed.
[0020] Optionally, the apparatus as described above further includes: a sending module, configured to determine at least one currently used module that is using the target resource; the sending module is further configured to generate first status information based on the unavailability status; the sending module is further configured to send the first status information to the at least one used module, so that the at least one used module stops generating tasks using the target resource during the execution of the resource modification request.
[0021] Optionally, in the apparatus described above, the sending module is specifically configured to determine the task queue of the target resource based on the target resource identifier, the task queue including at least one queued task; the sending module is further configured to determine the module that generates the at least one queued task as the at least one used module.
[0022] Optionally, the apparatus as described above further includes: a prediction module, configured to analyze and process the at least one queued task to obtain a task generation pattern of the at least one used module generating queued tasks; the prediction module is further configured to determine a periodically used module that periodically generates tasks from the at least one used module according to the task generation pattern; the prediction module is further configured to perform a copying process on the target resource to obtain a resource copy, and send the resource copy to the periodically used module so that the periodically used module can read the resource copy in advance.
[0023] Optionally, the apparatus as described above further includes: a second verification module, configured to obtain the current load and a load threshold; the second verification module is further configured to perform verification processing based on the current load and the load threshold to obtain a second verification result, wherein the second verification result is either verification passed or verification failed; the second verification module is further configured to allocate computing resources for executing the task if the second verification result is verification failed.
[0024] Optionally, the apparatus as described above further includes: a merging module, configured to determine multiple tasks to be executed corresponding to the target resource; the merging module is further configured to merge the multiple tasks to be executed that have the same resource access type to obtain multiple merged tasks; the merging module is further configured to replace the multiple tasks to be executed with the multiple merged tasks.
[0025] Optionally, the apparatus as described above further includes: a prompting module, configured to mark the resource status of the target resource as available; the prompting module is further configured to generate second status information based on the target resource identifier and the available status; the prompting module is further configured to send the second status information to at least one used module, so that the at least one used module generates a task using the target resource.
[0026] Thirdly, embodiments of this application provide a resource modification device, including: a memory and a processor;
[0027] The memory stores computer-executed instructions;
[0028] The processor executes computer execution instructions stored in the memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.
[0029] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.
[0030] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.
[0031] The resource modification method, apparatus, electronic device, storage medium, and program product provided in this application include: receiving a resource modification request, the resource modification request including a target resource identifier and target modification information; determining a target resource and a target pulse clock corresponding to the target resource identifier based on the resource modification request; marking the target resource as unavailable; performing detection processing on the task corresponding to the target resource according to the target pulse clock to obtain the completion time of the task corresponding to the target resource; and modifying the target resource according to the target modification information at the completion time to obtain the modified resource. This scheme, by determining the completion time of modification processing through a pulse clock mechanism, avoids access conflicts and reduces overhead compared to locking mechanisms, thereby improving system performance. Attached Figure Description
[0032] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0033] Figure 1 This is a schematic diagram illustrating an application scenario of a resource modification method provided in an embodiment of this application;
[0034] Figure 2 A flowchart illustrating a resource modification method provided in an embodiment of this application;
[0035] Figure 3 A flowchart illustrating a resource modification method provided in an embodiment of this application;
[0036] Figure 4 A schematic diagram of task detection provided for an embodiment of this application;
[0037] Figure 5 A schematic diagram of a pulse clock provided for an embodiment of this application;
[0038] Figure 6 A schematic diagram of resource tags provided in an embodiment of this application;
[0039] Figure 7 This is a schematic diagram of the structure of a resource modification device provided in an embodiment of this application;
[0040] Figure 8 This is a schematic diagram of the structure of a resource modification device provided in an embodiment of this application;
[0041] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0042] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0043] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0044] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, processing, transmission, provision, disclosure, and application of the relevant data all comply with the relevant laws, regulations, and standards of the relevant countries and regions, have taken necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation portals for users to choose to authorize or refuse.
[0045] It should be noted that the resource modification methods, apparatus, electronic devices, storage media, and program products of this application can be used in the field of data processing technology, or in any field other than data processing. The application fields of the resource modification methods, apparatus, electronic devices, storage media, and program products of this application are not limited.
[0046] Figure 1 This is a schematic diagram illustrating an application scenario of a resource modification method provided in an embodiment of this application. The system includes resources and multiple resource usage modules. These modules can share and use the resources, each module can access the resources, and each module completes a specific task based on the resources.
[0047] Optionally, the access method can include modification type or non-modification type. Modification type will change the current resource, while non-modification type will not change the current resource.
[0048] For example, if any resource-using module modifies a resource, it will affect the access of other resource-using modules to the resource at the same time.
[0049] In related technologies, locking mechanisms are used to prevent access exceptions. For example, when a resource-using module needs to delete a resource, it needs to hold a lock to delete it, while other resource-using modules also need to hold a lock to read or write the resource. If deletion is performed directly, it will cause an exception to the resource-using module that is currently accessing it.
[0050] However, acquiring and releasing locks requires processing by the system kernel. Furthermore, when a resource-using module attempts to acquire a lock that is already held, it will be blocked and enter a waiting state. This blocking prevents the module from continuing its current task. These issues increase system overhead, thereby reducing system performance.
[0051] The method for modifying resources provided in this application is intended to solve the above-mentioned technical problems in the prior art.
[0052] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0053] Figure 2 This is a flowchart illustrating a resource modification method provided in an embodiment of this application. The method includes the following steps:
[0054] S201. Receive a resource modification request. The resource modification request includes the target resource identifier and the target modification information.
[0055] Optionally, the resource modification request is generated by the resource management module and is used to trigger modification processing on the specified target resource.
[0056] For example, the target resource identifier is a unique identifier for the target resource, used to accurately identify the unique corresponding resource. The target modification information is the specified modification method, such as what content is added or deleted based on the target resource.
[0057] S202. Based on the resource modification request, determine the target resource and target pulse clock corresponding to the target resource identifier.
[0058] For example, a target pulse clock can determine the detection time, and the completion status of the task can be checked periodically according to the detection time.
[0059] With the example scenario, if all tasks corresponding to the target resource are completed, the task status is "completed". These multiple tasks include tasks currently using the target resource and / or tasks queued to use the target resource. The completion of multiple tasks is indicated by a pulse clock value.
[0060] Optionally, if multiple tasks are completed, the pulse clock value is incremented by 1. If any task is not completed, the pulse clock value remains unchanged.
[0061] With the help of scenario examples, by observing whether the pulse clock value changes at a certain moment, it is possible to quickly determine whether a task is using the target resource at that moment, and thus quickly determine whether the resource modification can be performed at that moment.
[0062] Optionally, the target resource and target pulse clock can be determined through a preset mapping relationship. The mapping relationship includes the mapping relationship between resource identifiers and resources, and the mapping relationship between resource identifiers and pulse clocks. The corresponding target resource and target pulse clock can be accurately determined through this mapping relationship.
[0063] S203. Mark the target resource as unavailable.
[0064] For example, after a target resource is marked as unavailable, the tasks currently using the target resource and the queued tasks continue to execute, while new tasks are no longer received.
[0065] With the example scenario, the resource usage module stops generating new tasks that use the target resource after recognizing an unavailable state, which can avoid the situation where continuously generating new tasks makes it impossible to modify the resource.
[0066] S204. Detect and process the task corresponding to the target resource according to the target pulse clock to obtain the completion time of the task corresponding to the target resource.
[0067] For example, a change in the pulse clock value indicates that all tasks using the target resource have been completed, and there are no other tasks to be executed at the corresponding completion time. Modifying the process at the completion time can avoid conflicts with tasks using the target resource.
[0068] S205. At the completion time, modify the target resource according to the target modification information to obtain the modified resource.
[0069] With the scenario example, marking the target resource as unavailable stops the module from generating new tasks. Next, it waits for existing tasks using the target resource to complete. A change in the target pulse clock value indicates the completion of existing tasks. At the completion time, there are neither newly generated tasks nor unexecuted tasks; therefore, modifications made at the completion time will not cause access conflicts to the target resource.
[0070] The resource modification method provided in this application embodiment receives a resource modification request, which includes a target resource identifier and target modification information; based on the resource modification request, it determines the target resource corresponding to the target resource identifier and a target pulse clock; it marks the target resource as unavailable; it performs detection processing on the task corresponding to the target resource according to the target pulse clock to obtain the completion time of the task corresponding to the target resource; and at the completion time, it modifies the target resource according to the target modification information to obtain the modified resource. This scheme, by determining the completion time of modification processing through a pulse clock mechanism, avoids access conflicts and reduces overhead compared to locking mechanisms, thereby improving system performance.
[0071] Based on any of the above embodiments, the following, in conjunction with Figure 3 The detailed process of modifying resources is explained.
[0072] Figure 3 This is a flowchart illustrating a resource modification method provided in an embodiment of this application. Figure 3 As shown, the method includes:
[0073] S301. Receive a resource modification request. The resource modification request includes the target resource identifier and the target modification information.
[0074] It should be noted that the execution process of S301 is the same as that of S201, and will not be repeated here.
[0075] S302. Based on the resource modification request, determine the target resource and target pulse clock corresponding to the target resource identifier.
[0076] It should be noted that the execution process of S302 is the same as that of S202, and will not be repeated here.
[0077] S303, Mark the target resource as unavailable.
[0078] It should be noted that the execution process of S303 is the same as that of S203, and will not be repeated here.
[0079] One feasible implementation, after marking the target resource as unavailable, further includes: identifying at least one currently used module that is using the target resource; generating first status information based on the unavailable status; and sending the first status information to at least one used module so that the at least one used module stops generating tasks that use the target resource during the execution of a resource modification request.
[0080] For example, at least one used module is the module currently accessing the target resource, i.e., the module that is easier to access the target resource again.
[0081] As illustrated by the scenario example, once a resource is marked as unavailable, existing modules may not immediately recognize the mark, leading to conflicts when they continue to access the target resource. Sending a first status message to at least one existing module explicitly instructs it to stop accessing the target resource, thus avoiding access conflicts.
[0082] In this feasible implementation, by explicitly instructing the cessation of access to the target resource, access conflicts can be effectively prevented, thereby improving the reliability of resource modifications.
[0083] One feasible implementation method is to determine at least one used module currently using the target resource by: determining the task queue of the target resource based on the target resource identifier, wherein the task queue includes at least one queued task; and identifying the module that generates at least one queued task as at least one used module.
[0084] Optionally, determine the correspondence between resource identifiers and task queues, and determine the task queue corresponding to the target resource based on the target resource identifier and the correspondence.
[0085] Optionally, the information for each task includes the resource usage module of the source, and at least one used module corresponding to at least one queued task is determined based on the task information.
[0086] In this feasible implementation, by analyzing the task queue and queued tasks, the usage relationship of the target resource can be clearly traced, and it can be accurately determined which modules are accessing the target resource, thereby improving the accuracy of resource modification.
[0087] One feasible implementation method for resource modification further includes: analyzing and processing at least one queued task to obtain the task generation pattern of at least one used module generating queued tasks; determining the periodic use of periodically generated tasks from at least one used module based on the task generation pattern; performing copy processing on the target resource to obtain a resource copy, and sending the resource copy to the periodically used module so that the periodically used module can read the resource copy in advance.
[0088] Optionally, the task generation pattern can include periodically generated tasks. Through analysis and processing, the generation pattern of periodically generated tasks can be obtained, thereby predicting the timing of the next task generation. The periodically used module refers to the module that is predicted to generate tasks periodically and has already been used.
[0089] For example, a resource copy is a resource obtained by copying a target resource, and the resource copy includes specific information about the target resource.
[0090] Optionally, sending a copy of the resource to the periodic usage module allows the periodic usage module to read the target resource in advance. If the periodic usage module can use the target resource, the number of tasks generated by the periodic usage module can be reduced.
[0091] In this feasible implementation, resource preheating allows the periodic module to read data in advance, reducing task queuing and thus improving task execution efficiency.
[0092] One feasible implementation method for modifying resources further includes: obtaining the current load and load threshold; based on the current load and load threshold, the thread performs verification processing to obtain a second verification result, which is either verification passed or verification failed; if the second verification result is verification failed, the thread allocates computing resources to execute the task.
[0093] For example, the current load represents the busy status of the current thread. A higher current load indicates that the current thread is busier and its task execution efficiency is lower; conversely, a lower current load indicates that the current thread's task execution efficiency is higher. Here, a thread is used to execute tasks using computing resources; the more computing resources available, the more efficient the thread is in executing tasks.
[0094] Optionally, the execution time of the pending task can be predicted based on the current load. The verification result indicates whether the execution time of the pending task is too long. If the second verification result is that the verification fails, it means that the execution time of the pending task according to the current load is too long, which will lead to low task completion efficiency.
[0095] Optionally, if the second verification result is that the verification fails, computing resources are allocated until the task can be completed in a timely manner after the computing resources are allocated.
[0096] As illustrated by the scenario example, if the task completion time is too long, the resource usage module will also have to wait for too long, which will affect the normal operation of the resource usage module.
[0097] In this feasible implementation, by allocating computing resources, task completion efficiency can be improved, avoiding long waiting times for resource-using modules due to excessively long task execution times.
[0098] One feasible implementation method for resource modification further includes: identifying multiple tasks to be executed corresponding to the target resource; merging the tasks to be executed with the same resource access type to obtain multiple merged tasks; and replacing the multiple tasks to be executed with the multiple merged tasks.
[0099] For example, resource access types include read-only, write-only, read-write, or reading a specified location of the resource. Each resource access type is executed by a corresponding thread.
[0100] For example, by merging processes, tasks with the same resource access type can be placed in adjacent positions, thereby reducing thread switching.
[0101] With the example provided, without merging, if the resource access types of the currently executing task and the next task are different, a thread switch is required before starting the next task, and so on. This results in frequent thread switching and reduced task execution efficiency. Merging reduces the number of thread switches.
[0102] In this feasible implementation, the number of thread switches can be reduced by merging processes, thereby improving task execution efficiency.
[0103] S304. Determine the target detection period corresponding to the target pulse clock.
[0104] For example, the target detection period is the period for detecting the task completion status. For instance, the target detection period is 10 seconds, meaning that the task completion status is detected once every 10 seconds.
[0105] Optionally, the target detection cycle can be adaptively adjusted according to the task volume or task execution rate.
[0106] Below, in conjunction with Figure 4 The task detection process is explained.
[0107] Figure 4 This is a schematic diagram illustrating task detection provided in an embodiment of this application. Figure 4 As shown, the tasks that need to be completed are those that need to be executed before the resources are modified. The tasks that need to be completed include tasks that are currently being executed and tasks waiting to be executed in the task queue. Newly generated tasks are those that have not been executed and have not been added to the task queue. Task detection is used to detect whether the tasks that need to be completed have been completed.
[0108] With the example scenario, the task completion status is periodically obtained based on the target detection cycle of the target pulse clock. If the task is completed, the pulse clock value is automatically incremented by 1; if the task is not completed, the pulse clock value is not updated. It can be understood that during modification processing, changes in the pulse clock value can quickly and accurately determine whether the task has been completed.
[0109] S305. Determine the request time corresponding to the request timestamp.
[0110] The resource modification request includes the request timestamp.
[0111] For example, the request timestamp is the timestamp at which the resource modification request was initiated. The request time is the time corresponding to the request timestamp.
[0112] Optionally, when an abnormal synchronization of the target pulse clock value is detected, all task delivery operations are frozen, and the target resource is rolled back to the nearest valid resource. It can be understood that rollback processing can effectively handle abnormal situations, thereby improving the reliability of resource modifications.
[0113] S306. At the requested time, determine the original pulse clock value of the target pulse clock.
[0114] The original pulse clock value represents the completion status of the task corresponding to the target resource at the request time.
[0115] With the example of the scenario, this application determines whether the task is completed based on whether the pulse clock value changes, and the original pulse clock value is used as a reference for judging whether the pulse clock value has changed.
[0116] Optionally, the pulse clock value at the moment marked as unavailable can be determined as the original pulse clock value.
[0117] S307. Starting from the request time, multiple detection times are determined sequentially according to the target detection cycle. At each detection time, the detection pulse clock value of the target pulse clock is determined sequentially until the detection pulse clock value at any detection time is different from the original pulse clock value. Then, the detection time is determined as the completion time.
[0118] Below, in conjunction with Figure 5 Explanation of pulse clock.
[0119] Figure 5 This is a schematic diagram of a pulse clock provided in an embodiment of this application. Figure 5 As shown, multiple candidate times are determined based on the target detection cycle: T0, T1, T2, T3, T4, and T5. The pulse clock updates its value at each time point based on the task completion status. The time when the pulse clock value is updated, starting from the request time, is the completion time. For example, if the request time is between T0 and T1, the original pulse clock value at the request time is 5, the detection pulse clock value at T1 is 5, the detection pulse clock value at T2 is 5, and the detection pulse clock value at T3 is 6, then the task was completed at T3, there are no tasks to be executed at T3, and T3 is determined as the completion time.
[0120] Based on the above implementation methods, by comparing the original pulse clock value and the change in the detected pulse clock value, it is possible to accurately determine whether the task has been completed, thereby improving the accuracy of resource modification.
[0121] One feasible implementation method for modifying resources further includes: determining the count value of the detection time between the current time and the request time; obtaining a count value threshold; performing verification processing on the count value according to the count value threshold to obtain a first verification result, wherein the first verification result is either verification passed or verification failed; and if the first verification result is verification failed, then allocating computing resources.
[0122] For example, the first verification result represents the number of tasks corresponding to the current target resource. A failed verification indicates that the number of tasks is too large to be processed in a short time.
[0123] Please refer to the following examples and scenarios. Figure 5 For example, if the request time is between T0 and T1, and the task is still not completed by time T5, the count value will be 5, indicating that the number of backlogged tasks is too large. During task execution, the target resource will not accept new tasks and will pause the resource usage module from generating new tasks. If the task execution time is too long, it will affect the normal operation of the resource usage module. Improving task execution efficiency by allocating computing resources can shorten task execution time and reduce the impact on the resource usage module.
[0124] In this feasible implementation, computing resources are allocated based on the first verification result. This can shorten the task execution time as much as possible when there are many tasks, avoid the task execution time being too long and affecting the normal operation of the resource utilization module, and improve the work efficiency of the resource utilization module.
[0125] S308. At the completion time, modify the target resource according to the target modification information to obtain the modified resource.
[0126] Below, in conjunction with Figure 6 Provide an explanation of the resource tags.
[0127] Figure 6 This is a schematic diagram of resource markers provided in an embodiment of this application. For example... Figure 6 As shown, when executing a resource modification request, the target resource is marked as unavailable and the system waits for a change in the pulse clock value. After being marked as unavailable, the resource-using module stops accessing the target resource, while already generated tasks continue to execute. When a change in the pulse clock value is detected, all tasks using the target resource have already completed, and resource modification can be performed without affecting access to the target resource. Consequently, the modification process will not affect access to the target resource.
[0128] One feasible implementation, after obtaining the modified resource, may further include: marking the resource status of the target resource as available; generating second status information based on the target resource identifier and the available status; and sending the second status information to at least one used module so that at least one used module generates a task that uses the target resource.
[0129] For example, the availability status indicates that the target resource is accessible. Once the used module identifies the availability status, it can clearly indicate that the target resource is currently accessible.
[0130] As illustrated by the scenario example, after a resource is marked as available, the module using the resource may not recognize it in time, resulting in an unclear understanding of whether the target resource is currently accessible. Sending a second status message to at least one module that has already used the resource can explicitly indicate that at least one module can access the target resource, thus enabling the modules using the resource to use it smoothly.
[0131] In this feasible implementation, by sending the second status information, the module already in use can clearly access the target resource, thus avoiding restrictions on the target resource and improving the effective utilization rate of the target resource.
[0132] Figure 7 This is a schematic diagram of a resource modification device provided in an embodiment of this application. Figure 7 As shown, the resource modification device 70 may include: a receiving module 71, a determining module 72, a marking module 73, a detecting module 74, and a modification module 75, wherein,
[0133] The receiving module 71 is used to receive resource modification requests, which include the target resource identifier and target modification information.
[0134] The determination module 72 is used to determine the target resource and target pulse clock corresponding to the target resource identifier based on the resource modification request.
[0135] The marking module 73 is used to mark the target resource as unavailable.
[0136] The detection module 74 is used to detect and process the task corresponding to the target resource according to the target pulse clock, and obtain the completion time of the task corresponding to the target resource.
[0137] Modification module 75 is used to modify the target resource based on the target modification information at the completion time to obtain the modified resource.
[0138] Optionally, the receiving module 71 can perform... Figure 2 S201 in the embodiment.
[0139] Optionally, module 72 can be executed. Figure 2 S202 in the embodiment.
[0140] Optionally, the tag module 73 can execute Figure 2 S203 in the embodiment.
[0141] Optionally, the detection module 74 can perform... Figure 2S204 in the embodiment.
[0142] Optionally, module 75 can be modified to execute. Figure 2 S205 in the embodiment.
[0143] It should be noted that the resource modification device shown in the embodiments of this application can execute the technical solution shown in the above method embodiments, and its implementation principle and beneficial effects are similar, so they will not be described again here.
[0144] In one possible implementation, the detection module 74 is specifically used for:
[0145] Determine the target detection period corresponding to the target pulse clock;
[0146] The completion time is determined based on the request timestamp and the target detection period.
[0147] In one possible implementation, the detection module 74 is specifically used for:
[0148] Determine the time of the request corresponding to the request timestamp;
[0149] At the request time, determine the original pulse clock value of the target pulse clock. The original pulse clock value represents the completion status of the task corresponding to the target resource at the request time.
[0150] Starting from the request time, multiple detection times are determined sequentially according to the target detection cycle. At each detection time, the detection pulse clock value of the target pulse clock is determined sequentially until the detection pulse clock value of any detection time is different from the original pulse clock value. Then, the detection time is determined as the completion time.
[0151] Figure 8 This is a schematic diagram of a resource modification device provided in an embodiment of this application. Figure 7 Based on the illustrated embodiments, as Figure 8 As shown, the resource modification device 80 further includes: a first verification module 76, a sending module 77, a prediction module 78, a second verification module 79, a merging module 710, and a prompting module 711, wherein...
[0152] The first verification module 76 is used for:
[0153] Determine the count value of the detection time between the current time and the requested time;
[0154] Obtain the count value threshold, and perform verification processing on the count value based on the count value threshold to obtain the first verification result, which is either verification passed or verification failed.
[0155] If the first verification result is that the verification fails, then computing resources for executing the task are allocated.
[0156] Sending module 77, used for:
[0157] Identify at least one currently used module that is using the target resource;
[0158] Generate first status information based on the unavailability status;
[0159] Send a first status message to at least one used module so that at least one used module stops generating tasks that use the target resource during the execution of a resource modification request.
[0160] In one possible implementation, the sending module 77 is specifically used for:
[0161] Based on the target resource identifier, determine the task queue of the target resource, and the task queue includes at least one queued task;
[0162] The module that generates at least one queued task is identified as at least one used module.
[0163] Prediction module 78 is used for:
[0164] Analyze and process at least one queuing task to obtain the task generation pattern of at least one queuing task generated by a used module;
[0165] Based on the task generation pattern, identify the periodically used module that generates tasks periodically from at least one used module;
[0166] The target resource is copied to obtain a resource copy, and the resource copy is sent to the periodic use module so that the periodic use module can read the resource copy in advance.
[0167] The second verification module 79 is used for:
[0168] Get the current load and load threshold;
[0169] Based on the current load and load threshold, a second verification result is obtained, which is either verification passed or verification failed.
[0170] If the second verification result is that the verification fails, then computing resources for executing the task are allocated.
[0171] Merging module 710 is used for:
[0172] Identify the multiple tasks to be executed corresponding to the target resource;
[0173] Multiple tasks with the same resource access type are merged to obtain multiple merged tasks.
[0174] Multiple tasks can be merged to replace multiple pending tasks.
[0175] Prompt module 711, used for:
[0176] Mark the resource status of the target resource as available;
[0177] Generate second status information based on the target resource identifier and availability status;
[0178] Send a second status message to at least one used module so that at least one used module generates a task that uses the target resource.
[0179] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 9 As shown, the electronic device includes:
[0180] The electronic device includes a processor 291 and a memory 292; it may also include a communication interface 293 and a bus 294. The processor 291, memory 292, and communication interface 293 can communicate with each other via the bus 294. The communication interface 293 can be used for information transmission. The processor 291 can invoke logical instructions stored in the memory 292 to execute the methods of the above embodiments.
[0181] Furthermore, the logic instructions in the aforementioned memory 292 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.
[0182] The memory 292, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of this application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, thereby implementing the methods in the above-described method embodiments.
[0183] The memory 292 may include a program storage area and a data storage area. The program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the terminal device. Furthermore, the memory 292 may include high-speed random access memory and may also include non-volatile memory.
[0184] This application provides a non-transitory computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods described in the foregoing embodiments.
[0185] This application provides a computer program product, including a computer program that, when executed by a processor, implements the method as described in the foregoing embodiments.
[0186] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0187] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0188] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.
[0189] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or in the form of software program modules.
[0190] When the integrated unit / module is implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. The processor can be any suitable hardware processor, such as CPU, GPU, FPGA, DSP, and ASIC. The storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.
[0191] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0192] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0193] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims.
[0194] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A resource modification method, characterized in that, include: Receive a resource modification request, the resource modification request including a target resource identifier and target modification information; Based on the resource modification request, determine the target resource and target pulse clock corresponding to the target resource identifier; Mark the target resource as unavailable; The task corresponding to the target resource is detected and processed according to the target pulse clock to obtain the completion time of the task corresponding to the target resource; At the completion time, the target resource is modified according to the target modification information to obtain the modified resource.
2. The method according to claim 1, characterized in that, The resource modification request includes a request timestamp; the task corresponding to the target resource is detected and processed according to the target pulse clock to obtain the completion time of the task corresponding to the target resource, including: Determine the target detection period corresponding to the target pulse clock; The completion time is determined based on the request timestamp and the target detection period.
3. The method according to claim 2, characterized in that, Determining the completion time based on the request timestamp and the target detection period includes: Determine the request time corresponding to the request timestamp; At the requested time, the original pulse clock value of the target pulse clock is determined, and the original pulse clock value represents the completion status of the task corresponding to the target resource at the requested time; Starting from the requested time, multiple detection times are sequentially determined according to the target detection cycle. At each detection time, the detection pulse clock value of the target pulse clock is determined sequentially until the detection pulse clock value at any detection time is different from the original pulse clock value. Then, the detection time is determined as the completion time.
4. The method according to claim 3, characterized in that, The method further includes: Determine the count value of the detection time between the current time and the requested time; A count value threshold is obtained, and the count value is verified based on the count value threshold to obtain a first verification result, wherein the first verification result is either verification passed or verification failed. If the first verification result is that the verification fails, then computing resources for executing the task are allocated.
5. The method according to claim 1, characterized in that, After marking the target resource as unavailable, the process also includes: Identify at least one currently used module that is using the target resource; Based on the unavailability status, generate first status information; The first status information is sent to the at least one used module so that the at least one used module stops generating tasks that use the target resource during the execution of the resource modification request.
6. The method according to claim 5, characterized in that, Identifying at least one currently used module that is using the target resource includes: Based on the target resource identifier, a task queue for the target resource is determined, wherein the task queue includes at least one queued task; The module that generates the at least one queued task is identified as the at least one used module.
7. The method according to claim 6, characterized in that, The method further includes: The at least one queuing task is analyzed and processed to obtain the task generation pattern of the at least one queuing task generated by the used module; Based on the task generation pattern, determine the periodically used module that generates tasks periodically from the at least one used module; The target resource is copied to obtain a resource copy, and the resource copy is sent to the periodic usage module so that the periodic usage module can read the resource copy in advance.
8. The method according to claim 6, characterized in that, The method further includes: Get the current load and load threshold; Based on the current load and the load threshold, a verification process is performed to obtain a second verification result, which is either verification passed or verification failed. If the second verification result is that the verification fails, then computing resources for executing the task are allocated.
9. The method according to claim 1, characterized in that, The method further includes: Identify the multiple tasks to be executed corresponding to the target resource; Among the multiple tasks to be executed, those with the same resource access type are merged to obtain multiple merged tasks. The multiple merged tasks replace the multiple tasks to be executed.
10. The method according to any one of claims 1-9, characterized in that, After modifying the target resource to obtain the modified resource, the process further includes: Mark the resource status of the target resource as available; Generate second status information based on the target resource identifier and the availability status; The second status information is sent to at least one used module so that the at least one used module generates a task that uses the target resource.
11. A resource modification device, characterized in that, include: The receiving module is used to receive resource modification requests, wherein the resource modification request includes a target resource identifier and target modification information; The determining module is used to determine the target resource and target pulse clock corresponding to the target resource identifier based on the resource modification request; The marking module is used to mark the target resource as unavailable. The detection module is used to detect and process the task corresponding to the target resource according to the target pulse clock, and obtain the completion time of the task corresponding to the target resource; The modification module is used to modify the target resource according to the target modification information at the completion time to obtain the modified resource.
12. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-10.
14. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1-10.