Message sending method and electronic device

By dynamically determining independent or shared communication modules in the communication system and adjusting them according to the token quantity threshold, the latency problem of the communication system under low-concurrency and high-concurrency IO models is solved, and the processing efficiency and resource utilization of the storage system are improved.

CN120915755BActive Publication Date: 2026-01-27INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202511441322.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-10
Publication Date
2026-01-27
Estimated Expiration
2045-10-10

AI Technical Summary

Technical Problem

Existing communication systems cannot simultaneously meet low latency requirements under both low-concurrency and high-concurrency I/O models, resulting in bottlenecks in storage systems in terms of processing latency and CPU resource allocation efficiency.

Method used

When a business module sends a message, the communication module of the target processing unit is dynamically determined to be either an independent communication module or a shared communication module. This is adjusted based on the threshold of the number of used and unused tokens. Using an independent communication module reduces thread switching, while using a shared communication module enables message aggregation and dynamically adjusts CPU resource allocation.

Benefits of technology

Under low-concurrency and high-concurrency I/O models, the communication module is dynamically adjusted, which improves the efficiency of CPU resource allocation, reduces the processing latency of the communication system, and enhances message sending efficiency and the overall performance of the storage system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120915755B_ABST
    Figure CN120915755B_ABST
Patent Text Reader

Abstract

The present disclosure provides a message sending method and an electronic device, relating to the technical field of communication, in the case of sending a message by a service module, obtaining the used token quantity and / or unused token quantity of a target processing unit corresponding to the service module; in the case that the used token quantity is less than a first quantity threshold and / or the unused token quantity is greater than a second quantity threshold, determining that the communication module corresponding to the target processing unit is an independent communication module; in the case that the used token quantity is greater than a third quantity threshold and / or the unused token quantity is less than a fourth quantity threshold, determining that the communication module corresponding to the target processing unit is a shared communication module, wherein the first quantity threshold is less than or equal to the third quantity threshold, and the second quantity threshold is greater than or equal to the fourth quantity threshold; and sending the message by using the independent communication module or the shared communication module. The message processing delay of the communication system can be reduced, the sending efficiency of the message can be improved, and the overall performance of the storage system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of communication technology, and in particular to a message sending method and an electronic device. Background Technology

[0002] In today's digital age, users are increasingly concerned about data security. To ensure that enterprise and personal data is not lost in the event of power outages or other failures, storage systems often use reliable communication systems to back up redundant data across multiple storage nodes. This ensures that even if a single or multiple nodes fail, a backup node will still provide data storage services. However, the communication system can add a data copying and mirroring process to complete user input / output requests (IO requests), increasing the processing latency of the entire IO process. Since the capabilities of the communication system determine the performance of the entire storage system, the processing latency of the communication system becomes a key concern. Summary of the Invention

[0003] This disclosure provides a message sending method and an electronic device. Its main purpose is to solve the problem of how to reduce the processing latency of communication systems and improve the sending efficiency of service modules when sending messages.

[0004] According to a first aspect of this disclosure, a message sending method is provided, comprising:

[0005] When a business module sends a message, obtain the number of used tokens and / or the number of unused tokens of the target processing unit corresponding to the business module;

[0006] If the number of used tokens is less than a first threshold and / or the number of unused tokens is greater than a second threshold, the communication module corresponding to the target processing unit is determined to be an independent communication module.

[0007] If the number of used tokens is greater than a third threshold and / or the number of unused tokens is less than a fourth threshold, the communication module corresponding to the target processing unit is determined to be a shared communication module, wherein the first threshold is less than or equal to the third threshold and the second threshold is greater than or equal to the fourth threshold.

[0008] The message is sent using either the independent communication module or the shared communication module.

[0009] According to a second aspect of this disclosure, a message sending apparatus is provided, comprising:

[0010] The information acquisition unit is used to acquire the number of used tokens and / or the number of unused tokens of the target processing unit corresponding to the business module when the business module sends a message;

[0011] The module determination unit is used to determine that the communication module corresponding to the target processing unit is an independent communication module when the number of used tokens is less than a first quantity threshold and / or the number of unused tokens is greater than a second quantity threshold.

[0012] The module determination unit is further configured to determine that the communication module corresponding to the target processing unit is a shared communication module when the number of used tokens is greater than a third quantity threshold and / or the number of unused tokens is less than a fourth quantity threshold, wherein the first quantity threshold is less than or equal to the third quantity threshold, and the second quantity threshold is greater than or equal to the fourth quantity threshold.

[0013] A message sending unit is used to send the message using the independent communication module or the shared communication module.

[0014] According to a third aspect of this disclosure, an electronic device is provided, comprising:

[0015] At least one processor; and

[0016] A memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect above.

[0018] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method described in the first aspect above.

[0019] According to a fifth aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method described in the first aspect above.

[0020] This disclosure allows for the following: when a business module sends a message, the number of used tokens and / or unused tokens of the target processing unit corresponding to the business module is obtained; if the number of used tokens is less than a first threshold and / or the number of unused tokens is greater than a second threshold, the communication module corresponding to the target processing unit is determined to be an independent communication module; if the number of used tokens is greater than a third threshold and / or the number of unused tokens is less than a fourth threshold, the communication module corresponding to the target processing unit is determined to be a shared communication module, wherein the first threshold is less than or equal to the third threshold, and the second threshold is greater than or equal to the fourth threshold; the message is sent using either the independent communication module or the shared communication module. Therefore, the communication module can be dynamically determined based on the number of tokens, allowing for dynamic adjustment and selection of the optimal communication module under low-concurrency and high-concurrency IO model pressures. This improves the allocation efficiency of the central processing unit (CPU) resources of the business module and the communication module, reduces processing latency when the communication system sends messages, improves message sending efficiency, and enhances the overall performance of the storage system.

[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0022] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:

[0023] Figure 1 This is a background diagram illustrating a message sending method provided in an embodiment of the present disclosure;

[0024] Figure 2 This is a background diagram illustrating another message sending method provided in an embodiment of the present disclosure;

[0025] Figure 3 This is a schematic diagram of an overall system framework provided in an embodiment of this disclosure;

[0026] Figure 4 A flowchart illustrating another message sending method provided in an embodiment of this disclosure;

[0027] Figure 5 This is a schematic diagram of a message sending device provided in an embodiment of the present disclosure. Detailed Implementation

[0028] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0029] According to some implementations, latency is an important indicator of a communication system's capabilities, and the latency performance of a storage system varies under different I / O models. Some storage systems can maintain low and good latency under low concurrency, but experience high latency and limited bandwidth under high concurrency. Conversely, some storage systems can maintain good latency under high concurrency, but suffer from unsatisfactory latency under low concurrency.

[0030] In some implementations, storage systems are complex and have numerous modules. To improve the overall processing capacity of the storage system, each business module is often bound to an independent and fixed CPU core. The communication module can employ two approaches. In the first approach, the communication module and the upper-layer business modules are isolated and use different CPU cores. When a business module sends data, it needs to copy the data to the communication module's buffer and notify the shared communication module's sending end to send the message. After receiving the message, the communication module's receiving end copies the data to the business module's buffer and notifies the business module to process it. In the second approach, the communication module and the upper-layer business modules use the same core. When a business module sends a message, it directly calls the communication module's sending interface, eliminating the need for inter-thread notification. After receiving the message, the receiving end directly calls back the business module's message processing interface. However, neither of these approaches can simultaneously meet the low-latency requirements under both low-concurrency and high-concurrency I / O.

[0031] Specifically, in the first approach, the upper-layer business module and communication module cores are independent, greatly reducing memory access latency and performance loss caused by CPU cache misses. However, the message communication process involves multiple thread switching and wake-up processes: 1) The business module notifies the sender to send a message; 2) The receiver notifies the business module to process the message. In low-concurrency I / O scenarios, the latency caused by thread switching and wake-up is much higher than the I / O message processing itself. A large amount of latency is consumed in unnecessary I / O processing, resulting in low overall efficiency. Furthermore, the communication module uses a fixed number of cores, and CPU resources are insufficient under high-concurrency I / O, becoming a bottleneck for the entire storage system.

[0032] For the second approach, the upper-layer business module and communication module share the same core. The communication module involves intermediate processes such as message assembly, underlying driver sending / polling / receiving, message verification, and parsing. Under high-concurrency I / O, this involves the allocation and release of a large amount of memory resources. Furthermore, the shared core of the business module and communication module easily leads to numerous CPU cache misses, all of which consume significant CPU resources. While this reduces the latency of thread switching and wake-up, the CPU utilization of the business module's bound execution will be higher, resulting in long queuing times for business module tasks and becoming a bottleneck for the entire storage system.

[0033] The message sending method and electronic device according to embodiments of the present disclosure are described below with reference to the accompanying drawings.

[0034] Figure 1 This is a flowchart illustrating a message sending method provided in an embodiment of this disclosure. Figure 1 As shown, the method includes the following steps:

[0035] Step 101: When the business module sends a message, obtain the number of used tokens and / or the number of unused tokens of the target processing unit corresponding to the business module;

[0036] Step 102: If the number of used tokens is less than the first threshold and / or the number of unused tokens is greater than the second threshold, determine that the communication module corresponding to the target processing unit is an independent communication module.

[0037] Step 103: If the number of used tokens is greater than the third quantity threshold and / or the number of unused tokens is less than the fourth quantity threshold, determine that the communication module corresponding to the target processing unit is a shared communication module, wherein the first quantity threshold is less than or equal to the third quantity threshold and the second quantity threshold is greater than or equal to the fourth quantity threshold.

[0038] Step 104: Send a message using either an independent communication module or a shared communication module.

[0039] Figure 2 This is a flowchart illustrating another message sending method provided in an embodiment of this disclosure. Figure 2 As shown, the method includes the following steps:

[0040] Step 201: When the business module sends a message, obtain the number of tokens used by the target processing unit corresponding to the business module;

[0041] According to some embodiments, the executing entity of the embodiments of this disclosure may be, for example, a network device. The name of the network device is not limited. For example, the network device may also be called a server, or a server cluster, etc. The network device does not specifically refer to a single fixed device. For example, when the structure of the network device changes, the network device may also change accordingly. For example, when the device identifier of the network device changes, the network device may also change accordingly. Specifically, the executing entity of the embodiments of this disclosure may also be, for example, a communication system.

[0042] According to some embodiments, a service module may be, for example, a functional module in a communication system responsible for processing and sending messages. This service module does not specifically refer to a single, fixed module. For example, when the service module identifier changes, the service module may also change accordingly. Similarly, when the sender and receiver of a message change, the service module may also change accordingly.

[0043] In some embodiments, the target processing unit may be a processing unit corresponding to a business module, and this target processing unit does not specifically refer to a fixed unit. For example, when the business module changes, the target processing unit may also change accordingly. The processing unit may also be referred to as a CPU core. A CPU core is the basic processing unit of a central processing unit (CPU), responsible for executing program instructions and processing data. Each business module may be pre-bound to a CPU core, i.e., pre-bound to a processing unit.

[0044] According to some embodiments, the token count may include, for example, token-related information. The token count may include the number of used tokens or the number of unused tokens. The number of used tokens may, for example, be the number of tokens that have already been used. The number of used tokens does not specifically refer to any fixed information.

[0045] In some embodiments, the number of tokens used by the target processing unit corresponding to the business module can be obtained when the business module sends a message.

[0046] According to some embodiments, Figure 3 This is a schematic diagram of an overall system framework provided in an embodiment of the present disclosure, such as... Figure 3As shown, this communication module can also be called a communication instance. Each business module can be bound to an independent and fixed CPU core. An independent communication module can be deployed on the CPU core of each business module. To avoid message transmission latency caused by switching between communication instances and the underlying driver thread, each network interface card (NIC) supports hardware / driver multi-queues. During driver initialization, a corresponding number of driver queues are requested and created according to the number of communication instances. Each driver queue is bound to a fixed CPU core and allocated independent sending resources, sending message buffers, receiving resources, and receiving message buffers. Each communication instance is associated with one driver queue. When a communication instance sends a message, it prioritizes sending it to the driver queue associated with the current core. Each communication instance / driver queue is independent and does not affect the others.

[0047] According to some embodiments, the communication module is divided into an independent communication module and a shared communication module. To reduce thread switching and wake-up operations between the business module and the communication module in low-concurrency scenarios, an independent communication module can be deployed on the core of the business module. When the business module sends a message, it can directly call the currently deployed independent communication module if it determines whether to use the independent communication module based on the number of tokens.

[0048] In some implementations, to reduce task queuing issues caused by high CPU usage due to the shared core of the business module and communication module in high-concurrency scenarios, a shared communication module can be deployed simultaneously on a non-business core. This communication instance provides multiple message queues according to the core of the business deployment. Each message queue supports message enqueueing, message caching, message dequeueing, message aggregation, and message sending. Multiple messages can be aggregated into a single message for sending, thereby reducing the frequency of driver message sending and lowering CPU resource consumption at the driver layer, preventing the core where the shared communication module is deployed from becoming a performance bottleneck.

[0049] In some embodiments, the method further includes:

[0050] Based on the processor's processing power, the initial number of tokens for each processing unit of the processor is determined. Therefore, determining the number of tokens based on processing power improves the matching between the number of tokens and processing power, increases the accuracy of token determination, improves the accuracy of communication module determination, and enhances message transmission efficiency.

[0051] In some embodiments, during system initialization, each CPU core maintains a fixed initial token amount (credit) based on the current CPU processing power. The more powerful the CPU, the larger the number of tokens allocated to each core. This initial token amount can, for example, indicate the initially allocated token amount, and can be, for example, the sum of used and unused tokens.

[0052] In some embodiments, determining the initial number of tokens corresponding to each processing unit of the processor includes:

[0053] When each processing unit corresponds to multiple business modules, the initial number of tokens for each business module is determined according to the priority of each business module among the multiple business modules.

[0054] According to some embodiments, multiple types of business modules are deployed on the current processing unit, i.e., the CPU core. The number of tokens to be allocated to each business module can be calculated according to the priority of the business modules and the proportion. The calculation formula can be as shown in formula (1):

[0055] service_credit(service_credit = credit * (service_priorty / sum(all_priority))) (1)

[0056] Where service_credit is the service credit; credit is the total number of tokens; service_priority is the service priority; and sum(all_priority) is the sum of the priorities of all services.

[0057] The priority of this business module can be determined based on the priority setting instruction or the business type corresponding to the business module.

[0058] Step 202: If the number of tokens used is less than the first quantity threshold, determine that the communication module corresponding to the target processing unit is an independent communication module.

[0059] According to some embodiments, the communication module may also be referred to as a communication instance, and the communication module may be a module used by both parties to communicate. The communication module is not specifically defined as a fixed module. For example, the communication module may change accordingly when the number of tokens changes. For example, the communication module may also change accordingly when the target processing unit changes.

[0060] In some embodiments, the conditions for determining a communication module can be used, for example, to determine whether to use the communication module. Different communication modules can correspond to different conditions for determining each communication module in a different set. The conditions for determining each communication module in this set can, for example, be a quantity threshold.

[0061] According to some embodiments, an independent communication module can be used, for example, as a communication module that independently sends a single message. This independent communication module does not specifically refer to a fixed module. For example, when the independent communication module changes, the independent communication module can also change accordingly.

[0062] In some embodiments, the first quantity threshold may be, for example, a threshold used to determine whether to use an independent communication module based on the number of tokens used. This first quantity threshold is not specifically a fixed threshold. For example, the first quantity threshold may change accordingly when the value corresponding to it changes. Similarly, the first quantity threshold may change accordingly when the method of determining it changes.

[0063] According to some embodiments, a communication module is used to send messages, including:

[0064] An independent communication module is used to encapsulate the message and obtain the first encapsulated message;

[0065] Obtain the first sending resource corresponding to the message from the resource pool, and store the first encapsulated message in the cache area of ​​the first sending resource;

[0066] The first encapsulated message is transmitted to the corresponding receive resource buffer at the receiving end via direct memory access.

[0067] In some embodiments, the first encapsulated message may be a message obtained by an independent communication module encapsulating the message to be sent. The "first" in this first encapsulated message is used to distinguish it from other encapsulated messages, and the first encapsulated message does not specifically refer to a particular fixed message. For example, when the message to be sent changes, the first encapsulated message may also change accordingly.

[0068] According to some embodiments, the number of used tokens can specifically be the number of tokens currently allocated. The first and second quantity thresholds can be the same, for example, the first quantity threshold could be the service credit (service_credit). When a business module sends a message, it can compare the currently allocated tokens with the service credit (service_credit). If the currently allocated tokens are less than the service_credit, the independent communication module associated with the current core is directly searched. The current communication module encapsulates the message content, sets a message transmission completion callback function, and submits it to the underlying driver associated with the current core. The underlying driver retrieves an available sending resource from the sending resource pool, copies the message content to the sending resource buffer, transmits it to the receiving resource buffer of the peer via Direct Memory Access (DMA), and increments the currently allocated tokens by 1. When message transmission is complete, the message transmission completion callback function set during sending is called, and the currently allocated tokens are decremented by 1 in the callback function. The peer, i.e., the message receiver, can query for the arrival of a message through CPU polling and submit the data in the receiving resource buffer to the communication module, which then submits it to the business module. The message sending process on the local end (i.e., the message sending end) is directly called and processed from top to bottom by the business module / communication module / driver module without thread switching, and the processing flow on the remote end is the same.

[0069] Step 203: If the number of used tokens is greater than the third quantity threshold, determine that the communication module corresponding to the target processing unit is a shared communication module, wherein the first quantity threshold is less than or equal to the third quantity threshold.

[0070] In some embodiments, a shared communication module may be used, for example, as a communication module that jointly sends multiple messages.

[0071] In some embodiments, the third quantity threshold may be, for example, a threshold for determining whether to use the shared communication module based on the number of tokens used.

[0072] According to some embodiments, a communication module is used to send messages, including:

[0073] The shared communication module adds messages to the message queue corresponding to the shared communication module and notifies the shared communication module to poll the message queue.

[0074] When the control communication module polls the message queue, according to the message queue information, at least one message corresponding to the message queue is encapsulated into a message structure in sequence to obtain the second encapsulated message;

[0075] Obtain the second sending resource corresponding to the message from the resource pool, and store the second encapsulated message in the buffer of the second sending resource;

[0076] The second encapsulated message is transmitted to the corresponding receive resource buffer at the receiving end via direct memory access.

[0077] In some embodiments, the second encapsulated message may be, for example, a message obtained by a shared communication module encapsulating at least one message. The "second" in this second encapsulated message is used to distinguish it from other encapsulated messages, and the second encapsulated message does not specifically refer to a particular fixed message. For example, when the number of messages in at least one message changes, the second encapsulated message may also change accordingly.

[0078] According to some implementations, if the currently allocated tokens are greater than `service_credit`, the shared communication module associated with the current core is found, the message is added to the shared communication module's message queue, and the shared communication module is notified to poll the message queue. When polling the message queue, multiple messages are sequentially encapsulated into a message structure and sent via the driver. Although the business module and the shared communication module are not on the same CPU core, involving thread switching and wake-up, this also provides the possibility for message aggregation. To improve the message aggregation capability of the shared communication instance, multiple business modules on different cores can simultaneously add messages to the shared communication module's message queue. This allows a single message at the driver layer to carry more business data, significantly improving transmission efficiency. In high-concurrency scenarios, driver layer latency can be significantly reduced.

[0079] According to some embodiments, the method further includes:

[0080] Once it is confirmed that the message has been sent, the number of tokens used is adjusted, and the adjusted number of tokens used is determined.

[0081] According to some embodiments, the number of used tokens is adjusted, and the adjusted number of used tokens is determined, including:

[0082] Increment the number of tokens used by one to determine the adjusted number of tokens used.

[0083] In some embodiments, the number of tokens used can be adjusted through a callback function. Specifically, for example, a callback function can be set when the message is encapsulated to indicate that the message transmission is complete. When the message is sent, the callback function can be called, in which the number of tokens used has been incremented by 1, and the number of tokens used can be adjusted.

[0084] Step 204: Send a message using either an independent communication module or a shared communication module.

[0085] According to some embodiments, the method further includes:

[0086] Obtain the module adjustment information corresponding to the target processing unit;

[0087] Based on the module adjustment information, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted. This reduces the situation where the business module and the independent communication module share a core, resulting in high core CPU utilization, long task queuing times, and low execution efficiency. It also reduces task queuing time and improves execution efficiency.

[0088] According to some embodiments, based on module adjustment information, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted, including:

[0089] If the module adjustment information meets the adjustment conditions, obtain the processor utilization rate and token utilization rate within the historical time period;

[0090] Based on processor utilization and token utilization, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted. Therefore, by dynamically adjusting the maximum number of tokens through this mechanism, the CPU cores of the business module are maintained within a normal utilization range, reducing task queuing latency and thus improving overall performance.

[0091] In some implementations, each CPU core creates a detection timer during the initialization phase to dynamically adjust the proportion of messages sent by the current core through independent communication instances. When the timer triggers, it calculates the CPU utilization and token utilization (currently allocated tokens / service_credit) within the current 30-second period. If the CPU utilization is greater than 80% and the token utilization is greater than 90%, the service_credit of all business modules on the current core is reduced until a minimum threshold is reached. If the CPU utilization is less than 50% and the token utilization is greater than 90%, the service_credit of all business modules on the current core is increased until a maximum threshold is reached.

[0092] This disclosure allows for the following: when a business module sends a message, the number of used tokens for the target processing unit corresponding to that business module is obtained; if the number of used tokens is less than a first threshold, the communication module corresponding to the target processing unit is determined to be an independent communication module; if the number of used tokens is greater than a third threshold, the communication module corresponding to the target processing unit is determined to be a shared communication module, wherein the first threshold is less than or equal to the third threshold; and the message is sent using either an independent communication module or a shared communication module. Therefore, the communication module can be dynamically determined based on the number of used tokens. This allows for dynamic adjustment and selection of the optimal communication module under low-concurrency and high-concurrency I / O model pressures, improving the CPU resource allocation efficiency of the business module and communication module, reducing message processing latency in the communication system, increasing message sending efficiency, and enhancing the overall performance of the storage system.

[0093] It should be noted that the embodiments of this disclosure may include multiple steps. For ease of description, these steps are numbered, but these numbers are not a limitation on the execution time slots or execution order between the steps; these steps can be implemented in any order, and the embodiments of this disclosure do not limit this.

[0094] Furthermore, in one possible implementation of this embodiment, Figure 4 This is a flowchart illustrating another message sending method provided in an embodiment of this disclosure. Figure 4 As shown, the method includes the following steps:

[0095] Step 301: When the business module sends a message, obtain the number of unused tokens of the target processing unit corresponding to the business module;

[0096] The relevant processes are as described above and will not be repeated here.

[0097] In some embodiments, the method further includes:

[0098] Based on the processor's processing power, the initial number of tokens for each processing unit of the processor is determined. Therefore, determining the number of tokens based on processing power improves the matching between the number of tokens and processing power, increases the accuracy of token determination, improves the accuracy of communication module determination, and enhances message transmission efficiency.

[0099] In some embodiments, during system initialization, each CPU core maintains a fixed initial token amount (credit) based on the current CPU processing power. The more powerful the CPU, the larger the number of tokens allocated to each core. When the initial token amount is acquired but the scheme is not executed, this initial token amount can, for example, be the same as the number of unused tokens.

[0100] In some embodiments, determining the initial number of tokens corresponding to each processing unit of the processor includes:

[0101] When each processing unit corresponds to multiple business modules, the initial number of tokens for each business module is determined according to the priority of each business module among the multiple business modules.

[0102] Step 302: If the number of unused tokens is greater than the second quantity threshold, determine that the communication module corresponding to the target processing unit is an independent communication module;

[0103] The relevant processes are as described above and will not be repeated here.

[0104] In some embodiments, the second quantity threshold may be, for example, a threshold for determining whether to use an independent communication module based on the number of unused tokens.

[0105] According to some embodiments, a communication module is used to send messages, including:

[0106] An independent communication module is used to encapsulate the message and obtain the first encapsulated message;

[0107] Obtain the first sending resource corresponding to the message from the resource pool, and store the first encapsulated message in the cache area of ​​the first sending resource;

[0108] The first encapsulated message is transmitted to the corresponding receive resource buffer at the receiving end via direct memory access.

[0109] In some embodiments, the first encapsulated message may be a message obtained by an independent communication module encapsulating the message to be sent. The "first" in this first encapsulated message is used to distinguish it from other encapsulated messages, and the first encapsulated message does not specifically refer to a particular fixed message. For example, when the message to be sent changes, the first encapsulated message may also change accordingly.

[0110] According to some embodiments, the number of used tokens can specifically be the number of tokens currently allocated. The first and second quantity thresholds can be the same, for example, the first quantity threshold could be the service credit (service_credit). When a business module sends a message, it can compare the currently allocated tokens with the service credit (service_credit). If the currently allocated tokens are less than the service_credit, the independent communication module associated with the current core is directly searched. The current communication module encapsulates the message content, sets a message transmission completion callback function, and submits it to the underlying driver associated with the current core. The underlying driver retrieves an available sending resource from the sending resource pool, copies the message content to the sending resource buffer, transmits it to the receiving resource buffer of the peer via Direct Memory Access (DMA), and increments the currently allocated tokens by 1. When message transmission is complete, the message transmission completion callback function set during sending is called, and the currently allocated tokens are decremented by 1 in the callback function. The peer, i.e., the message receiver, can query for the arrival of a message through CPU polling and submit the data in the receiving resource buffer to the communication module, which then submits it to the business module. The message sending process on the local end (i.e., the message sending end) is directly called and processed from top to bottom by the business module / communication module / driver module without thread switching, and the processing flow on the remote end is the same.

[0111] Step 303: If the number of unused tokens is less than the fourth quantity threshold, determine that the communication module corresponding to the target processing unit is a shared communication module, wherein the third quantity threshold is greater than or equal to the fourth quantity threshold.

[0112] The relevant processes are as described above and will not be repeated here.

[0113] In some embodiments, the fourth quantity threshold may be, for example, a threshold for determining whether to use the shared communication module based on the number of unused tokens.

[0114] According to some embodiments, a communication module is used to send messages, including:

[0115] The shared communication module adds messages to the message queue corresponding to the shared communication module and notifies the shared communication module to poll the message queue.

[0116] When the control communication module polls the message queue, according to the message queue information, at least one message corresponding to the message queue is encapsulated into a message structure in sequence to obtain the second encapsulated message;

[0117] Obtain the second sending resource corresponding to the message from the resource pool, and store the second encapsulated message in the buffer of the second sending resource;

[0118] The second encapsulated message is transmitted to the corresponding receive resource buffer at the receiving end via direct memory access.

[0119] In some embodiments, the second encapsulated message may be, for example, a message obtained by a shared communication module encapsulating at least one message. The "second" in this second encapsulated message is used to distinguish it from other encapsulated messages, and the second encapsulated message does not specifically refer to a particular fixed message. For example, when the number of messages in at least one message changes, the second encapsulated message may also change accordingly.

[0120] According to some implementations, if the currently allocated tokens are greater than `service_credit`, the shared communication module associated with the current core is found, the message is added to the shared communication module's message queue, and the shared communication module is notified to poll the message queue. When polling the message queue, multiple messages are sequentially encapsulated into a message structure and sent via the driver. Although the business module and the shared communication module are not on the same CPU core, involving thread switching and wake-up, this also provides the possibility for message aggregation. To improve the message aggregation capability of the shared communication instance, multiple business modules on different cores can simultaneously add messages to the shared communication module's message queue. This allows a single message at the driver layer to carry more business data, significantly improving transmission efficiency. In high-concurrency scenarios, driver layer latency can be significantly reduced.

[0121] Step 304: Send a message using an independent communication module or a shared communication module.

[0122] The relevant processes are as described above and will not be repeated here.

[0123] According to some embodiments, the method further includes:

[0124] Once it is confirmed that the message has been sent, the number of unused tokens is adjusted, and the adjusted number of unused tokens is determined.

[0125] According to some embodiments, the number of unused tokens is adjusted, and the adjusted number of unused tokens is determined, including:

[0126] Decrease the number of unused tokens by one to determine the adjusted number of unused tokens.

[0127] According to some embodiments, the method further includes:

[0128] Obtain the module adjustment information corresponding to the target processing unit;

[0129] Based on the module adjustment information, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted. This reduces the situation where the business module and the independent communication module share a core, resulting in high core CPU utilization, long task queuing times, and low execution efficiency. It also reduces task queuing time and improves execution efficiency.

[0130] According to some embodiments, based on module adjustment information, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted, including:

[0131] If the module adjustment information meets the adjustment conditions, obtain the processor utilization rate and token utilization rate within the historical time period;

[0132] Based on processor utilization and token utilization, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted. Therefore, by dynamically adjusting the maximum number of tokens through this mechanism, the CPU cores of the business module are maintained within a normal utilization range, reducing task queuing latency and thus improving overall performance.

[0133] In some implementations, each CPU core creates a detection timer during the initialization phase to dynamically adjust the proportion of messages sent by the current core through independent communication instances. When the timer triggers, it calculates the CPU utilization and token utilization (currently allocated tokens / service_credit) within the current 30-second period. If the CPU utilization is greater than 80% and the token utilization is greater than 90%, the service_credit of all business modules on the current core is reduced until a minimum threshold is reached. If the CPU utilization is less than 50% and the token utilization is greater than 90%, the service_credit of all business modules on the current core is increased until a maximum threshold is reached. When determining which communication module to use for message sending based on service_credit, the ratio of the number of first messages sent through independent communication modules to the number of second messages sent through shared communication modules can be adjusted.

[0134] In one or related embodiments, if the number of unused tokens for the target processing unit is greater than a second threshold, the communication module corresponding to the target processing unit can be determined as an independent communication module; if the number of unused tokens is less than a fourth threshold, the communication module corresponding to the target processing unit can be determined as a shared communication module, wherein the second threshold is greater than or equal to the fourth threshold. Therefore, the required communication module can be determined based on the number of unused tokens, improving the accuracy of communication module determination. When the number of unused tokens is greater than the set maximum number of tokens, message communication preferentially uses the independent communication module, reducing thread switching / wake-up and lowering IO latency under low concurrency. When the number of unused tokens is less than the set maximum number of tokens, message communication preferentially uses the shared communication module, reducing CPU resource consumption at the driver layer and lowering IO latency under high concurrency through the message aggregation mechanism of the shared communication module.

[0135] in, Figure 2 The message sending method shown can be used with Figure 4 The message sending methods shown can be executed simultaneously or selectively. When executing simultaneously, if a conflict arises in selecting a communication module based on a threshold, the selection can be made according to the priority of the number of unused tokens and the number of used tokens, or by issuing a prompt message and selecting a communication module based on the received selection instruction. This disclosure does not limit the scope of these methods.

[0136] According to embodiments of this disclosure, this disclosure also provides a message sending device.

[0137] For example, Figure 5 This is a schematic diagram of a message sending device provided in an embodiment of the present disclosure. The message sending device 500 includes: an information acquisition unit 501, a module determination unit 502, and a message sending unit 503; wherein,

[0138] The information acquisition unit 501 is used to acquire the number of used tokens and / or the number of unused tokens of the target processing unit corresponding to the business module when the business module sends a message.

[0139] The module determination unit 502 is used to determine that the communication module corresponding to the target processing unit is an independent communication module when the number of used tokens is less than a first quantity threshold and / or the number of unused tokens is greater than a second quantity threshold.

[0140] The module determination unit 502 is further configured to determine that the communication module corresponding to the target processing unit is a shared communication module when the number of used tokens is greater than the third quantity threshold and / or the number of unused tokens is less than the fourth quantity threshold, wherein the first quantity threshold is less than or equal to the third quantity threshold and the second quantity threshold is greater than or equal to the fourth quantity threshold.

[0141] The message sending unit 503 is used to send messages using an independent communication module or a shared communication module.

[0142] Furthermore, the message sending unit 503, when sending messages using an independent communication module or a shared communication module, is specifically used for:

[0143] An independent communication module is used to encapsulate the message and obtain the first encapsulated message;

[0144] Obtain the first sending resource corresponding to the message from the resource pool, and store the first encapsulated message in the cache area of ​​the first sending resource;

[0145] The first encapsulated message is transmitted to the corresponding receive resource buffer at the receiving end via direct memory access.

[0146] Furthermore, the message sending unit 503, when sending messages using an independent communication module or a shared communication module, is specifically used for:

[0147] The shared communication module adds messages to the message queue corresponding to the shared communication module and notifies the shared communication module to poll the message queue.

[0148] When the control communication module polls the message queue, according to the message queue information, at least one message corresponding to the message queue is encapsulated into a message structure in sequence to obtain the second encapsulated message;

[0149] Obtain the second sending resource corresponding to the message from the resource pool, and store the second encapsulated message in the buffer of the second sending resource;

[0150] The second encapsulated message is transmitted to the corresponding receive resource buffer at the receiving end via direct memory access.

[0151] Furthermore, module determining unit 502 is also specifically used for:

[0152] Once it is determined that the message has been sent, the number of used tokens and / or the number of unused tokens are adjusted, and the adjusted number of used tokens and / or the adjusted number of unused tokens are determined.

[0153] Furthermore, the module determining unit 502 is used to adjust the number of used tokens and / or the number of unused tokens. Specifically, when determining the adjusted number of used tokens and / or the adjusted number of unused tokens, it is used for:

[0154] Increment the number of tokens used by one to determine the adjusted number of tokens used;

[0155] and / or

[0156] Decrease the number of unused tokens by one to determine the adjusted number of unused tokens.

[0157] Furthermore, the information acquisition unit 501 is also specifically used for:

[0158] The initial number of tokens for each processing unit of the processor is determined based on the processor's processing power.

[0159] Furthermore, the information acquisition unit 501, when determining the initial number of tokens corresponding to each processing unit of the processor, is specifically used for:

[0160] When each processing unit corresponds to multiple business modules, the initial number of tokens for each business module is determined according to the priority of each business module among the multiple business modules.

[0161] Furthermore, the information acquisition unit 501 is also specifically used for:

[0162] Obtain the module adjustment information corresponding to the target processing unit;

[0163] Based on the module adjustment information, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted.

[0164] Furthermore, the information acquisition unit 501, when adjusting the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module based on the module adjustment information, is specifically used for:

[0165] If the module adjustment information meets the adjustment conditions, obtain the processor utilization rate and token utilization rate within the historical time period;

[0166] Based on processor utilization and token utilization, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted.

[0167] It should be noted that the description of the features in the embodiment corresponding to the message sending device can be found in the relevant description of the embodiment corresponding to the message sending method, and will not be repeated here.

[0168] Embodiments of this disclosure also provide an electronic device including a memory and a processor, the memory storing a computer program, the processor being configured to run the computer program to perform the steps in any of the above-described message sending method embodiments.

[0169] Embodiments of this disclosure also provide a computer-readable storage medium storing a computer program configured to execute the steps in any of the above-described message sending method embodiments.

[0170] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0171] Embodiments of this disclosure also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described message sending method embodiments.

[0172] Embodiments of this disclosure also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in any of the above-described message sending method embodiments.

[0173] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0174] The above provides a detailed description of a message sending method provided by this disclosure. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this disclosure without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this disclosure.

Claims

1. A message sending method, characterized in that, include: When a business module sends a message, the number of used tokens and / or unused tokens of the target processing unit corresponding to the business module is obtained. Each business module is bound to an independent and fixed CPU core. An independent communication module is deployed on the CPU core of the business module. Each driver queue is bound to a fixed CPU core and is allocated independent sending resources, sending message buffers, receiving resources, and receiving message buffers. Each communication module is associated with a driver queue. The communication module includes independent communication modules and shared communication modules. Independent communication modules are deployed on the core of the business module, and shared communication modules are deployed on non-business cores. If the number of used tokens is less than a first threshold and / or the number of unused tokens is greater than a second threshold, the communication module corresponding to the target processing unit is determined to be an independent communication module. If the number of used tokens is greater than a third threshold and / or the number of unused tokens is less than a fourth threshold, the communication module corresponding to the target processing unit is determined to be a shared communication module, wherein the first threshold is less than or equal to the third threshold and the second threshold is greater than or equal to the fourth threshold. The message is sent using either the independent communication module or the shared communication module; The method further includes: Obtain the module adjustment information corresponding to the target processing unit; If the module adjustment information meets the adjustment conditions, obtain the processor utilization rate and token utilization rate within the historical time period; Based on the processor utilization rate and the token utilization rate, the ratio of the number of first messages sent by the target processing unit through the independent communication module to the number of second messages sent through the shared communication module is adjusted.

2. The method according to claim 1, characterized in that, Sending the message using the independent communication module or the shared communication module includes: The message is encapsulated using the independent communication module to obtain the first encapsulated message; Obtain the first sending resource corresponding to the message from the resource pool, and store the first encapsulated message in the cache area of ​​the first sending resource; The first encapsulated message is transmitted to the corresponding receive resource buffer at the receiving end via direct memory access.

3. The method according to claim 1, characterized in that, Sending the message using the independent communication module or the shared communication module includes: The shared communication module adds the message to the message queue corresponding to the shared communication module and notifies the shared communication module to poll the message queue. When the communication module polls the message queue, at least one message corresponding to the message queue is sequentially encapsulated into a message structure according to the message queue information to obtain the second encapsulated message; Obtain the second sending resource corresponding to the message from the resource pool, and store the second encapsulated message in the buffer of the second sending resource; The second encapsulated message is transmitted to the corresponding receive resource buffer at the receiving end via direct memory access.

4. The method according to claim 2 or 3, characterized in that, The method further includes: If it is determined that the message has been sent, the number of used tokens and / or the number of unused tokens are adjusted, and the adjusted number of used tokens and / or the adjusted number of unused tokens are determined.

5. The method according to claim 4, characterized in that, The step of adjusting the number of used tokens and / or the number of unused tokens, and determining the adjusted number of used tokens and / or the adjusted number of unused tokens, includes: Increment the number of tokens used by one to determine the adjusted number of tokens used; and / or Subtract one from the number of unused tokens to determine the adjusted number of unused tokens.

6. The method according to claim 1, characterized in that, The method further includes: The initial number of tokens corresponding to each processing unit of the processor is determined based on the processing capability of the processor.

7. The method according to claim 6, characterized in that, Determining the initial number of tokens corresponding to each processing unit of the processor includes: In the case where each processing unit corresponds to multiple business modules, the initial number of tokens corresponding to each business module is determined according to the priority of each business module among the multiple business modules.

8. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the message sending method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Fluid control method and device based on tokens

    CN104780118A

  • Service isolation speed limiting method and device for multiple processor cores

    CN115225580A

  • Token processing method and device, electronic equipment and storage medium

    CN117834543A

  • Token bucket and leaky bucket combined flow limiting method and system for payment system

    CN120389987A