CN117785434A - Data processing method and device, electronic equipment and computer readable storage medium - Google Patents

Data processing method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN117785434A
CN117785434A CN202211261366.5A CN202211261366A CN117785434A CN 117785434 A CN117785434 A CN 117785434A CN 202211261366 A CN202211261366 A CN 202211261366A CN 117785434 A CN117785434 A CN 117785434A
Authority
CN
China
Prior art keywords
target
request
coroutine
data processing
token address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211261366.5A
Other languages
Chinese (zh)
Inventor
姚舜禹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xingyin Information Technology Shanghai Co ltd
Original Assignee
Xingyin Information Technology Shanghai Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xingyin Information Technology Shanghai Co ltd filed Critical Xingyin Information Technology Shanghai Co ltd
Priority to CN202211261366.5A priority Critical patent/CN117785434A/en
Publication of CN117785434A publication Critical patent/CN117785434A/en
Pending legal-status Critical Current

Links

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The application discloses a data processing method and device, electronic equipment and a computer readable storage medium. The data processing method is applied to a data processing device, the data processing device runs n threads, the n threads comprise target threads, and the method comprises the following steps: determining a target time for a target coroutine in the target thread to process a first request; the data processing apparatus invokes the target coroutine to process the first request at the target time.

Description

Data processing method and device, electronic equipment and computer readable storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a data processing method and apparatus, an electronic device, and a computer readable storage medium.
Background
The server side processes the request of the client side by adopting a coroutine mode, so that the time expenditure can be reduced, and the processing efficiency of the system can be improved. However, in the coroutine mode, if a coroutine in a thread is blocked, the thread is in a waiting state, and then a central processing unit (central processing unit, CPU) of the thread is idle, that is, the hardware resource utilization rate of the data processing device is low, and the response speed of the thread to a request is slow.
Disclosure of Invention
The application provides a data processing method and device, electronic equipment and a computer readable storage medium.
In a first aspect, there is provided a data processing method applied to a data processing apparatus running n threads including a target thread, the method comprising:
determining a target time for a target coroutine in the target thread to process a first request;
the data processing apparatus invokes the target coroutine to process the first request at the target time.
In the aspect, the data processing device determines the time for processing the first request for the target cooperative distance, so that the target cooperative distance is prevented from waiting for processing the first request, the blocking probability of the target cooperative distance can be reduced, the blocking probability of the target thread is further reduced, the hardware resource utilization rate of the data processing device is improved, and the response speed of the server side is improved.
In combination with any one of the embodiments of the present application, the determining the target time for the target coroutine in the target thread to process the first request includes:
and under the condition that the target coroutine is determined to have the authority of calling the hardware resource, determining the target time for the target coroutine in the target thread to process the first request.
In this embodiment, the data processing apparatus determines the target time for the target cooperative program to process the first request under the condition that the target cooperative program is determined to have the authority to invoke the hardware resource, so that each thread can be better managed, and the processing efficiency of the data processing apparatus is improved.
In combination with any one of the embodiments of the present application, before determining the target time for the target co-process in the target thread to process the first request in the case that the target co-process is determined to have the right to invoke the hardware resource, the method further includes:
under the condition that the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing device, determining that the target cooperative program has the authority of calling hardware resources; the global token address stores a global token having the right to invoke a hardware resource.
In such an embodiment, the data processing apparatus causes the target coroutine to have the right to invoke the hardware resource by exchanging the private token address of the target coroutine with the global token address of the data processing apparatus. Because the exchange of the private token address of the target cooperative program and the global token of the data processing device is a lock-free operation, the implementation mode can reduce the blocking probability when the target cooperative program obtains the global token in the global token address.
In combination with any one of the embodiments of the present application, before determining that the target cooperative program has the authority to invoke the hardware resource, in a case where the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing apparatus, the method further includes:
performing an atomic operation on the private token address and the global token address;
and under the condition that the original value of the private token address is changed, the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing device.
In such an embodiment, the data processing apparatus implements the exchange of the private token address with the global token address by performing an atomic operation on the private token address and the global token address. Because the atomic operation belongs to the lock-free operation, the exchange of the private token address and the global token address is realized through the atomic operation, and the blocking probability of the target coroutine can be reduced.
In combination with any one of the embodiments of the present application, the performing an atomic operation on the private token address and the global token address includes:
the target coroutine acquires the target number of the request to be processed; the request to be processed is a request with determined processing time;
The target coroutine sends an atomic operation request to the data processing device under the condition that the target quantity is smaller than or equal to a threshold value;
the data processor performs an atomic operation on the private token address and the global token address if the atomic operation request is detected.
In this embodiment, the target coroutine sends the atomic operation request to the data processing apparatus when it is determined that the target number is less than or equal to the threshold, so that the response speed of the data processing apparatus can be improved.
In combination with any one of the embodiments of the present application, after the target time invokes the target coroutine to process the first request, the method further includes:
and cleaning up the token stored in the global token address under the condition that the target coroutine finishes processing the first request.
In such an embodiment, the data processing apparatus may implement resource reclamation of global token addresses by cleaning tokens in the global token. After the private token address of the target cooperative program is successfully exchanged with the global token address, the global token address becomes the private address of the target cooperative program, so that the target cooperative program cleans up the tokens stored in the global token address (namely the global tokens) and is the local operation of the target cooperative program, the operation of the global cooperative program is not influenced by the resource recovery operation, and the probability of blocking the cooperative program of the data processing device can be further reduced.
In combination with any one of the embodiments of the present application, the determining the target time for the target coroutine in the target thread to process the first request includes:
acquiring the target number of the requests to be processed; the request to be processed is a request with determined processing time;
and obtaining the target time according to the target number and the processing time of the to-be-processed request.
In combination with any one of the embodiments of the present application, before the data processing apparatus invokes the target coroutine to process the first request at the target time, the method further includes: the data processing device invokes the target coroutine to process a second request before the target time; the second request is different from the first request.
In this embodiment, the second request is different from the first request, that is, the data processing apparatus may also invoke the target co-program to process the second request before invoking the target co-program to process the first request, in other words, the data processing apparatus does not need to wait before invoking the target co-program to process the first request. Therefore, the efficiency of processing the request by the target coroutine can be improved, and the response speed of the data processing device to the request can be improved.
In a second aspect, there is provided a data processing apparatus that runs n threads including a target thread, the data processing apparatus comprising:
a first processing unit, configured to determine a target time for a target coroutine in the target thread to process a first request;
and the second processing unit is used for calling the target coroutine to process the first request at the target time by the data processing device.
In combination with any one of the embodiments of the present application, the first processing unit is configured to:
and under the condition that the target coroutine is determined to have the authority of calling the hardware resource, determining the target time for the target coroutine in the target thread to process the first request.
In combination with any one of the embodiments of the present application, the first processing unit is further configured to determine that the target coroutine has a right to invoke a hardware resource when the private token address of the target coroutine is successfully exchanged with the global token address of the data processing apparatus; the global token address stores a global token having the right to invoke a hardware resource.
In combination with any one of the embodiments of the present application, the first processing unit is further configured to:
Performing an atomic operation on the private token address and the global token address;
and under the condition that the original value of the private token address is changed, the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing device.
In combination with any one of the embodiments of the present application, the first processing unit is configured to:
the target coroutine acquires the target number of the request to be processed; the request to be processed is a request with determined processing time;
the target coroutine sends an atomic operation request to the data processing device under the condition that the target quantity is smaller than or equal to a threshold value;
the data processor performs an atomic operation on the private token address and the global token address if the atomic operation request is detected.
In combination with any one of the embodiments of the present application, the first processing unit is further configured to:
and cleaning up the token stored in the global token address under the condition that the target coroutine finishes processing the first request.
In combination with any one of the embodiments of the present application, the first processing unit is configured to:
acquiring the target number of the requests to be processed; the request to be processed is a request with determined processing time;
And obtaining the target time according to the target number and the processing time of the to-be-processed request.
In combination with any one of the embodiments of the present application, the first processing unit is further configured to: the data processing device invokes the target coroutine to process a second request before the target time; the second request is different from the first request.
In a third aspect, an electronic device is provided, including: a processor and a memory for storing computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform a method as described in the first aspect and any one of its possible implementations.
In a fourth aspect, there is provided another electronic device comprising: a processor, transmission means, input means, output means and memory for storing computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to carry out the method as described in the first aspect and any one of its possible implementations.
In a fifth aspect, there is provided a computer readable storage medium having stored therein a computer program comprising program instructions which, when executed by a processor, cause the processor to carry out a method as in the first aspect and any one of its possible implementations.
In a sixth aspect, a computer program product is provided, the computer program product comprising a computer program or instructions which, when run on a computer, cause the computer to perform the method of the first aspect and any one of the possible implementations thereof.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
In order to more clearly describe the technical solutions in the embodiments or the background of the present application, the following description will describe the drawings that are required to be used in the embodiments or the background of the present application.
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and, together with the description, serve to explain the technical aspects of the application.
Fig. 1 is a schematic flow chart of a data processing method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of a first request processing method according to an embodiment of the present application;
fig. 3 is a schematic flow chart of processing a first request sent by a client by calling a target cooperative program according to an embodiment of the present application;
FIG. 4 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application;
fig. 5 is a schematic hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the present application solution better understood by those skilled in the art, the following description will clearly and completely describe the technical solution in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The terms first, second and the like in the description and in the claims of the present application and in the above-described figures, are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
It should be understood that, in the present application, "at least one (item)" means one or more, "a plurality" means two or more, "at least two (items)" means two or three and three or more, "and/or" for describing an association relationship of an association object, three kinds of relationships may exist, for example, "a and/or B" may mean: only a, only B and both a and B are present, wherein a, B may be singular or plural. The character "/" may indicate that the context-dependent object is an "or" relationship, meaning any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b or c may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural. The character "/" may also represent divisors in mathematical operations, e.g., a/b=a divided by b; 6/3=2. "at least one of the following" or its similar expressions.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The server typically processes the client's request through a thread mode, i.e., the server invokes the thread to process the client's request. If a certain thread is blocked in the thread mode, the server side calls other idle and unblocked threads to process the request through the running system, so that the thread switching is realized. However, the time overhead caused by the thread switching may reduce the processing efficiency of the system, so some methods use the coroutine mode to process the request of the client. The coroutine mode is that a CPU of the server executes a thread, and a thread includes at least one coroutine. In the coroutine mode, the system does not execute the operation of thread switching, so that the time cost can be reduced, and the processing speed of the system is improved.
However, in the coroutine mode, if a coroutine in a thread is blocked, the thread is in a waiting state, and then a CPU executing the thread is idle, that is, the hardware resource utilization rate of the data processing device is low, and the response speed of the thread to a request is slow.
Based on the above, the embodiment of the application provides a technical scheme, so that the probability of blocking the cooperative distance is reduced, even the blocking can be avoided, the utilization rate of hardware resources of the server is further improved, and the response speed of the server is improved under the cooperative distance mode of the server.
The execution main body of the embodiment of the application is a data processing device, which is the server, wherein the data processing device can be any electronic equipment capable of executing the technical scheme disclosed by the embodiment of the application method. Alternatively, the data processing device may be one of the following: server, computer.
It should be understood that the method embodiments of the present application may also be implemented by way of a processor executing computer program code. Embodiments of the present application are described below with reference to the accompanying drawings in the embodiments of the present application. Referring to fig. 1, fig. 1 is a flow chart of a data processing method according to an embodiment of the present application.
101. And determining the target time of the target cooperative process first request in the target thread.
In this embodiment, the data processing apparatus runs n threads, where n is a positive integer. Any of the n threads includes at least one coroutine. In one possible implementation, the number of cores of the data processing apparatus is n, i.e. the number of CPUs of the data processing apparatus is n. Each CPU runs one thread. The target thread is any one of n threads, and the target cooperative thread is any one cooperative thread of the target threads.
In this embodiment of the present application, the first request is a request sent by a client that establishes a connection with the data processing apparatus. The target time is the time when the target coroutine processes the first request, i.e. the data processing apparatus determines that the target coroutine processes the first request at the target time.
In one possible implementation, the data processing apparatus determines the target time based on the number of requests to be processed and the processing duration of each request. For example, 3 requests are also processed before the CPU of the data processing apparatus invokes the target co-program to process the first request, and the processing duration of each request is 1 minute, so that the target time for the target co-program to process the first request is 3 minutes after the current time.
In another possible implementation, the data processing apparatus determines the processing order of the first request according to the transmission time of the first request. And determining the target time of the target coroutine processing the first request according to the processing sequence of the first request and the processing duration of each request. For example, in all unprocessed requests, the transmission time of the first request is 3 rd earliest, and then the processing order of the first request is 3. If the processing duration of each request is 1 minute, then the target coroutine processes the target time of the first request 2 minutes after the current time.
102. The data processing apparatus invokes the target coroutine to process the first request at the target time.
In the embodiment of the application, the data processing device determines the time for processing the first request for the target cooperative distance, so that the target cooperative distance is prevented from waiting for processing the first request, the blocking probability of the target cooperative distance can be reduced, the blocking probability of the target thread is further reduced, the hardware resource utilization rate of the data processing device is improved, and the response speed of the server side is improved.
As an alternative embodiment, the data processing apparatus performs the following steps in performing step 101:
201. and under the condition that the target coroutine is determined to have the authority of calling the hardware resource, determining the target time of the target coroutine in the target thread for processing the first request.
Optionally, the data processing apparatus does not determine a target time to process the first request for the target coroutine if it is determined that the target coroutine does not have the right to invoke the hardware resource.
In this embodiment, the data processing apparatus determines the target time for the target cooperative program to process the first request under the condition that the target cooperative program is determined to have the authority to invoke the hardware resource, so that each thread can be better managed, and the processing efficiency of the data processing apparatus is improved.
As an alternative embodiment, the data device determines that the target coroutine has the right to invoke the hardware resource by performing the following steps:
301. and under the condition that the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing device, determining that the target cooperative program has the authority to call the hardware resource.
In the embodiment of the present application, the private token address of the target cooperative is only open to the target cooperative, that is, threads other than the target cooperative cannot access the private token address. The global token address is open to all the co-processes in the target thread, i.e., any one of the co-processes in the target thread can access the global token address. The global token address stores a global token, wherein the global token has the right to call the hardware resource. I.e. the thread that gets the global token has the right to invoke the hardware resource processing request. Both the private token address and the global token address are pointer addresses.
The private token address of the target cooperative program is successfully exchanged with the global token address, which means that the global token address is the private address of the target cooperative program, namely, only the target cooperative program can access the global token address, and meanwhile, the target cooperative program also obtains the global token in the global token address. Correspondingly, the private token address of the target cooperative program is changed into a global address, namely any cooperative program in the target thread can access the private token address of the target cooperative program.
Therefore, the data processing device determines that the target coroutine has the authority to call the hardware resource under the condition that the private token address of the target coroutine is successfully exchanged with the global token address of the data processing device.
Optionally, the data processing apparatus determines that the target coroutine does not have the right to invoke the hardware resource if the private token address of the target coroutine is not successfully exchanged with the global token address of the data processing apparatus.
In such an embodiment, the data processing apparatus causes the target coroutine to have the right to invoke the hardware resource by exchanging the private token address of the target coroutine with the global token address of the data processing apparatus. Because the exchange of the private token address of the target cooperative program and the global token of the data processing device is a lock-free operation, the implementation mode can reduce the blocking probability when the target cooperative program obtains the global token in the global token address.
As an alternative embodiment, the data processing apparatus determines that the private token address of the target coroutine is successfully exchanged with the global token address of the data processing apparatus by performing the following steps:
401. and performing atomic operation on the private token address and the global token address.
In the embodiment of the application, the atomic operation is realized through an atomic instruction of the processor. Specifically, the two memory addresses are compared, and when the comparison results are equal to each other, the original values of the two memory addresses are exchanged, so that the exchange of the two addresses is completed.
402. And under the condition that the original value of the private token address is changed, the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing device.
The original value of the private token address has been changed, which means that the comparison result obtained by performing the atomic operation on the global token address and the private token address is equal, that is, the private token address and the global token address have been successfully exchanged.
In such an embodiment, the data processing apparatus implements the exchange of the private token address with the global token address by performing an atomic operation on the private token address and the global token address. Because the atomic operation belongs to the lock-free operation, the exchange of the private token address and the global token address is realized through the atomic operation, and the blocking probability of the target coroutine can be reduced.
As an alternative embodiment, the data processing apparatus performs the following steps in performing step 401:
501. The target coroutine acquires the target number of the to-be-processed request.
In this embodiment, the request to be processed is a request with a determined processing time, that is, the coroutines that process the request to be processed all have the right to invoke the hardware resource.
In one possible implementation, the global token includes a target number of pending requests, and the target coroutine determines the target number from the global token.
502. And the target cooperative distance sends an atomic operation request to the data processing device under the condition that the target number is less than or equal to a threshold value.
In this embodiment of the present application, the atomic operation request is used to apply for an atomic operation to the data processing apparatus. Due to the limited hardware resources of the data processing device, the data processing device limits the number of requests that can be processed per unit time, i.e. limits the traffic of the client. For example, the data processing apparatus is limited to processing up to 40 requests within 1 minute. If the number of requests for processing time is determined to be large, the target coroutine is caused to process the first request, namely the response time of the first request is caused to be long, even if the target coroutine has the authority of calling the hardware resource, from the current time. Therefore, the target coroutine transmits an atomic operation request to the data processing apparatus in the case where the number of requests for which processing times have been determined is small.
In the embodiment of the application, the threshold is used as a basis to judge whether the number of the requests of the determined processing time is more or less. Specifically, the number of requests for which processing time has been determined is less than or equal to the threshold, indicating that the number of requests for which processing time has been determined is small. The number of requests for which processing time has been determined is greater than the threshold, indicating that the number of requests for which processing time has been determined is greater. Therefore, the target coroutine sends an atomic operation request to the data processing device under the condition that the target number is smaller than or equal to the threshold value, and the response speed of the data processing device is further improved.
503. And the data processor performs atomic operation on the private token address and the global token address under the condition that the atomic operation request is detected.
In this embodiment, the target coroutine sends the atomic operation request to the data processing apparatus when it is determined that the target number is less than or equal to the threshold, so that the response speed of the data processing apparatus can be improved.
As an alternative embodiment, the data processing apparatus, in the case of performing step 102, further performs the following steps:
601. and cleaning up the token stored in the global token address under the condition that the target coroutine finishes processing the first request.
The target coroutine may implement resource reclamation of the global token address by executing step 601. After the private token address of the target cooperative program is successfully exchanged with the global token address, the global token address becomes the private address of the target cooperative program, so that the target cooperative program cleans up the tokens stored in the global token address (namely the global tokens) and is the local operation of the target cooperative program, the operation of the global cooperative program is not influenced by the resource recovery operation, and the probability of blocking the cooperative program of the data processing device can be further reduced.
As an alternative embodiment, the data processing apparatus determines the target time for the target coroutine in the target thread to process the first request by performing the steps of:
701. and obtaining the target number of the pending requests.
In this embodiment, the request to be processed is a request with a determined processing time, that is, the coroutines that process the request to be processed all have the right to invoke the hardware resource.
In one possible implementation, the global token includes a target number of pending requests, and the target coroutine determines the target number from the global token.
702. And obtaining the target time according to the target number and the processing time of the to-be-processed request.
In the embodiment of the application, the processing time length of each request to be processed is the same, so that the time length required for processing all the requests to be processed can be determined according to the target number and the processing time length of the requests to be processed, and further the target time can be determined.
In one possible implementation, the product of the target number and the processing duration of the pending requests is determined, resulting in the duration required to process all pending requests. And taking the sum of the time length required for processing all the pending requests and the current time as the target time. For example, the target number is 4, the processing time of the pending requests is 10 seconds, and the time required for processing all the pending requests is 40 seconds. If the current time is 2022, 9, 19, 9, 30 minutes and 15 seconds, then the target time is 2022, 9, 19, 9, 30 minutes and 55 seconds.
In another possible implementation, the product of the target number and the processing duration of the pending requests is determined, resulting in the duration required to process all pending requests. And taking the sum of the time length, the current time and the preset time required for processing all the pending requests as the target time. For example, the target number is 4, the processing time of the pending requests is 10 seconds, and the time required for processing all the pending requests is 40 seconds. If the current time is 2022, 9, 19, 9, 30 minutes, 15 seconds and the preset time is 1 second, then the target time is 2022, 9, 19, 9, 30 minutes, 56 seconds.
As depicted in step 502, the data processing apparatus limits the number of requests that can be processed per unit time, i.e., the speed at which the data processing apparatus processes requests is limited, due to the limited hardware resources of the data processing apparatus. For example, the data processing device processes a maximum of 120 requests within 1 minute, and then the data processing device processes the requests at a rate of 2 requests per second. That is, the processing time period of each request is 1/2 second=0.5 second, that is, the processing time period of the request to be processed can be determined according to the speed of processing the request.
As an alternative embodiment, the data processing apparatus further performs the following steps before the target time invokes the target coroutine to process the first request:
801. and calling the target protocol to process a second request before the target time.
In this embodiment of the present application, the second request is different from the first request, that is, the data processing apparatus may further invoke the target cooperative program to process the second request before invoking the target cooperative program to process the first request, in other words, the data processing apparatus does not need to wait before invoking the target cooperative program to process the first request. Therefore, the efficiency of processing the request by the target coroutine can be improved, and the response speed of the data processing device to the request can be improved.
It should be understood that, in the embodiment of the present application, the target cooperative thread and the target thread are only descriptive objects selected by the technical solution for brevity, and it should not be understood that the n threads only include the target thread, and the target thread only includes the target cooperative thread, and it should not be understood that the data processing apparatus only calls the target cooperative thread to process the first request through the foregoing technical solution, so that the target cooperative thread does not need to wait before processing the first request. In practical application, the data processing device may determine the reference time of any one of the n threads for processing the request according to the foregoing technical solution, and then call the corresponding cooperative processing request at the reference time, so that each of the n threads does not need to wait before processing the request. Thereby, the response speed of the data processing apparatus to the request can be improved.
Based on the technical scheme provided by the embodiment of the application, the embodiment of the application also provides a possible application scene.
Considering that the hardware configuration and network bandwidth of a server (such as a server) are limited, in order to protect the security of a database of the server, the number of requests of a client processed by the server needs to be limited. According to the technical scheme provided by the embodiment of the application, the cooperative processing request of the server under the cooperative mode is called, so that the processing speed can be improved through the cooperative mode, and the blocking probability of the cooperative process can be reduced.
Specifically, referring to fig. 2, as shown in fig. 2, after the server receives the first request sent by the client, a protocol layer (protocol layer) may determine whether to limit the first request according to the determination. If it is determined that the first request does not need to be current limited, a filter layer will invoke a coroutine in time to process the first request. If it is determined that the first request needs to be limited, a calling component in the filtering layer obtains the flow limiting flow rate (i.e. the speed of processing the request), determines a duration of processing a first request according to the flow limiting flow rate, and then calls the target cooperative program to process the first request according to the technical scheme. And after the first request sent by the client is processed, releasing the target coroutine for processing the first request. Optionally, the calling component is a pluggable module.
Optionally, a flow diagram of the calling component for calling the target coroutine to process the first request sent by the client according to the technical scheme is shown in fig. 3. In FIG. 3, the target coroutine first obtains the most recently issued global token address. And determining the target number according to the global token address. Judging whether the target number is smaller than or equal to a threshold value, if not, not sending an atomic operation request to a server, if so, generating a private token, and storing the private token in a private token address, wherein the private token carries the following information: and the target number and the target coroutine identification, and sending an atomic operation request to the server. And the server performs atomic operation on the private token address and the global token address under the condition that an atomic operation request sent by the target coroutine is detected. If the private token address and the global token address are not successfully exchanged through the atomic operation, the target coroutine continues to acquire the recently issued global token address. If the private token address and the global token address are successfully exchanged through the atomic operation, the server determines the target time of the target cooperative process for processing the first request, and calls the target cooperative process for processing the first request at the target time. The target coroutine clears the token stored in the global token address after processing the first request.
It will be appreciated by those skilled in the art that in the above-described method of the specific embodiments, the written order of steps is not meant to imply a strict order of execution but rather should be construed according to the function and possibly inherent logic of the steps.
If the technical scheme of the application relates to personal information, the product applying the technical scheme of the application clearly informs the personal information processing rule before processing the personal information, and obtains independent consent of the individual. If the technical scheme of the application relates to sensitive personal information, the product applying the technical scheme of the application obtains individual consent before processing the sensitive personal information, and simultaneously meets the requirement of 'explicit consent'. For example, a clear and remarkable mark is set at a personal information acquisition device such as a camera to inform that the personal information acquisition range is entered, personal information is acquired, and if the personal voluntarily enters the acquisition range, the personal information is considered as consent to be acquired; or on the device for processing the personal information, under the condition that obvious identification/information is utilized to inform the personal information processing rule, personal authorization is obtained by popup information or a person is requested to upload personal information and the like; the personal information processing may include information such as a personal information processor, a personal information processing purpose, a processing mode, and a kind of personal information to be processed.
The foregoing details the method of embodiments of the present application, and the apparatus of embodiments of the present application is provided below.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application, where the data processing apparatus 1 includes a first processing unit 11 and a second processing unit 12, and specifically:
a first processing unit 11, configured to determine a target time for a target coroutine in the target thread to process a first request;
a second processing unit 12, configured to invoke, by the data processing apparatus, the target coroutine to process the first request at the target time.
In combination with any one of the embodiments of the present application, the first processing unit 11 is configured to:
and under the condition that the target coroutine is determined to have the authority of calling the hardware resource, determining the target time for the target coroutine in the target thread to process the first request.
In combination with any one of the embodiments of the present application, the first processing unit 11 is further configured to determine that the target coroutine has a right to invoke a hardware resource when the private token address of the target coroutine is successfully exchanged with the global token address of the data processing apparatus; the global token address stores a global token having the right to invoke a hardware resource.
In combination with any one of the embodiments of the present application, the first processing unit 11 is further configured to:
performing an atomic operation on the private token address and the global token address;
and under the condition that the original value of the private token address is changed, the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing device.
In combination with any one of the embodiments of the present application, the first processing unit 11 is configured to:
the target coroutine acquires the target number of the request to be processed; the request to be processed is a request with determined processing time;
the target coroutine sends an atomic operation request to the data processing device under the condition that the target quantity is smaller than or equal to a threshold value;
the data processor performs an atomic operation on the private token address and the global token address if the atomic operation request is detected.
In combination with any one of the embodiments of the present application, the first processing unit 11 is further configured to:
and cleaning up the token stored in the global token address under the condition that the target coroutine finishes processing the first request.
In combination with any one of the embodiments of the present application, the first processing unit 11 is configured to:
Acquiring the target number of the requests to be processed; the request to be processed is a request with determined processing time;
and obtaining the target time according to the target number and the processing time of the to-be-processed request.
In combination with any one of the embodiments of the present application, the first processing unit 11 is further configured to: the data processing device invokes the target coroutine to process a second request before the target time; the second request is different from the first request.
In the embodiment of the application, the data processing device determines the time for processing the first request for the target cooperative distance, so that the target cooperative distance is prevented from waiting for processing the first request, the blocking probability of the target cooperative distance can be reduced, the blocking probability of the target thread is further reduced, the hardware resource utilization rate of the data processing device is improved, and the response speed of the server side is improved.
In some embodiments, functions or modules included in the apparatus provided in the embodiments of the present application may be used to perform the methods described in the foregoing method embodiments, and specific implementations thereof may refer to descriptions of the foregoing method embodiments, which are not repeated herein for brevity.
Fig. 5 is a schematic hardware structure of an electronic device according to an embodiment of the present application. The electronic device 2 comprises a processor 21 and a memory 22. Optionally, the electronic device 2 further comprises input means 23 and output means 24. The processor 21, memory 22, input device 23, and output device 24 are coupled by connectors, including various interfaces, transmission lines or buses, etc., as not limited in this application. It should be understood that in various embodiments of the present application, coupled is intended to mean interconnected by a particular means, including directly or indirectly through other devices, e.g., through various interfaces, transmission lines, buses, etc.
The processor 21 may comprise one or more processors, for example one or more CPUs, which in the case of a single CPU may be a single core CPU or a multi-core CPU. Alternatively, the processor 21 may be a processor group formed by a plurality of GPUs, and the plurality of processors are coupled to each other through one or more buses. In the alternative, the processor may be another type of processor, and the embodiment of the present application is not limited.
Memory 22 may be used to store computer program instructions as well as various types of computer program code for performing aspects of the present application. Optionally, the memory includes, but is not limited to, a random access memory (random access memory, RAM), a read-only memory (ROM), an erasable programmable read-only memory (erasable programmable read only memory, EPROM), or a portable read-only memory (compact disc read-only memory, CD-ROM) for associated instructions and data.
The input means 23 are for inputting data and/or signals and the output means 24 are for outputting data and/or signals. The input device 23 and the output device 24 may be separate devices or may be an integral device.
It will be appreciated that in the embodiment of the present application, the memory 22 may be used to store not only relevant instructions, but also relevant data, for example, the memory 22 may be used to store a first request obtained through the input device 23, etc., and the embodiment of the present application is not limited to the data specifically stored in the memory.
It will be appreciated that fig. 5 shows only a simplified design of an electronic device. In practical applications, the electronic device may further include other necessary elements, including but not limited to any number of input/output devices, processors, memories, etc., and all electronic devices that may implement the embodiments of the present application are within the scope of protection of the present application.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein. It will be further apparent to those skilled in the art that the descriptions of the various embodiments herein are provided with emphasis, and that the same or similar parts may not be explicitly described in different embodiments for the sake of convenience and brevity of description, and thus, parts not described in one embodiment or in detail may be referred to in the description of other embodiments.
In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted across a computer-readable storage medium. The computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, digital subscriber line (digital subscriber line, DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital versatile disk (digital versatile disc, DVD)), or a semiconductor medium (e.g., a Solid State Disk (SSD)), or the like.
Those of ordinary skill in the art will appreciate that implementing all or part of the above-described method embodiments may be accomplished by a computer program to instruct related hardware, the program may be stored in a computer readable storage medium, and the program may include the above-described method embodiments when executed. And the aforementioned storage medium includes: a read-only memory (ROM) or a random access memory (random access memory, RAM), a magnetic disk or an optical disk, or the like.

Claims (11)

1. A data processing method, wherein the data processing method is applied to a data processing apparatus that runs n threads including a target thread, the method comprising:
determining a target time for a target coroutine in the target thread to process a first request;
the data processing apparatus invokes the target coroutine to process the first request at the target time.
2. The method of claim 1, wherein determining a target time for a target coroutine in the target thread to process a first request comprises:
and under the condition that the target coroutine is determined to have the authority of calling the hardware resource, determining the target time for the target coroutine in the target thread to process the first request.
3. The method of claim 2, wherein the determining a target time for a target coroutine in the target thread to process the first request is preceded by determining that the target coroutine has permission to invoke a hardware resource, the method further comprising:
under the condition that the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing device, determining that the target cooperative program has the authority of calling hardware resources; the global token address stores a global token having the right to invoke a hardware resource.
4. A method according to claim 3, wherein, in case the private token address of the target coroutine is successfully exchanged with the global token address of the data processing apparatus, the method further comprises, before determining that the target coroutine has the right to invoke a hardware resource:
performing an atomic operation on the private token address and the global token address;
and under the condition that the original value of the private token address is changed, the private token address of the target cooperative program is successfully exchanged with the global token address of the data processing device.
5. The method of claim 4, wherein the performing an atomic operation on the private token address and the global token address comprises:
the target coroutine acquires the target number of the request to be processed; the request to be processed is a request with determined processing time;
the target coroutine sends an atomic operation request to the data processing device under the condition that the target quantity is smaller than or equal to a threshold value;
the data processor performs an atomic operation on the private token address and the global token address if the atomic operation request is detected.
6. The method of claim 4, wherein the data processing apparatus, after invoking the target coroutine at the target time to process the first request, further comprises:
and cleaning up the token stored in the global token address under the condition that the target coroutine finishes processing the first request.
7. The method of any of claims 1-6, wherein the determining a target time for a target co-process in the target thread to process a first request comprises:
acquiring the target number of the requests to be processed; the request to be processed is a request with determined processing time;
And obtaining the target time according to the target number and the processing time of the to-be-processed request.
8. The method of any of claims 1 to 6, wherein prior to the data processing apparatus invoking the target coroutine at the target time to process the first request, the method further comprises: the data processing device invokes the target coroutine to process a second request before the target time; the second request is different from the first request.
9. A data processing apparatus that runs n threads, the n threads including a target thread, the data processing apparatus comprising:
a first processing unit, configured to determine a target time for a target coroutine in the target thread to process a first request;
and the second processing unit is used for calling the target coroutine to process the first request at the target time by the data processing device.
10. An electronic device, comprising: a processor and a memory for storing computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform the method of any one of claims 1 to 8.
11. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of any of claims 1 to 8.
CN202211261366.5A 2022-10-14 2022-10-14 Data processing method and device, electronic equipment and computer readable storage medium Pending CN117785434A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211261366.5A CN117785434A (en) 2022-10-14 2022-10-14 Data processing method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211261366.5A CN117785434A (en) 2022-10-14 2022-10-14 Data processing method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN117785434A true CN117785434A (en) 2024-03-29

Family

ID=90378690

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211261366.5A Pending CN117785434A (en) 2022-10-14 2022-10-14 Data processing method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN117785434A (en)

Similar Documents

Publication Publication Date Title
CN108683604B (en) Concurrent access control method, terminal device, and medium
US11605087B2 (en) Method and apparatus for identifying identity information
CN111901249A (en) Service current limiting method, device, equipment and storage medium
CN115378735B (en) Data processing method and device, storage medium and electronic equipment
CN111597040A (en) Resource allocation method, device, storage medium and electronic equipment
CN109995787A (en) A kind of data processing method and relevant device
CN114925015A (en) Data processing method, device, equipment and medium based on multi-core processor
CN112463266A (en) Execution policy generation method and device, electronic equipment and storage medium
CN111125168B (en) Data processing method and device, electronic equipment and storage medium
CN111913815A (en) Call request processing method and device, electronic equipment and readable storage medium
CN117785434A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN110865848B (en) Component interception method and terminal equipment
US9628401B2 (en) Software product instance placement
CN109284177B (en) Data updating method and device
CN114374657A (en) Data processing method and device
CN111367694B (en) Event processing method, server and computer storage medium
CN113961364A (en) Large-scale lock system implementation method and device, storage medium and server
CN113726673A (en) Service gateway flow control method, device, equipment and storage medium
CN112188012A (en) Method and device for establishing customer service session, electronic equipment and readable storage medium
CN113055350A (en) Data transmission method, device, equipment and readable storage medium
CN104267929A (en) Computing system and method of operating lock in same
CN108874564A (en) A kind of inter-process communication methods, electronic equipment and readable storage medium storing program for executing
CN117785433A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN110968370B (en) Data processing method and device
WO2024109388A1 (en) Feature synchronization method and apparatus, and computer device, storage medium and program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination