Network card cache management method, device, computer equipment and storage medium

By using a ring data queue and pre-configured cache space in the network card driver, the problem of cache application delay in traditional network card drivers is solved, and efficient data processing and stable performance are achieved.

CN119324905BActive Publication Date: 2025-04-08SHENZHEN NANFEI MICROELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411813673.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-04-08
Estimated Expiration
2044-12-11

AI Technical Summary

Technical Problem

Traditional network card drivers are prone to delays when applying for cache resources, resulting in a decrease in data processing efficiency. Especially in high traffic environments, the complexity of operating system memory management leads to cache application exceptions and CPU resource occupancy problems.

Method used

By receiving data write requests in the ring data queue, using the pre-configured cache space and page reference count, we can determine whether we need to apply for a new cache address, avoid unnecessary cache application operations, and directly write to the current cache space.

Benefits of technology

It realizes efficient data reception and processing, reduces dependence on operating system memory management, avoids cache application exceptions and CPU resource occupation problems, and significantly improves the performance and stability of network cards in high traffic environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119324905B_ABST
    Figure CN119324905B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer network technology, and discloses a network card cache management method, device, computer equipment and storage medium, the method comprising: receiving a data write request for a data segment in a circular data queue; wherein the circular data queue comprises multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space; judging whether a new cache address needs to be applied for according to the occupancy of the current cache space; if not, writing the temporary data into the current cache space; deleting the temporary data in the data segment, and using the data segment to receive new temporary data. The present invention realizes efficient data reception and processing, and significantly improves the performance and stability of the network card in a high-traffic environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer network technology, and in particular to a network card cache management method, device, computer equipment and storage medium. Background Art

[0002] In modern computer network systems, the performance of network cards, as a key component of data transmission, directly affects the data throughput of the entire system. Traditional network card drivers often face performance bottlenecks when processing network packets due to the complexity of operating system memory management. Especially in high-traffic environments, network card drivers may encounter delays when applying for cache resources, resulting in reduced data processing efficiency.

[0003] The general network card receiving operation occurs when the local machine needs to receive remote data, such as when a user downloads a movie or receives an email. In 90% of cases, the network data packets received by the network card will be processed by the operating system in a timely manner. In the process of downloading a movie, the received data is stored in the cache, and the cache is released immediately after the data is written to the disk. In order to receive the messages transmitted on the network in a timely manner, the network card driver generally applies for some caches. The length of these caches is determined by the page size of the operating system and the network card hardware. The network card driver informs the network card hardware of the memory address where the network message can be stored through the descriptor. The network card hardware writes the message to the host memory through DMA (direct memory access) and reports the interrupt notification driver that a new message has been received. The driver is responsible for actively sending the message memory address to the operating system to complete the message reception. In order to continue to receive messages, the driver needs to apply for a new cache and write it into the descriptor to inform the network card hardware. The cache application operation is initiated to the operating system, and the operating system returns the application result based on the currently free cache information.

[0004] The memory management of the operating system is a complex and sophisticated process. Requesting cache operations often triggers a series of complex software logic. For example, when a page fault exception is caused by dense traffic, the operating system needs to update the TLB (address translation lookaside buffer) to find a free page and return it to the network card for use. In extreme cases, the request may even fail, and the network card driver needs to poll multiple times until the request is successful.

[0005] These operations will cause the network card to have no new cache available for a short period of time. The polling operation will also occupy a large amount of precious CPU (central processing unit) resources, and users will perceive high network latency and operating system lag. Summary of the invention

[0006] Based on this, it is necessary to propose a network card cache management method, device, computer equipment and storage medium to address the problem that the existing network card cache application operation relies on the operating system memory management, which is easy to cause cache application exceptions and occupy CPU resources.

[0007] A first aspect of the present invention provides a network card cache management method, the method comprising:

[0008] Receive a data write request for a data segment in a circular data queue; wherein the circular data queue includes multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space;

[0009] Determining whether a new cache address needs to be applied for according to the occupancy of the current cache space;

[0010] If not, writing the temporarily stored data into the current cache space;

[0011] The temporarily stored data in the data segment is deleted, and the data segment is used to receive new temporarily stored data.

[0012] Furthermore, before the step of receiving a data write request for a data segment in the circular data queue, the method further includes:

[0013] A one-to-one corresponding cache space is configured for each data segment, and the cache space includes at least two cache pages, wherein the capacity of one cache page is greater than or equal to the capacity of one of the data segments.

[0014] Further, after the step of writing the temporarily stored data into the current cache space, the following steps are included:

[0015] The page reference count of the current cache space is increased by 1;

[0016] And in a circular order, the data write request for the next data segment in the circular data queue is received in sequence.

[0017] Furthermore, the initial value of the page reference count is 0, and the step of determining whether a new cache address needs to be applied for according to the occupancy of the current cache space includes:

[0018] Determining whether the current value of the page reference count is less than the number of cached pages;

[0019] If so, it is determined that there is no need to apply for a new cache address.

[0020] Furthermore, the step of writing the temporarily stored data into the current cache space includes:

[0021] Searching for unoccupied cache pages in the current cache space in order;

[0022] Get the address of the first unoccupied cache page found;

[0023] The temporarily stored data is written into a cache page corresponding to the address, and the cache page corresponding to the address is marked as occupied.

[0024] Furthermore, after the step of writing the temporarily stored data into the cache page corresponding to the address and marking the cache page corresponding to the address as occupied, the step further includes:

[0025] Determining whether the temporarily stored data has been written into the preset operating system;

[0026] If so, the temporary data of the cache page is cleared, the cache page is marked as free, and the page reference count of the current cache space is reduced by 1.

[0027] Furthermore, after the step of determining whether the current value of the page reference count is less than the number of cached pages, the step further includes:

[0028] If not, it is determined that a new cache address needs to be applied for;

[0029] Sending a cache address application request to the preset operating system;

[0030] After receiving the new cache address assigned by the preset operating system, the temporarily stored data is written into the new cache address.

[0031] A second aspect of the present invention provides a network card cache management device, the device comprising:

[0032] a request receiving module, configured to receive a data write request for a data segment in a circular data queue; wherein the circular data queue includes a plurality of data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space;

[0033] An occupancy determination module, used to determine whether a new cache address needs to be applied for according to the occupancy of the current cache space;

[0034] A cache writing module, used for writing the temporarily stored data into the current cache space if there is no need to apply for a new cache address;

[0035] The data clearing module is used to delete the temporarily stored data in the data segment and use the data segment to receive new temporarily stored data.

[0036] A third aspect of the present invention provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor performs the following steps:

[0037] Receive a data write request for a data segment in a circular data queue; wherein the circular data queue includes multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space;

[0038] Determining whether a new cache address needs to be applied for according to the occupancy of the current cache space;

[0039] If not, writing the temporarily stored data into the current cache space;

[0040] The temporarily stored data in the data segment is deleted, and the data segment is used to receive new temporarily stored data.

[0041] A fourth aspect of the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps:

[0042] Receive a data write request for a data segment in a circular data queue; wherein the circular data queue includes multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space;

[0043] Determining whether a new cache address needs to be applied for according to the occupancy of the current cache space;

[0044] If not, writing the temporarily stored data into the current cache space;

[0045] The temporarily stored data in the data segment is deleted, and the data segment is used to receive new temporarily stored data.

[0046] The network card cache management method, device, computer equipment and storage medium of the present invention receive a data write request of a data segment in a circular data queue; wherein the circular data queue includes multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space; then, it is determined whether a new cache address needs to be applied for according to the occupancy of the current cache space; if a new cache address does not need to be applied for, the temporary data is written into the current cache space; and the temporary data in the data segment is deleted, and the data segment is used to receive new temporary data; thus, the circular data queue and the pre-configured cache space are used to realize efficient data reception and processing, and the network card cache management no longer completely depends on the memory management of the operating system, avoiding unnecessary cache application operations. Especially in a high-traffic environment, the present invention effectively avoids the cache application anomaly and CPU resource occupancy problems caused by the complexity of the operating system memory management, thereby significantly improving the performance and stability of the network card in a high-traffic environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0048] in:

[0049] Figure 1 A flowchart of a network card cache management method in one embodiment;

[0050] Figure 2 is a structural block diagram of a network card cache management device in an embodiment;

[0051] Figure 3 FIG. 4 is a structural block diagram of a computer device in one embodiment. DETAILED DESCRIPTION

[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0053] like Figure 1As shown, in one embodiment, a network card cache management method is provided. The method can be applied to both a terminal and a server. This embodiment is illustrated by applying to a terminal. The network card cache management method specifically includes the following steps:

[0054] S1: receiving a data write request for a data segment in a circular data queue; wherein the circular data queue includes multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space;

[0055] S2: judging whether it is necessary to apply for a new cache address according to the occupancy of the current cache space;

[0056] S3: If not, writing the temporarily stored data into the current cache space;

[0057] S4: deleting the temporarily stored data in the data segment, and using the data segment to receive new temporarily stored data.

[0058] In this embodiment, in the above step S1, the data packet received by the network card is first read into the above circular data queue. The circular data queue is a first-in-first-out (FIFO) data structure, including multiple data segments. The design of the circular data queue ensures the continuity and efficiency of data processing.

[0059] When each data segment is created, a corresponding cache space is pre-configured to store temporary data received from the network card. The temporary data is part of the data in the received data packet. When the data of a data segment is written into the cache space, the storage space of the data segment is released and returns to the end of the circular data queue to receive new network data and enter the queue waiting to be written into the cache space again.

[0060] When the network card receives a new network data packet, it generates a data write request and sends the request to the data segment currently queued first in the circular data queue.

[0061] In the above step S2, after receiving the data write request, the occupancy of the current cache space is checked. If the current cache space has enough remaining capacity to store the temporary data, then there is no need to apply for a new cache address. If there is not enough remaining capacity to store the temporary data, it is necessary to apply for a new cache address from the operating system. For example, this can be achieved by comparing the remaining capacity of the current cache space with the size of the temporary data to be written.

[0062] In the above step S3, if the current cache space has enough remaining capacity, the temporarily stored data is directly written into the current cache space. This step does not require the intervention of the CPU, which greatly improves the speed and efficiency of data writing. This step avoids unnecessary cache application operations, thereby reducing the burden of operating system memory management and reducing performance bottlenecks caused by abnormal cache applications.

[0063] In the above step S4, when the temporary data is successfully written into the current cache space, the temporary data in the data segment is deleted and the data segment is marked as idle to receive new temporary data, thereby ensuring the continuity of the use of the circular data queue, so that the network card can continuously receive and process network data packets.

[0064] By implementing the method of this embodiment, using the circular data queue and pre-configured cache space, efficient data reception and processing are achieved, and the network card cache management is no longer completely dependent on the memory management of the operating system, avoiding unnecessary cache application operations. Especially in a high-traffic environment, the method of this embodiment effectively avoids cache application anomalies and CPU resource occupation problems caused by the complexity of the operating system memory management.

[0065] In a specific embodiment, before the step S1 of receiving a data write request for a data segment in the circular data queue, the method further includes:

[0066] S01: configuring a one-to-one corresponding cache space for each data segment, wherein the cache space includes at least two cache pages, wherein the capacity of one cache page is greater than or equal to the capacity of one of the data segments.

[0067] In this embodiment, the capacity of at least one cache page is designed to be greater than or equal to the capacity of a data segment, so that the temporary data of a data segment can be completely stored in one cache page. The cache space configured for each data segment includes at least two cache pages. When data is being written to one cache page, another cache page can be used as a backup to prepare to receive subsequent data write requests. This avoids processing interruptions and delays caused by a single cache page being occupied.

[0068] For example, in the specific use process, when configuring the cache space, it is necessary to perform it according to the data segment capacity of the network card and the PAGE SIZE (page size) of the operating system environment. For example, if the data segment capacity of the network card is 1518 and the PAGE SIZE is 4096, then the number of application pages is one, the cache space capacity is 4096, and the entire cache space is divided into 2 cache pages, and the capacity of each cache page is 2048; if the data segment capacity of the network card is 4018 and the PAGE SIZE is 4096, then the number of application pages is two, the cache space capacity is 8192, and the entire cache space is divided into 2 cache pages, and the capacity of each cache page is 4096. It can be understood that the specific configuration number of cache pages can be adjusted as needed.

[0069] In a specific embodiment, after the step S3 of writing the temporarily stored data into the current cache space, the following steps are included:

[0070] S5: increasing the page reference count of the current cache space by 1;

[0071] S6: and receiving the data write request for the next data segment in the circular data queue in sequence according to the circular order.

[0072] In this embodiment, in the above step S5, after the temporary data is written into the current cache space, that is, after a cache page is used, the page reference count (PRC) of the cache space is incremented by 1. The page reference count is used to track the number of times the cache page in the cache space is used. When data is written into a cache page, the page reference count is incremented by 1. It can be understood that for a cache space, the maximum increase in its page reference count is equal to the number of cache pages.

[0073] In the above step S6, after completing the data writing and cache space management of the current data segment, the data writing request of the next data segment is received in sequence according to the ring order of the ring data queue, and the steps S1-S4 or S1-S5 of the above embodiment are repeatedly executed for the data of the next data segment, including checking the occupancy of the current cache space, writing temporary data, updating the page reference count, etc., so as to realize continuous writing of data and ensure that the network card can maintain efficient and stable operation in a high-traffic environment.

[0074] In a specific embodiment, the initial value of the page reference count is 0, and the step S2 of determining whether a new cache address needs to be applied for according to the occupancy of the current cache space includes:

[0075] S201: Determine whether the current value of the page reference count is less than the number of cached pages;

[0076] S202: If yes, it is determined that there is no need to apply for a new cache address.

[0077] In this embodiment, when the initial value of the page reference count is set to 0, the maximum value of the page reference count is equal to the number of cache pages. When the page reference count is equal to the number of cache pages, it means that all cache pages in the cache space are in an occupied state, and a new cache address needs to be applied for. If it is less than the number of cache pages, it means that there are still free cache pages available for use. Then, the temporarily stored data can be directly written into the free cache pages without applying for a new cache to the operating system, thereby avoiding unnecessary cache application operations.

[0078] In a specific embodiment, the step S3 of writing the temporarily stored data into the current cache space includes:

[0079] S301: Searching for unoccupied cache pages in the current cache space in order;

[0080] S302: Obtain the address of the first unoccupied cache page found;

[0081] S303: Write the temporarily stored data into the cache page corresponding to the address, and mark the cache page corresponding to the address as occupied.

[0082] In the present embodiment, in the above step S301, when preparing to write the temporarily stored data into the current cache space, first search the cache pages in the cache space in sequence to determine whether there are unoccupied cache pages. For example, the search process can be performed in the order of the cache page numbers or addresses, and the status of each cache page can be checked one by one. If a cache page is marked as "unoccupied", it means that the page can be used to store new data. Specifically, PUTC (page usage tracking count) can be used to mark the usage of the cache page. The initial value of PUTC is set to 0. When the cache page is used, the corresponding PUTC increases by 1. A PUTC value of 1 indicates that the cache page is occupied; when the cache page is finished using, the PUTC of the cache page is reduced by 1 to 0. A PUTC value of 0 indicates that the cache page is in an idle state.

[0083] In the above step S302, after finding the first unoccupied cache page, the address of the cache page is obtained. The address indicates the location of the cache page where the temporarily stored data should be stored. Specifically, PUO (page usage offset) can be used to express the address. Taking the cache space capacity as 4096, the entire cache space is divided into 2 cache pages, and the capacity of each cache page is 2048 as an example, the initial value of PUO is set to 0. When the first cache page is used, PUO changes to 2048, which points to the address of the second cache page. After the second cache page is used, if the first cache page has been used up and is in an idle state, PUO changes back to 0 and points to the address of the first cache page.

[0084] In the above step S303, after obtaining the address of the unoccupied cache page, the temporarily stored data is written into the cache page corresponding to the address, thereby realizing the transfer of data from the data segment of the circular data queue to the cache page. At the same time, the cache page is marked as "occupied", that is, for example, PUTC=1, to prevent subsequent operations from mistakenly writing data into the occupied cache page.

[0085] In a specific embodiment, after the step S303 of writing the temporarily stored data into the cache page corresponding to the address and marking the cache page corresponding to the address as occupied, the method further includes:

[0086] S304: Determine whether the temporarily stored data has been written into the preset operating system;

[0087] S305: If yes, clear the temporary data of the cache page, mark the cache page as free, and reduce the page reference count of the current cache space by 1.

[0088] In this embodiment, in the above step S304, after the data is written to the cache page, it is monitored whether it has completed writing to the preset operating system. Once it is confirmed that the temporary data has been successfully written to the preset operating system, the temporary data of the cache page is cleared and the cache page is marked as free, thereby freeing up cache space so that subsequent data writing operations can correctly identify and use the free cache pages.

[0089] In a specific embodiment, after the step S201 of determining whether the current value of the page reference count is less than the number of cached pages, the step further includes:

[0090] S203: If not, it is determined that a new cache address needs to be applied for;

[0091] S204: Sending a cache address application request to the preset operating system;

[0092] S205: After receiving the new cache address allocated by the preset operating system, the temporarily stored data is written into the new cache address.

[0093] In this embodiment, in the above step S203, after step S201 of determining whether the current value of the page reference count is less than the number of cache pages, if the result is "no", that is, the total of the page reference counts in the current cache space is not less than the preset cache page number threshold, this indicates that the current cache space is saturated and cannot meet new data writing requirements.

[0094] In the above steps S204-S205, when it is determined that a new cache address needs to be applied, a cache address application request is sent to the preset operating system. The above cache address application request may include the size and type of the required cache space and other related parameters. When a new cache address is received, the temporarily stored data is written into the cache space corresponding to the address.

[0095] This embodiment is used in a special high-traffic environment, where the cache space is already saturated, and actively applies to the operating system for a new cache address to expand the storage space.

[0096] This situation in the present embodiment is less likely to occur, especially when the length of the ring data queue is set to be greater than the preset ring length. The polling read time of the ring data queue itself is sufficient to cache page data writes, that is, under normal circumstances, there will be at least one page in the cache space that is idle, and there is no need to re-apply for cache from the operating system.

[0097] Specifically, a network card from a first-tier manufacturer on the market was used for verification, and a performance test tool was used to test the performance of a single stream on the same hardware platform and operating system. The network card was used as the receiving end, and the performance of the native driver was 7.4 Gbit / s, while the driver that incorporated the network card cache management method of the embodiment of the present invention had a performance of 13.5 Gbit / s, an improvement of about 82%. And the performance of the modified driver did not fluctuate during the test, which shows that this device can greatly improve bandwidth data. It has been verified that when using common data transmission operations such as bandwidth testing, FTP (File Transfer Protocol) and scp (Secure Copy), when the ring length of the circular data queue is 512, there is no need to re-apply for cache to the operating system, which shows that the network card cache management method of the embodiment of the present invention can cover most traffic-intensive scenarios.

[0098] like Figure 2 As shown, in one embodiment, a network card cache management device is provided, the device comprising:

[0099] The request receiving module 10 is used to receive a data write request for a data segment in the circular data queue; wherein the circular data queue includes a plurality of data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space;

[0100] An occupancy determination module 20 is used to determine whether a new cache address needs to be applied for according to the occupancy of the current cache space;

[0101] The cache writing module 30 is used to write the temporarily stored data into the current cache space if there is no need to apply for a new cache address;

[0102] The data clearing module 40 is used to delete the temporarily stored data in the data segment and use the data segment to receive new temporarily stored data.

[0103] In a specific embodiment, the network card cache management device further includes:

[0104] The cache space configuration module is used to configure a one-to-one corresponding cache space for each data segment, wherein the cache space includes at least two cache pages, wherein the capacity of a cache page is greater than or equal to the capacity of one of the data segments.

[0105] In a specific embodiment, the network card cache management device further includes:

[0106] A page counting module, used to increase the page reference count of the current cache space by 1;

[0107] The second request receiving module is used to sequentially receive the data write request for the next data segment in the circular data queue in a circular order.

[0108] In a specific embodiment, the initial value of the page reference count is 0, and the occupancy determination module 20 includes:

[0109] A first judging unit, configured to judge whether a current value of the page reference count is less than the number of cached pages;

[0110] The first determination unit is configured to determine that there is no need to apply for a new cache address if the number is less than the number of cache pages.

[0111] In a specific embodiment, the cache writing module 30 includes:

[0112] A search unit, used to sequentially search for unoccupied cache pages in each cache page in the current cache space;

[0113] An address acquisition unit, used to acquire the address of the first unoccupied cache page found;

[0114] A writing unit is used to write the temporarily stored data into a cache page corresponding to the address, and mark the cache page corresponding to the address as occupied.

[0115] In a specific embodiment, the cache writing module 30 further includes:

[0116] A second judgment unit, used to judge whether the temporarily stored data has been written into the preset operating system;

[0117] The second determination unit is configured to clear the temporary data of the cache page, mark the cache page as free, and reduce the page reference count of the current cache space by 1 if writing to the preset operating system is completed.

[0118] In a specific embodiment, the occupancy determination module 20 further includes:

[0119] A third determination unit, configured to determine that a new cache address needs to be applied for if the number is not less than the number of cache pages;

[0120] A cache application unit, used to send a cache address application request to the preset operating system;

[0121] The cache writing unit is used to write the temporarily stored data into the new cache address after receiving the new cache address allocated by the preset operating system.

[0122] The network card cache management device of the embodiment of the present invention realizes efficient data reception and processing by utilizing a circular data queue and a pre-configured cache space, and the network card cache management no longer completely relies on the memory management of the operating system, thereby avoiding unnecessary cache application operations. In particular, in a high-traffic environment, it effectively avoids cache application anomalies and CPU resource occupation problems caused by the complexity of the operating system memory management.

[0123] Figure 3 FIG. 1 shows an internal structure diagram of a computer device in an embodiment. The computer device may be a terminal or a server. Figure 3 As shown, the computer device includes a processor, a memory and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor may implement the network card cache management method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor may execute the network card cache management method. Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0124] In one embodiment, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps:

[0125] Receive a data write request for a data segment in a circular data queue; wherein the circular data queue includes multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space;

[0126] Determining whether a new cache address needs to be applied for according to the occupancy of the current cache space;

[0127] If not, writing the temporarily stored data into the current cache space;

[0128] The temporarily stored data in the data segment is deleted, and the data segment is used to receive new temporarily stored data.

[0129] The network card cache management device of the embodiment of the present invention realizes efficient data reception and processing by utilizing a circular data queue and a pre-configured cache space, and the network card cache management no longer completely relies on the memory management of the operating system, thereby avoiding unnecessary cache application operations. In particular, in a high-traffic environment, it effectively avoids cache application anomalies and CPU resource occupation problems caused by the complexity of the operating system memory management.

[0130] In one embodiment, a computer-readable storage medium is provided, storing a computer program, wherein when the computer program is executed by a processor, the processor performs the following steps:

[0131] Receive a data write request for a data segment in a circular data queue; wherein the circular data queue includes multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space;

[0132] Determining whether a new cache address needs to be applied for according to the occupancy of the current cache space;

[0133] If not, writing the temporarily stored data into the current cache space;

[0134] The temporarily stored data in the data segment is deleted, and the data segment is used to receive new temporarily stored data.

[0135] The network card cache management device of the embodiment of the present invention realizes efficient data reception and processing by utilizing a circular data queue and a pre-configured cache space, and the network card cache management no longer completely relies on the memory management of the operating system, thereby avoiding unnecessary cache application operations. In particular, in a high-traffic environment, it effectively avoids cache application anomalies and CPU resource occupation problems caused by the complexity of the operating system memory management.

[0136] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0137] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0138] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A network card cache management method, characterized in that: The method comprises: A one-to-one corresponding cache space is configured for each data segment in the circular data queue, wherein the cache space includes at least two cache pages, wherein the capacity of one cache page is greater than or equal to the capacity of one data segment, so as to completely store the temporary data in one data segment into one cache page; Receive a data write request for a data segment in a circular data queue; wherein the circular data queue includes multiple data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space; Determining whether a new cache address needs to be applied for according to the occupancy of the current cache space; If not, writing the temporarily stored data into the current cache space; The temporarily stored data in the data segment is deleted, and the data segment is returned to the end of the circular data queue for receiving new temporarily stored data, and enters the queue waiting to be written into the cache space again.

2. The network card cache management method according to claim 1, characterized in that: After the step of writing the temporarily stored data into the current cache space, the method further comprises: The page reference count of the current cache space is increased by 1; And in a circular order, the data write request for the next data segment in the circular data queue is received in sequence.

3. The network card cache management method according to claim 2, characterized in that: The initial value of the page reference count is 0, and the step of determining whether a new cache address needs to be applied for according to the occupancy of the current cache space includes: Determining whether the current value of the page reference count is less than the number of cached pages; If so, it is determined that there is no need to apply for a new cache address.

4. The network card cache management method according to claim 3, characterized in that: The step of writing the temporarily stored data into the current cache space comprises: Sequentially searching for unoccupied cache pages in each cache page in the current cache space; Get the address of the first unoccupied cache page found; The temporarily stored data is written into a cache page corresponding to the address, and the cache page corresponding to the address is marked as occupied.

5. The network card cache management method according to claim 4, characterized in that: After the step of writing the temporarily stored data into the cache page corresponding to the address and marking the cache page corresponding to the address as occupied, the method further includes: Determining whether the temporarily stored data has been written into the preset operating system; If so, the temporary data of the cache page is cleared, the cache page is marked as free, and the page reference count of the current cache space is reduced by 1.

6. The network card cache management method according to claim 5, characterized in that: After the step of determining whether the current value of the page reference count is less than the number of cached pages, the method further includes: If not, it is determined that a new cache address needs to be applied for; Sending a cache address application request to the preset operating system; After receiving the new cache address assigned by the preset operating system, the temporarily stored data is written into the new cache address.

7. A network card cache management device, characterized in that: The device comprises: A cache space configuration module, used to configure a one-to-one corresponding cache space for each data segment in the circular data queue, wherein the cache space includes at least two cache pages, wherein the capacity of a cache page is greater than or equal to the capacity of a data segment, so as to completely store the temporary data in a data segment into a cache page; a request receiving module, configured to receive a data write request for a data segment in a circular data queue; wherein the circular data queue includes a plurality of data segments, each data segment stores temporary data, each data segment is pre-configured with a one-to-one corresponding cache space, and the cache space of the data segment corresponding to the data write request is used as the current cache space; An occupancy determination module, used to determine whether a new cache address needs to be applied for according to the occupancy of the current cache space; A cache writing module, used for writing the temporarily stored data into the current cache space if there is no need to apply for a new cache address; The data clearing module is used to delete the temporarily stored data in the data segment, return the data segment to the end of the circular data queue, receive new temporarily stored data, and enter the queue waiting to be written into the cache space again.

8. A computer-readable storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the processor executes the steps of the network card cache management method according to any one of claims 1 to 6.

9. A computer device, characterized in that: The device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the network card cache management method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Memory use method, electronic equipment and storage medium

    CN114218130A

  • Data writing method and device, data reading method and device, electronic equipment and storage medium

    CN117407148A