Search

EP-3793176-B1 - DATA PROCESSING METHOD, DEVICE AND APPARATUS

EP3793176B1EP 3793176 B1EP3793176 B1EP 3793176B1EP-3793176-B1

Inventors

  • JADHAV, Rahul Arvind
  • SARMA, K Anmol Mani Tejeswar
  • CAO, Zhen

Dates

Publication Date
20260506
Application Date
20200316

Claims (13)

  1. A data processing method, comprising: receiving (S101), by an operating system of a device, a start instruction sent by an application in the device, wherein the application is a latency-insensitive application, and the start instruction comprises an identifier of a socket connection; calling (S 102), by the operating system according to the start instruction, a monitoring module to monitor to learn whether buffering data of the socket connection in a kernel buffer exceeds a lowest water mark, wherein the data of the socket connection is from an underlying protocol stack, wherein the calling, by the operating system according to the start instruction, a monitoring module to monitor a case about buffering data of the socket connection in a kernel buffer comprises: calling, by the operating system according to the start instruction, the monitoring module to perform monitoring of: a duration of buffering of data of the socket connection in a kernel buffer, and an amount of the data of the socket connection buffered in the kernel buffer; generating (S103), by the monitoring module, a data readable identifier, wherein the data readable identifier is a first data readable identifier when a time interval between a current moment and a start moment is greater than or equal to a timeout duration and wherein the data readable identifier is a second data readable identifier when the data of the socket connection in the kernel buffer is greater than or equal to the lowest water mark; sending, by the operating system when receiving the data readable identifier generated by the monitoring module, the data of the socket connection received in the kernel buffer to a sliding receive window of the socket connection; wherein the start moment is a moment at which the operating system receives the start instruction, and the data readable identifier indicates that the data of the socket connection received in the kernel buffer is readable by the application; and calling, by the application based on the data readable identifier generated by the monitoring module, a reading module to read the data of the socket connection from the receive window corresponding to the socket connection, wherein the monitoring module comprises a timer, duration of the timer is the timeout duration, and the method further comprises: starting, by the operating system, the timer according to the start instruction, wherein the method further comprises: when the timer expires, determining, by the monitoring module, whether the data of the socket connection is buffered in the kernel buffer, wherein the application receives the data readable identifier generated by the monitoring module when it is determined that the data of the socket connection is buffered in the kernel buffer; and when it is determined that the data of the socket connection is not buffered in the kernel buffer, the monitoring module continues waiting to receive the data of the socket connection, or exits by triggering another event, wherein the lowest water mark is maximum available space of the data to be received by the application in the kernel buffer, and the timeout duration is a maximum duration of buffering the data of the socket connection in the kernel buffer.
  2. The method according to claim 1, wherein the calling, by the operating system according to the start instruction, the monitoring module to perform monitoring to learn whether the data of the socket connection buffered in the kernel buffer exceeds a lowest water mark comprises: in a process from calling, according to the start instruction, the monitoring module to monitor the kernel buffer to sending, by the monitoring module, the data readable identifier to the application, learning, by the monitoring module through monitoring, that the data of the socket connection buffered in the kernel buffer does not exceed the lowest water mark.
  3. The method according to claim 1 or 2, wherein the timeout duration is set based on at least one of the following indicators: a latency of a network used by the socket connection, bandwidth of the network used by the socket connection, a packet loss rate of the network used by the socket connection, and a communication requirement type of the application.
  4. The method according to claim 1 or 2, wherein the lowest water mark is set based on at least one of the following indicators: available space of data to be received by the application in the kernel buffer, a latency of a network used by the socket connection, a packet loss rate of the network used by the socket connection, bandwidth of the network used by the socket connection, a maximum value of a receive window corresponding to the socket connection, and a communication requirement type of the application.
  5. The method according to any one of claims 1 to 4, wherein the operating system stores a mapping relationship between the identifier of the socket connection and the timeout duration.
  6. A data processing apparatus (10) comprising: a receiving module (11), configured to receive a start instruction sent by an application in a device, wherein the application is a latency-insensitive application, and the start instruction comprises an identifier of a socket connection; a processing module (12), configured to call, according to the start instruction, the monitoring module (13) to monitor to learn whether about buffering data of the socket connection in a kernel buffer exceeds a lowest water mark, wherein the data of the socket connection is from an underlying protocol stack, wherein processing module (12) is configured to call the monitoring module to perform monitoring of: a duration of buffering of data of the socket connection in a kernel buffer, and an amount of the data of the socket connection buffered in the kernel buffer; and the monitoring module (13), further configured to generate a data readable identifier, wherein the data readable identifier is a first data readable identifier when a time interval between a current moment and a start moment is greater than or equal to timeout duration, and wherein the data readable identifier is a second data readable identifier when the data of the socket connection in the kernel buffer is greater than or equal to the lowest water mark, wherein the start moment is a moment at which an operating system of the device receives the start instruction, and the data readable identifier indicates that the data of the socket connection received in the kernel buffer is readable by the application; the data processing apparatus (10) is configured to send, when receiving the data readable identifier generated by the monitoring module (13), the data of the socket connection received in the kernel buffer to a sliding receive window of the socket connection; and the application is configured to call, based on the data readable identifier generated by the monitoring module, a reading module to read the data of the socket connection from the receive window corresponding to the socket connection, wherein the monitoring module comprises a timer, duration of the timer is the timeout duration, and the processing module is further configured to start the timer according to the start instruction, wherein the monitoring module is further configured to: when the timer expires, determine that the data of the socket connection is buffered in the kernel buffer, wherein the application receives the data readable identifier generated by the monitoring module when it is determined that the data of the socket connection is buffered in the kernel buffer; and when it is determined that the data of the socket connection is not buffered in the kernel buffer, the monitoring module is configured to: continue waiting to receive the data of the socket connection, or exit by triggering another event, wherein the lowest water mark is maximum available space of the data to be received by the application in the kernel buffer, and the timeout duration is a maximum duration of buffering the data of the socket connection in the kernel buffer.
  7. The apparatus according to claim 6, wherein the monitoring module is configured to: in a process from calling, according to the start instruction, the monitoring module to monitor the kernel buffer to sending, by the monitoring module, the data readable identifier to the application, learn, through monitoring, that the data of the socket connection buffered in the kernel buffer does not exceed the lowest water mark.
  8. The apparatus according to claim 6 or 7, wherein the timeout duration is set based on at least one of the following indicators: a latency of a network used by the socket connection, bandwidth of the network used by the socket connection, a packet loss rate of the network used by the socket connection, and a communication requirement type of the application.
  9. The apparatus according to any one of claims 6 to 8, wherein the apparatus is a device, comprising: a memory and a processor, wherein the memory stores a program instruction; and the processor is configured to invoke the program instruction in the memory to perform the data processing method according to any one of claims 1 to 5.
  10. A readable storage medium, wherein the readable storage medium stores an executable instruction, and when at least one processor of a device executes the executable instruction, the device performs the data processing method according to any one of claims 1 to 5.
  11. A computer program product, comprising a program or an instruction, wherein when the program or the instruction is run on a computer, the data processing method according to any one of claims 1 to 5 is performed.
  12. A system comprising a chip and a memory, and when a software program stored in the memory is executed, the data processing method according to any one of claims 1 to 5 is implemented.
  13. The system according to claim 12, wherein the memory is integrated in the chip.

Description

TECHNICAL FIELD This application relates to the field of communications technologies, and in particular, to a data processing method and apparatus, readable storage medium, computer program product, and a system. BACKGROUND As mobile Internet access has become a main characteristic of a device (such as a terminal), a technical solution used by the device to access a network continuously develops, thereby greatly improving an information obtaining rate of a device product. TCP (transmission control protocol) commonly used in the field of mobile communications is a connection-oriented, reliable, and byte stream-based transport layer communications protocol. Generally, a system call (system call) is a combination of a series of complex operations. During the system call, use of a central processing unit (central processing unit, CPU) in the device is triggered, and even an operation such as internal memory copy in the device is performed. Currently, in a process in which the device accesses the network by using TCP, an application program in a user mode receives data from a TCP protocol stack in a kernel mode through a plurality of system calls. For example, the application program may call a select() function to monitor a status of a socket connection, and then call a read() function to read data. However, excessively frequent system calls tend to cause a waste of CPU resources and increase power consumption of the device. Hellmann Doug, "select - Wait for I/O Efficiently -Python Module of the Week Platform-specific Options", (20180624), URL: https://web.archive.org/web/20180624082628/https://pymotw.com/2/select/, (20210830), describes a readable list wherein all sockets in the readable list have incoming data buffered and available to read. US 2003/002508 A1 describes a method of performing a bulk read from a socket receive buffer, with steps of: initiating a bulk read function having a bulk read size; determining if an amount of data in the socket receive buffer is equal to or greater than the bulk read size; and activating the bulk read function only when there is an amount of data in the socket receive buffer equal to or greater than the bulk read size. SUMMARY The present invention provides a data processing method, a data processing apparatus, readable storage medium, a computer program product, and a system according to the independent claims. Particular embodiments are specified in the dependent claims. This application further provides a data processing method and apparatus, and a device, so that a data buffering process can be optimized through time restriction, and a process in which an application obtains data from an operating system better meets an actual requirement, thereby reducing a quantity of system calls. According to a first aspect, this application provides a data processing method, including: receiving, by an operating system of a device, a start instruction sent by an application in the device, where the application is a latency-insensitive application, and the start instruction includes an identifier of a socket connection;calling, by the operating system according to the start instruction, a monitoring module to monitor to learn whether buffering data of the socket connection in a kernel buffer exceeds a lowest water mark, where the data of the socket connection is from an underlying protocol stack, wherein the calling, by the operating system according to the start instruction, a monitoring module to monitor a case about buffering data of the socket connection in a kernel buffer comprises: calling, by the operating system according to the start instruction, the monitoring module to perform monitoring of: a duration of buffering of data of the socket connection in a kernel buffer, and an amount of the data of the socket connection buffered in the kernel buffer;generating, by the monitoring module, a data readable identifier, wherein the data readable identifier is a first data readable identifier when a time interval between a current moment and a start moment is greater than or equal to timeout duration and wherein the data readable identifier is a second data readable identifier when the data of the socket connection in the kernel buffer is greater than or equal to the lowest water mark, andsending, by the operating system when receiving the data readable identifier generated by the monitoring module, the data of the socket connection received in the kernel buffer to a sliding receive window of the socket connection; wherethe start moment is a moment at which the operating system receives the start instruction, and the data readable identifier indicates that the data of the socket connection received in the kernel buffer is readable by the application; andcalling, by the application based on the data readable identifier generated by the monitoring module, the reading module to read the data of the socket connection from the receive window corresponding to the socket connection. Th