Cache acceleration method and device, equipment and storage medium
By using asynchronous read and write methods of user state block devices and event notification descriptors in big data calculation, the problem of increased CPU processing burden under high-speed storage media is solved, and data cache efficiency and storage performance are improved.
Patent Information
- Application Number
- CN202411930507.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-18
AI Technical Summary
The interrupt notification mode causes an increase in CPU processing burden in high-speed storage media, affecting system performance.
By using the user state block device as the local cache device, asynchronous reading and writing are implemented using the event notification descriptor, reducing the number of data transmissions between the user state and the kernel state, and allowing tasks to be processed in parallel.
Improves data caching efficiency, reduces redundant processing in the kernel, and improves storage performance, especially in big data parallel computing programs.
Smart Images

Figure CN119847434A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data computing, and in particular to a cache acceleration method, device, equipment and storage medium. Background Art
[0002] Spark is a big data parallel computing framework based on memory computing. It can be used to build large-scale, low-latency data analysis applications. The characteristic of Spark computing is that the calculation data and intermediate results are stored in memory, reducing a large number of IO (Input / Output) processes.
[0003] In the related art, an interrupt notification mode is used to store data in a storage device (such as a mechanical hard disk). When the storage device completes the data read and write operation or requires the CPU (Central Processing Unit) to perform further processing, it will notify the CPU by sending an interrupt signal. After receiving the interrupt signal, the CPU will suspend the currently executing task and process the interrupt service program related to the storage device.
[0004] However, with the continuous advancement of technology, especially the popularity of high-speed storage media such as SSD (Solid State Disk or Solid State Drive), the limitations of the interrupt notification mode have gradually become apparent. Since the read and write speed of SSD is very fast, the frequency of interrupts will increase significantly, bringing a greater processing burden to the CPU, thus affecting the overall performance of the system. Summary of the invention
[0005] The embodiments of the present application provide a cache acceleration method, device, equipment and storage medium, which can improve the efficiency of file cache. The technical solution is as follows.
[0006] According to one aspect of the present application, a cache acceleration method is provided, the method being performed by a computer device having a user-mode block device as a local cache device of a computing program, the method comprising:
[0007] In the process of reading and writing a first file to the user-mode block device, determining a cache block corresponding to the first file;
[0008] Initiate a block read and write request of the cache block to the kernel-mode input and output IO engine, and create an event notification descriptor; the event notification descriptor is used to indicate the read and write status of the block read and write request; the IO engine is used to asynchronously read and write the user-mode block device;
[0009] Based on the event notification descriptor, a message notification is obtained after the IO engine completes reading and writing the cache block.
[0010] According to another aspect of the present application, a cache acceleration device is provided, wherein the device has a user-mode block device as a local cache device of a computing program, and the device comprises:
[0011] A determination module, configured to determine a cache block corresponding to the first file during a process of reading and writing the first file to the user-mode block device;
[0012] An initiating module, used to initiate a block read and write request of the cache block to the kernel-mode input and output IO engine, and to create an event notification descriptor; the event notification descriptor is used to indicate the read and write status of the block read and write request; the IO engine is used to asynchronously read and write the user-mode block device;
[0013] The notification module is used to obtain the message notification of the IO engine after the reading and writing of the cache block is completed based on the event notification descriptor.
[0014] According to another aspect of the present application, a computer device is provided, comprising: a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the cache acceleration method as described above.
[0015] According to another aspect of the present application, a computer-readable storage medium is provided, in which at least one instruction, at least one program, a code set or an instruction set is stored, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the cache acceleration method as described above.
[0016] According to another aspect of the embodiments of the present disclosure, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the cache acceleration method provided in the above optional implementation.
[0017] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:
[0018] Using user-mode block devices as local cache devices allows computing programs to read and write cache data directly to user-mode block devices, reducing the number of data transmissions between user mode and kernel mode, allowing computing programs to access local cache devices more directly, and reducing redundant processing in the kernel. Asynchronous reading and writing are achieved through event notification descriptors, allowing tasks to be processed in parallel. When executing data cache, there is no need to wait for the previous read and write task to be completed, and other tasks can be continued. After the read and write tasks are completed, the event notification descriptor triggers a notification message to notify the completion of the read and write, so as to trigger the subsequent tasks of the computing program. This method improves the efficiency of data caching, especially in large data parallel computing programs, which can efficiently cache computing data and intermediate results and improve storage performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] Figure 1 is a schematic diagram of a cache acceleration method provided by an exemplary embodiment of the present application;
[0021] Figure 2 is a schematic diagram of io_uring provided by an exemplary embodiment of the present application;
[0022] Figure 3 is a schematic diagram of a cache acceleration method provided by another exemplary embodiment of the present application;
[0023] Figure 4 is a schematic diagram of a cache acceleration method provided by another exemplary embodiment of the present application;
[0024] Figure 5 is a block diagram of a computer device provided by an exemplary embodiment of the present application;
[0025] Figure 6 is a method flow chart of a cache acceleration method provided by another exemplary embodiment of the present application;
[0026] Figure 7 is a method flow chart of a cache acceleration method provided by another exemplary embodiment of the present application;
[0027] Figure 8 is a method flow chart of a cache acceleration method provided by another exemplary embodiment of the present application;
[0028] Fig. 9is a method flow chart of a cache acceleration method provided by another exemplary embodiment of the present application;
[0029] Fig.10 is a method flow chart of a cache acceleration method provided by another exemplary embodiment of the present application;
[0030] Fig.11 is a method flow chart of a cache acceleration method provided by another exemplary embodiment of the present application;
[0031] Fig.12 is a schematic diagram of a cache acceleration method provided by another exemplary embodiment of the present application;
[0032] Fig.13 is a method flow chart of a cache acceleration method provided by another exemplary embodiment of the present application;
[0033] Fig.14 is a method flow chart of a cache acceleration method provided by another exemplary embodiment of the present application;
[0034] Fig.15 is a block diagram of a terminal provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0036] First, the terms involved in the embodiments of the present application are explained.
[0037] 1. Spark
[0038] Spark is a big data parallel computing framework based on memory computing. It can be used to build large-scale, low-latency data analysis applications. The characteristic of Spark computing is that the computing data and intermediate results are stored in memory, reducing a large number of IO operations.
[0039] IO operations refer to the transfer of data between a computer and external devices. These devices can be network devices (such as network cards), storage devices (such as hard disks, SSDs), etc. For example, reading and sending data through a network card is an IO operation in network communication; for another example, reading and writing data from a disk is a storage IO operation, such as reading a file from a hard disk to a computer's memory or writing data to a hard disk. Each external device usually has one or more controllers that manage communication with the device. The exchange of data between the controller and the CPU (or more broadly, the host system) is an IO operation. The CPU side is called the host side, while the external device is called the device side. Memory (such as RAM (Random Access Memory)) is a storage area directly accessed by the CPU for temporary storage of data and programs. Unlike external devices, the CPU does not require special IO instructions to access memory, and it interacts directly with the memory through the memory bus. Therefore, memory is considered part of the CPU host side, not the device side.
[0040] Spark is a computing engine running in a cluster environment. HDFS (Hadoop Distributed File System) is the computing data pulled by Spark from a remote location. HDFS also stores data in the cluster. All computing and data storage are uniformly scheduled for computing tasks and allocated for resources through the big data resource scheduling platform.
[0041] Spark's computing tasks can be (Structured Query Language, SQL) tasks, machine learning computing tasks, graph computing tasks, etc. Take SQL query as an example. Enter the SQL query task in the interactive front end. The back end will create an RDD (Resilient Distributed Datasets) based on the query data source (HDFS file) through Spark. By pulling data from HDFS (remote storage) to the local to build RDD (if the memory is large enough), each computing node will calculate part of the data according to RDD (because the amount of RDD data is too large, a single machine cannot load all the data content, the calculation will be split to different nodes to calculate part of the content, and then the intermediate results will continue to be partitioned and calculated to obtain the final calculation result). The intermediate results of this part of the calculation will be cached in the local NVME SSD (Solid State Disk or Solid State Drive) disk (the local NVME SSD storage performance is better than the remote HDFS and mechanical disk, the price is lower than the memory, and it can be used as the second layer of cache outside the memory, that is: L2 Cache).
[0042] Spark's calculation includes the Map phase and the Reduce phase. Figure 1 As shown in the figure, the Map phase splits a large data set into small data sets. For example, File1 includes Block#1, Block#2, Block#3, and Block#4. Block#1 and Block#2 are divided into InputSplit#1, and Block#3 and Block#4 of File1 are divided into InputSplit#1. The same is true for File2. Each input slice is assigned to a task, and these tasks are executed on RDD (Resilient Distributed Datasets). RDD is further decomposed into multiple partitions, each of which contains one or more blocks of data, and each partition will be processed by a specific task to store the key-value pairs obtained by the processing. For example, a keyword search is performed on InputSplit#1 to obtain a key-value pair of the keyword and the number of times the keyword appears. In the Map phase, each task processes its corresponding input slice and maps the input elements into key-value pairs. These key-value pairs are stored in their respective partitions. In the Reduce phase, Spark determines which key-value pairs need to be sent to the same Reduce task for merging and aggregation based on the key of the key-value pairs. Since the key-value pairs are stored in partitions, Spark determines which partitions contain the key-value pairs that need to be sent to the same Reduce task. This requires the Shuffle phase to redistribute the key-value pairs to different partitions based on the keys so that each Reduce task can receive all the key-value pairs it needs.
[0043] The Shuffle phase in Spark is a bridge between the Map phase and the Reduce phase. In the Spark computing phase, the Map task generates a series of key-value pairs, and the Shuffle process is responsible for reorganizing and distributing these key-value pairs according to a specific partitioning logic to ensure that the values with the same key can be gathered in the same Reducer task for further processing. The core of the Shuffle process lies in the partitioning and transmission of data. In the Map phase, each Map task writes the data it generates to a local disk file, and uses the Partitioner to determine which Reducer task each key-value pair should be sent to. This partitioning process may generate a large number of intermediate files, especially when processing large-scale data sets. Once the Map phase is completed, the Shuffle process enters the Data Transfer phase. In this phase, each Reducer task pulls the data it needs from the node where the Map task is located. Generally, the shuffle is divided into two parts: data preparation (Shuffle Write) in the Map phase and data copy processing (Shuffle Read) in the Reduce phase.
[0044] 2. io_uring
[0045] io_uring is an efficient asynchronous IO framework implemented in the Linux kernel. It aims to provide high-performance asynchronous IO operations and improve the performance of IO operations by reducing the overhead of system calls and context switches. The io_uring framework implements efficient asynchronous IO processing by using a ring buffer and event-driven approach.
[0046] like Figure 2 As shown in the figure, io_uring is mainly composed of two ring buffers: SubmitQueue (SQ) 21 and Completion Queue (CQ) 22. Both queues are located in kernel space, but can be directly accessed from user space, usually through memory mapping (mmap). SubmitQueue (SQ) 21 is used to store IO requests submitted by user space, while CompletionQueue (CQ) 22 is used to store completed IO requests. Kernel state takes IO requests from SQ 21 according to the submission command of user state, and initiates real read and write operations to block devices. After completing data reading and writing, the kernel program writes the operation completion entry to CQ 22, and the user state application reads the completion entry CQE from CQ, reads the data in CQE and enters the next data polling.
[0047] An exemplary io_uring workflow is as follows:
[0048] 1) A user space program (e.g., a computing program) creates an io_uring instance through the io_uring_setup() system call and sets relevant parameters, such as the size of the queue.
[0049] 2) The user space program fills the IO request (such as read, write, etc.) into the submission queue (SQ) 21, and updates the head pointer of SQ 21 through atomic operations to notify the kernel of the new request.
[0050] 3) The kernel periodically checks the submission queue (SQ) 21, and when a new request is found, it takes it out of SQ 21 and processes it. The processing may involve actual IO operations such as disk operations and network communications.
[0051] 4) When the IO request is completed, the kernel fills the result into the completion queue (CQ) 22, and informs the user space that the request has been completed by updating the relevant pointer of CQ 22 or sending an event notification.
[0052] 5) The user space program periodically checks the completion queue (CQ) 22, and when a request is found to be completed, it takes the result out of CQ 22 and performs subsequent processing.
[0053] io_uring is asynchronous and non-blocking. After submitting a request, the user space program can continue to perform other tasks without waiting for the IO request to complete. When the IO request is completed, the kernel will inform the user space program through the event notification mechanism. In addition, io_uring also supports batch submission and processing of requests, further improving efficiency.
[0054] 3. UBLK (Userspace Block Drive)
[0055] The UBLK framework is implemented based on the io_uring mechanism of the Linux kernel. The UBLK framework consists of two parts: the user-mode service process (ublksrv) and the kernel-mode UBLK driver. In the UBLK framework, the processing logic of the block device is moved to the user space.
[0056] UBLK is a user-mode block storage framework implemented by Redhat based on the io_uring backend. It can create a driver for a user-space block device that uses io_uring to communicate with the kernel. That is, through the UIO kernel module, the NVMe SSD device node ( / dev / nvmeXnY, X, Y are positive integers) is created as a user-mode ublk device: / dev / ublkbZ (Z is a natural number).
[0057] like Figure 3As shown, based on the UBLK framework, the computing program 102 in the user space can directly access the user-mode block device ublkbZ 24, and initiate an IO request based on the user-mode block device 24 using blk-mq (multi-queue block IO queuing mechanism) 25. ublk-drv (UBLK kernel-mode driver) 26 calls the IO engine 103 to process the IO request, and uses the notification mechanism of libublksrv (ublk user mode) 28 to notify the computing program 102 of the processing result. The computing program 102 goes to target (backend: backing_file) (target object) 29 to read the processing result.
[0058] UBLK provides ublkb (user block device node) and ublkc (control node).
[0059] ublkb is a standard block device interface node provided by the UBLK framework for user space. It allows user space applications to operate UBLK devices like traditional block devices (such as hard disks, SSDs, etc.). The ublkb node provides a standard block device operation interface, including read and write operations, device information query, etc. These operations enable user space applications (such as computing programs) to interact with UBLK devices. At the kernel level, the UBLK framework maps ublkb nodes to specific storage devices or virtual storage devices by implementing the corresponding block device driver logic. These devices can be physical storage devices, network storage devices, or virtual storage devices in memory. User space applications interact with UBLK devices by accessing the file path / dev / ublkbX (where X is the device number).
[0060] ublkc is the configuration and control interface node provided by the UBLK framework for user space. It allows user space applications to configure and control UBLK devices. The ublkc node provides a wealth of configuration and control functions, including setting device parameters (such as block size, read and write speed limits, etc.), starting / stopping devices, etc. These functions enable user space applications to customize the configuration and control of UBLK devices according to actual needs.
[0061] In the embodiment of the present application, ublkc can be used to implement event notification based on edf (Event Notification File Descriptor, eventfd, event notification descriptor).
[0062] The ublkc control node creates an eventfd object in the kernel or user space. The eventfd object contains an unsigned 64-bit integer counter maintained by the kernel. When creating it, you can specify the initial value of the counter (usually 0) and flags (such as EFD_NONBLOCK and EFD_CLOEXEC). When a specific event occurs (for example, a device status change, an IO operation is completed, etc.), ublkc writes an integer value (usually 1) to the eventfd object to increment the counter. This write operation can be regarded as a triggering action for an event notification. User space applications detect readable events on the eventfd file descriptor through mechanisms such as select, poll, or epoll. When the counter is not 0, it means that an event has occurred, and the application can obtain event notifications by reading eventfd (and the counter will be cleared at the same time). The application executes the corresponding processing logic based on the information read (for example, the read operation usually only checks the non-zero state of the counter and does not care about the specific value).
[0063] For example, if eventfd is set to non-blocking mode (using the EFD_NONBLOCK flag), a read operation will immediately return an error (EAGAIN) without blocking when the counter is 0. In blocking mode, the read operation will wait until the counter becomes non-zero.
[0064] 4. User-mode block devices
[0065] User-mode block devices are a special type of device that provides a standard block device interface (such as / dev / ublkbX) to the business, while the actual data read and write processing is determined by the user-mode code. User-mode block devices are devices that provide a standard block device interface for business use. The actual IO processing of the business reading and writing this block device is determined by the code written in user mode. When a user-mode block device receives an IO request, it passes the request to the IO engine processing code written in user mode. This code is responsible for handling the actual read and write operations, such as reading data from the backend storage system into the memory, or writing data from the memory to the backend storage system. User-mode block devices are usually mapped to blk-mq (multi-queue block IO framework) in the kernel. Each user-mode block device queue includes an io_uring instance, which does not interfere with each other and does not need to lock and synchronize any information, thereby improving scalability.
[0066] 5. Apply UBLK to Spark’s shuffle phase
[0067] Accessing block devices in user mode has become a mainstream trend in the storage industry, such as SPDK (Storage Performance Development), UBLK, IO Passthru and other technologies and frameworks. On the one hand, user-mode IO can avoid redundant processing in the kernel through the file system, memory write-back, block device and then to the device driver layer. On the other hand, it can also adapt to changes in storage media. In the past, the kernel's IO path was not suitable for high-speed storage media. The traditional interrupt notification mode driver will generate more frequent interrupts due to the introduction of high-speed storage media, thereby bringing higher load to the system, which in turn reduces storage performance and the response speed of upper-level applications.
[0068] Using the traditional interrupt notification mode, the application will initiate an IO request, and the IO request will be passed to the operating system kernel through a system call (syscall). The system call is the interface between the application and the operating system kernel, which is used to request the kernel to perform specific operations, such as file reading and writing, device communication, etc. The IO request is then passed to the BIOS stack. On the BIOS stack, the Device driver 32 converts the IO request into a format that the hardware device can understand and communicates with the hardware device. When the hardware device is ready to process the IO request, it will notify the operating system through the IRQ (interrupt request) mechanism. IRQ is a communication method between the hardware device and the operating system, which is used to indicate that the hardware device needs the attention or processing of the operating system. The interrupt service program (CS, also commonly known as ISR, i.e., interrupt service routine) in the operating system is responsible for responding to this interrupt request.
[0069] However, the traditional interrupt-driven IO model has performance problems: when the hardware device processes very fast, it will frequently generate interrupts, which will increase the burden on the operating system and may lead to increased context switching and latency. To solve this problem, the Linux block layer introduced a polling mechanism as a means of IO optimization.
[0070] The polling mechanism allows the operating system to actively query the status of the hardware device instead of waiting for the hardware device to notify through an interrupt. In this way, the operating system can manage IO requests more efficiently and reduce the frequency of interrupts, thereby reducing latency and improving performance. Figure 4 As shown, a polling mechanism 31 is used to actively query the execution status of commands instead of relying on traditional interrupt notifications, which reduces high-frequency interrupts caused by high-speed storage media and further reduces system load.
[0071] Therefore, when using Spark for shuffle operations, the user-space block device storage framework (UBLK (Userspace Block Drive) framework) and the backend IO engine io_uring are introduced, combined with the local disk's NVMe SSD solid-state disk to accelerate the caching and processing of data during the shuffle process. Through the nvme user-space block device bdev ( / dev / ublkbZ) constructed by SPDK, Spark shuffle can directly write cache data to bdev. The upper-level API (Application Programming Interface) provided by ublk / io_uring is incompatible with the traditional POSIX (Portable Operating System Interface) API in terms of data reading and writing. The traditional POSIX API directly reads and writes data synchronously through the read / write interface, while ublk / io_uring adopts a completely asynchronous processing method, including event notification mechanisms such as preparing write commands, submitting write requests, waiting for message notifications, and data polling. Therefore, in Spark implemented in Java, if you want to use ublk / io_uring to improve IO performance, you need to modify the upper-level programming model and transform the original synchronous IO read / write-based model into a programming method that adapts to the ublk / io_uring asynchronous IO processing model.
[0072] The above-mentioned technology based on user-mode block device storage (which can only be used after the kernel's UIO module maps the underlying hardware resources to the user mode) is widely used in high-performance machines such as centralized storage and hyper-convergence, but is rarely implemented in the field of big data where Java is the mainstream development language. However, as the mainstream development language in the field of big data, Java language is partially out of touch with the development trend of the upper-layer application framework of big data and the lower-layer system software. Therefore, the method provided in the embodiment of the present application is based on UBLK / io_uring to optimize the shuffle stage of Spark, and the technical solution widely promoted in the big data stack has a positive significance in leading the direction.
[0073] The big data software stack developed in Java uses the IO util inside the JVM (Java Virtual Machine) to read and write storage devices in the Spark computing engine. The IO util uses the traditional posix interface read and write to complete the reading and writing of files. It does not support or adapt user-mode asynchronous reading and writing technologies such as SPDK, UBLK, and io_uring. SPDK, UBLK, and io_uring cannot demonstrate their performance advantages on Spark. Therefore, the big data software stack needs to re-implement and adapt the above user-mode storage device access interfaces to further improve performance. The traditional Posix interface no longer meets the future technology development trend and the evolution of new hardware.
[0074] Figure 5 A schematic diagram of a computer device 120 provided by an exemplary embodiment of the present application is shown.
[0075] The computer device 120 may be a terminal or a server. The computer device 120 includes a computing program 102, an IO engine 103, and a user-mode block device 104. The computing program 102 is invoked and executed by a processor to implement the cache acceleration method provided in the present application.
[0076] The user-state block device 104 is created based on NVMe (Non-Volatile Memory Express, non-volatile memory host controller interface specification) SSD or PMem (Persistent Memory). Optionally, the computer device 120 also includes a random access memory (Random Access Memory, RAM). Among them, RAM, that is, memory, is L1 cache; NVMe SSD or PMem is L2 cache, and NVMe SSD is created as the user-state block device 104.
[0077] The computing program 102 calls the IO engine 103 to read and write data to the user-mode block device 104. The IO engine 103 provides the computing program 102 with an interface for reading and writing data, so that the computing program 102 can focus on the computing task itself without having to worry about the underlying data storage and transmission details. The IO engine 103 needs to interact with the user-mode block device 104 to complete the data reading and writing operations. The user-mode block device 104 provides the IO engine 103 with a standard block device interface, through which the IO engine 103 sends read and write requests to the user-mode block device 104 and receives the read and write results returned by the user-mode block device 104.
[0078] The processor of the computer device may be composed of one or more integrated circuit chips. Optionally, the processor may be a general-purpose processor, such as a central processing unit (CPU) or a network processor (NP). Optionally, the processor may implement the cache acceleration method provided by the present application by running a program or code.
[0079] Exemplarily, a computing program 102 is stored on the computer device 120, and the computer device can run the computing program 102 to implement the cache acceleration method provided in the embodiment of the present application. For example, the computing program 102 can be a distributed big data computing program.
[0080] Figure 6 A flow chart of a cache acceleration method provided by an exemplary embodiment of the present application is shown. The method can be executed by a computer device. The method includes the following steps.
[0081] Step 210: in the process of reading and writing the first file to the user-mode block device, determine the cache block corresponding to the first file.
[0082] The method is performed by a computer device, and the computer device has a user-mode block device as a local cache device for a computing program. Exemplarily, the method is performed by a computer program.
[0083] The computer program may be a distributed big data computing program. The method provided in the embodiment of the present application may be used to accelerate data caching in the shuffle phase of the distributed big data computing program based on a user-mode block device.
[0084] For example, the distributed big data computing program may be Spark. In the process of big data computing, Spark uses the method provided in the embodiment of the present application to cache intermediate results, for example, uses the method provided in the embodiment of the present application to execute ShuffleWrite and / or Shuffle Read to store the intermediate results generated in the Map stage, or reads the intermediate results generated in the Map stage and sends them to the Reduce task for computing.
[0085] Alternatively, by using the method provided in the embodiment of the present application, Spark can cache the remote data pulled from the remote database into the user-mode block device. The remote data can be a first file, and the first file includes at least one cache block. Spark uses the method provided in the embodiment of the present application to write at least one cache block of the first file into the user-mode block device for storage. So that data can be quickly read from the local during subsequent calculations. Alternatively, Spark can use the method provided in the embodiment of the present application to read the remote data (e.g., the first file) stored in the user-mode block device for calculation.
[0086] The method provided in the embodiment of the present application creates an NVMe SSD as a user-mode block device, so that Spark can directly access the user-mode block device and read and write data to the user-mode block device. The computing program creates an NVMe flash disk as a user-mode block device. Exemplarily, using SPDK's support for UBLK UIO and UBLK underlying drivers, create a / dev / ublkbX user-mode block device and a control node / dev / ublkcX for controlling the user-mode block device. The creation process can be:
[0087] scripts / setup.sh
[0088] scripts / rpc.py ublk_create_target
[0089] scripts / rpc.py bdev_nvme_attach_controller-b NVMe1-t PCIe-a10001:81:00.0
[0090] scripts / rpc.py ublk_start_disk NVMe1n1 1-q 2-d 128
[0091] Then, two nodes / dev / ublkb1 and / dev / ublkc1 are obtained. The user-mode block device node can be used to store data, and the control node can change the event notification descriptor after the read and write request processing is completed to notify the computing program that the request processing is completed.
[0092] Exemplarily, a file descriptor fd of the first file is created.
[0093] The first file may be a to-be-stored file that needs to be written to a user-mode block device. The first file may also be a file that needs to be read from a user-mode block device. The first file includes at least one cache block, and the size of each cache block may be 128 MB, or the size of each cache block may be any value, such as 6 KB, 10 KB, etc.
[0094] Exemplarily, this method can be used for data caching in a big data computing process, and the first file may include at least two cache blocks. By adopting the method provided in the embodiment of the present application, asynchronous reading and writing of at least two cache blocks can be realized. After initiating block read and write requests for at least two cache blocks, the computing program does not need to wait for the completion of reading and writing of at least two cache blocks.
[0095] Step 220, initiate a block read / write request of the cache block to the kernel-mode IO engine, and create an event notification descriptor; the event notification descriptor is used to indicate the read / write status of the block read / write request; the IO engine is used to asynchronously read and write user-mode block devices.
[0096] Exemplarily, the computing program initiates a block read / write request of a cache block of the first file to the IO engine, and the block read / write request may be a block write request or a block read request; the block write request is used to request to write the cache block of the first file to the user-mode block device. The block read request is used to request to read the cache block of the first file from the user-mode block device.
[0097] Exemplarily, after creating a file descriptor of the first file, the cache block contained in the first file is determined, and the read and write addresses of the cache block are determined, and the read and write addresses of the cache block include the address of the user-mode block device. The event notification descriptor efd is registered with the IO engine / UBLK thread. Based on the event notification descriptor and the read and write addresses, a block read and write request of the cache block is submitted to the IO engine / UBLK thread, and the IO engine / UBLK thread processes the block read and write request. Thereafter, the computing program starts a polling task for the event notification descriptor. After the block read and write request processing is completed, the IO engine / UBLK thread changes the state of the event notification descriptor. The computing program polls the event notification descriptor, detects the state change of the event notification descriptor, determines that the block read and write request processing is completed, and implements asynchronous message notification of the data cache.
[0098] The event notification descriptor (efd or eventfd) is a lightweight event notification mechanism provided by Linux. It creates an eventfd object, which maintains a 64-bit unsigned integer counter in the kernel. This counter can be used to indicate the number of times an event has occurred. When an event (for example, the completion of a block read or write request) occurs, a value can be written to this counter to increase its count. The process or thread waiting for the event can read this counter to check whether an event has occurred and take appropriate actions accordingly.
[0099] Exemplarily, the computing program may create an event notification descriptor for a block read / write request to detect the completion status of a fast write request. The computing program may also create respective event notification descriptors for multiple block read / write threads that process block read / write requests to detect the completion status of each fast read / write thread.
[0100] Step 230: Based on the event notification descriptor, obtain the message notification of the IO engine after the cache block reading and writing is completed.
[0101] Exemplarily, the computing program polls the event notification descriptor, and after the state of the event notification descriptor changes, determines that the block read and write request of the cache block is completed. The computing program can read the read and write results based on the read and write positions of the cache block, and determine that the read and write are completed if data is read; if no data is read, determine that the read and write fails.
[0102] In an optional embodiment, the computer program may be a Spark RSS (Remote Shuffle Service) program. The local cache device may be an NVMe SSD. The cache acceleration method provided in the embodiment of the present application is used to implement cache acceleration of the local NVMe SSD disk. In Spark RSS, data is usually pulled from the remote HDFS to the local. In order to speed up the calculation, the local NVMe SSD (and / or Intel Optane storage) is configured to cache the hot data. When the calculation occurs, Spark RSS first searches for this part of the data in the NVMe SSD, and only pulls it remotely if there is no hit. Therefore, the business implementation of RSS includes the implementation logic of pulling data remotely (reading HDFS) and caching data locally (writing NVMe).
[0103] like Figure 7 As shown, when processing RSS Workload, the cache acceleration method provided in the embodiment of the present application is used to process each RSS Workload block 301 of the RSS Workload, that is, the cache block. SparkRSS initiates a block read and write request of the RSS Workload block to the kernel-state IO engine 103 based on the UBLK framework. The block read and write request carries the read and write address of the RSS Workload block on the user-state device. Spark RSS creates an event notification descriptor for the read and write thread of the RSS Workloadblock; the event notification descriptor is used to indicate the read and write status of the block read and write request. The IO engine asynchronously reads and writes the user-state block device to process the block read and write request of the RSS Workload block, and changes the status of the event notification descriptor after the read and write request processing is completed. Spark RSS polls the status of the event notification descriptor, and triggers the block read and write request of the next RSS Workload block based on the status change of the event notification descriptor until all RSS Workload blocks of the RSS Workload are written.
[0104] In summary, the method provided in this embodiment uses a user-state block device as a local cache device, so that the computing program can directly read and write cache data to the user-state block device, reducing the number of data transmissions between the user state and the kernel state, allowing the computing program to access the local cache device more directly, and reducing redundant processing in the kernel. Asynchronous reading and writing are achieved through event notification descriptors, allowing tasks to be processed in parallel. When executing data caching, there is no need to wait for the previous read and write task to be completed, and other tasks can continue to be executed. After the read and write tasks are completed, the event notification descriptor triggers a notification message to notify the completion of the read and write, so as to trigger the subsequent tasks of the computing program. This method improves the efficiency of data caching, especially in large data parallel computing programs, it can efficiently cache calculation data and intermediate results, and improve storage performance.
[0105] An exemplary embodiment of obtaining a message notification based on an event notification descriptor is given below.
[0106] Figure 8 A flowchart of a cache acceleration method provided by an exemplary embodiment of the present application is shown. The method can be implemented by a computer device. Figure 6 In the illustrated embodiment, step 230 includes step 231 and step 232 .
[0107] Step 210: in the process of reading and writing the first file to the user-mode block device, determine the cache block corresponding to the first file.
[0108] For example, the first file may correspond to at least one cache block. Since the data volume of a cache block (128MB) is relatively large, it is necessary to split a cache block into multiple data blocks for reading and writing in batches according to the read and write capabilities of the IO engine. For example, if the IO engine can read and write up to 64kb of data at a time, it is necessary to split a cache block into multiple data blocks, each of which is 64kb in size, and read and write each data block in turn.
[0109] In order to improve the read and write efficiency of the cache block, multiple read and write threads can be used to read and write the cache block in parallel. For example, 8 read and write threads can be used to read and write the cache block synchronously.
[0110] Step 220, initiate a block read / write request of the cache block to the kernel-mode input / output IO engine, and create an event notification descriptor; the event notification descriptor is used to indicate the read / write status of the block read / write request; the IO engine is used to asynchronously read and write user-mode block devices.
[0111] Exemplarily, the read and write tasks of the cache block are split into at least two read and write threads according to the IO depth; the IO depth is used to indicate the number of IO requests processed in parallel by the IO engine; and event notification descriptors are created for the at least two read and write threads respectively.
[0112] When the IO engine uses at least two read / write threads to process read / write requests of a cache block in parallel, an event notification descriptor may be created for each read / write thread.
[0113] For example, at least two read-write threads include a first read-write thread and a second read-write thread, the first read-write thread is used to read and write the first part of the data of the cache block, and the second read-write thread is used to read and write the second part of the data of the cache block. After both read-write threads are processed, the reading and writing of all the data of the cache block can be completed. A first event notification descriptor is created for the first read-write thread, and a second event notification descriptor is created for the second read-write thread. The computing program polls the first event notification descriptor and the second event notification descriptor respectively to detect the completion status of the first read-write thread and the second read-write thread. When the first read-write thread is processed, the IO engine can change the state of the first event notification descriptor, and the computing program obtains the processing result of the first read-write thread after detecting the change of the state of the first event notification descriptor. When the second read-write thread is processed, the IO engine can change the state of the second event notification descriptor, and the computing program obtains the processing result of the second read-write thread after detecting the change of the state of the second event notification descriptor. After the first read-write thread and the second read-write thread are both read and written successfully, it is determined that the cache block is read and written successfully.
[0114] Exemplarily, at least two read / write threads are respectively used to read and write data to corresponding buffers; at least two event notification descriptors are configured with mask values corresponding to them, and the mask values are used to indicate the buffers corresponding to the read / write threads.
[0115] Exemplarily, the event notification descriptor is used to notify the computing program that the processing state of the corresponding read / write thread has changed, that is, the processing is completed. The computing program needs to read the processing result from the buffer of the read / write thread to determine whether the reading and writing are completed. When creating an event notification descriptor for each read / write thread, the mask value corresponding to the event notification descriptor can also be indicated, and the mask value is used to indicate the buffer position corresponding to the read / write thread. When the state of the event notification descriptor changes, the computing program can read the processing result from the buffer according to the mask value corresponding to the event notification descriptor, and determine whether the reading and writing are successful based on the processing result.
[0116] Step 231, polling event notification descriptors.
[0117] Exemplarily, after submitting a read or write request of a cache block to the IO engine, the computing program starts a polling task of the event notification descriptor to poll the event notification descriptor.
[0118] When the cache block is read and written in parallel by at least two read and write threads, the computing program polls the event notification descriptor corresponding to each read and write thread to detect the processing status of each read and write thread.
[0119] Step 232: When the state of the event notification descriptor changes, it is determined that a message notification is received from the IO engine after the cache block reading and writing is completed.
[0120] The state of the event notification descriptor is changed by the event trigger after the IO engine completes the block read or write request.
[0121] Exemplarily, when the event notification descriptor is created for a block read / write request, the IO engine changes the state of the event notification descriptor after the block read / write request is processed to notify the computing program that the block read / write request is processed.
[0122] Exemplarily, when the event notification descriptor is created for a read / write thread of a block read / write request, after the read / write thread completes processing, the IO engine changes the state of the event notification descriptor corresponding to the processing thread to notify the computing program that the processing thread has completed processing.
[0123] Exemplarily, when the states of the event notification descriptors corresponding to at least two read / write threads respectively change, it is determined that the message notification after the cache block read / write is completed is received by the IO engine. Optionally, when the states of the event notification descriptors of at least two read / write threads for processing the block write request are changed, it means that the processing of at least two read / write threads is completed, that is, the processing of the block read / write request is completed.
[0124] Exemplarily, when the states of the event notification descriptors corresponding to at least two read / write threads respectively change, it is determined that a message notification is received after the at least two read / write threads have completed reading and writing in their respective corresponding buffers. The message notification is used to indicate that the read / write thread processing is completed.
[0125] For example, at least two read / write threads include a first read / write thread, and the first read / write thread corresponds to a first event notification descriptor and a first mask value; when the state of the first event notification descriptor changes, the first buffer corresponding to the first mask value is read according to the first mask value corresponding to the first event notification descriptor; when the data in the first buffer is read successfully, it is determined that a message notification is received after the first read / write thread completes reading and writing in the first buffer. Optionally, the first read / write thread can be used to read and write the first part of the data in the first cache block of the first file. When the computing program successfully reads the first part of the data from the first buffer, it indicates that the first read / write thread has successfully read and written; when the computing program fails to read the first part of the data from the first buffer, it indicates that the first read / write thread has failed to read and write.
[0126] In summary, the method provided in this embodiment can use multiple read-write threads to process block read and write requests in parallel for a cache block, and configure an event notification descriptor for each read-write thread to detect the processing status of each read-write thread. After the state of the event notification descriptor changes, the processing result of the read-write thread can be read from the corresponding buffer according to the mask value corresponding to the event notification descriptor, and whether the read and write is successful is determined based on the processing result. When the states of the event notification descriptors of all read-write threads of the cache block change, the computing program can be informed that the block read and write request processing of the cache block is completed, triggering the subsequent processing of the computing program. Based on the event notification descriptor, asynchronous read and write message notification is implemented, which improves the data cache efficiency. In particular, in large data parallel computing programs, computing data and intermediate results can be efficiently cached to improve storage performance.
[0127] An exemplary embodiment of triggering the reading and writing of the next cache block based on a callback function is given below.
[0128] Fig. 9 A flowchart of a cache acceleration method provided by an exemplary embodiment of the present application is shown. The method can be implemented by a computer device. Figure 6 In the illustrated embodiment, step 220 includes step 221 , and step 230 includes step 240 .
[0129] Step 210: in the process of reading and writing the first file to the user-mode block device, determine the cache block corresponding to the first file.
[0130] Exemplarily, the number of cache blocks is at least two. For example, the cache blocks include the i-th cache block and the i+1-th cache block.
[0131] The computing program needs to send read and write requests for each cache block to the IO engine in turn to complete the read and write of the first file. The method provided in this embodiment registers the callback function of the cache block currently being read and written at the native layer. After the read and write of the current cache block is completed, the native layer is called back to automatically trigger the read and write request of the next cache block until the read and write requests of all cache blocks are processed, that is, the read and write of the first file is completed.
[0132] Exemplarily, the computer program includes an upper layer part and a lower layer part; the upper layer part registers a callback function of the ith cache block to the native layer of the operating system, and the callback function is used to call back when the lower layer part determines that the reading and writing of the ith cache block is completed.
[0133] Optionally, the upper layer part may be a program running in user mode, for example, the upper layer part may be a Spark RSS file IO thread or a Spark file cache write thread. The lower layer part may be a program running in kernel mode, for example, the lower layer part may be a Spark RSS native thread.
[0134] For example, after receiving the block read / write request initiated by the Spark file cache write thread, the Spark RSS file IO thread can register a callback function with the native layer and submit the block read / write request. The callback function is used to call back after the block read / write request is processed, trigger the submission of the next block read / write request if there is a next block read / write situation, or release native resources after all block read / write requests are processed.
[0135] Step 221, when the reading and writing of the i-th cache block is completed, a block reading and writing request for the i+1-th cache block is initiated to the kernel-mode IO engine; and an event notification descriptor is created.
[0136] Exemplarily, the computer program initiates a block read / write request for the first cache block to the IO engine, and creates respective efd and mask values for each read / write thread of the first cache block. After determining that the read / write of the first cache block is completed based on the efd and mask values, a block read / write request for the next cache block is initiated to the IO engine until the read / write of all cache blocks of the first file is completed.
[0137] Exemplarily, when the callback function is called back by the bottom layer and the i-th cache block is not the last cache block, the upper layer initiates a block read / write request for the i+1-th cache block to the kernel-mode input / output IO engine.
[0138] Exemplarily, the callback function corresponding to the block read and write request of the i-th cache block is triggered after the block read and write request is processed. The callback function determines whether there is a cache block that has not been processed. If so, it triggers the block read and write request of the next cache block; if not, it determines that the reading and writing of the first file is completed, releases the native resources occupied by the reading and writing of the first file, and releases the file descriptor of the first file.
[0139] Step 230: Based on the event notification descriptor, obtain the message notification of the IO engine after the cache block reading and writing is completed.
[0140] Exemplarily, the event notification descriptor is used to detect the processing status of multiple read / write threads corresponding to a cache block, and trigger the message notification of the completion of the read / write thread processing. The callback function is used to detect the processing status of a block read / write request of a cache block, and after the block read / write request of the current cache block is processed, trigger the submission of the block read / write request of the next cache block.
[0141] Step 240: When all cache blocks belonging to the first file have been read and written, the native resources occupied by the callback function in the operating system are released.
[0142] Exemplarily, when all cache blocks of the first file are read and written, the native resources occupied by the first file read and write are released. Exemplarily, when the block read and write request of the nth cache block is processed, the callback function is triggered, and in the absence of the next block read and write request, the first file read and write is determined to be completed, and the native resources allocated for the first file read and write are released.
[0143] In summary, the method provided in this embodiment realizes asynchronous processing of file reading and writing by registering a callback function of a block read and write request at the native layer, and calling back after the block read and write request is processed to trigger the submission of the next block read and write request. After submitting a block read and write request, the computing program can use the callback function to automatically trigger the submission of the next block read and write request after the previous block read and write request is processed, until all cached blocks of the file are read and written, thereby improving data caching efficiency, especially in large data parallel computing programs, which can efficiently cache computing data and intermediate results and improve storage performance.
[0144] Exemplarily, an embodiment of writing a file using the cache acceleration method provided in an embodiment of the present application is provided.
[0145] Fig.10 A flowchart of a cache acceleration method provided by an exemplary embodiment of the present application is shown. The method can be executed by a computer device. Among them, the Spark file cache write thread, the Spark RSS file IO class thread, and the Spark RSSNative thread are threads running the computing program. UBLK is a thread running the IO engine. The method includes the following steps.
[0146] Step 301: The Spark file cache write thread creates a file descriptor fd and initiates a write request for the first block of the first file to the Spark RSS file IO class thread.
[0147] The reading and writing of the native interface of each block (blocks at the Spark level correspond to blocks of HDFS, i.e., 128MB. For example, the blocks in the embodiments of the present application can default to 128MB) is implemented through the user-mode ublk framework and the io_uring backend. Among them, the native interface reading and writing specifically refers to the libc interface provided by the operating system, i.e., open, read, write, fcntl and other C language APIs. Spark write / read triggers the write / read of a block in non-blocking mode, and the native write / read is written / read according to the ublk API. When this write / read is completed, the control node ( / dev / ublkcX) of ublk sends a message / calls back the write / read request of the next block of the upper-level Spark until all blocks of the file are written / read and the file descriptor fd is closed (released).
[0148] Step 302: The Spark RSS file IO thread determines the write address of the current block and the write address of the next block, registers the callback function for block writing, and initializes the context for block writing. The Spark RSS file IO thread sends a write request to the Spark RSS Native thread, which carries the write address of the current block, the write address of the next block, and the callback function.
[0149] Step 303, the Spark RSS Native thread generates at least one write thread for the current block (for example, the block size is 128MB) according to iodepth (io depth); registers the event notification descriptor efd of each write thread's writing completion; starts the background submission task function to submit a write request to UBLK; starts the background event detection task to detect the efd status.
[0150] Optionally, a mask value corresponding to the event notification descriptor efd of each writing thread is configured, and the mask value is used to indicate the buffer address for executing the writing thread.
[0151] Step 304, UBLK performs disk writing based on io_uring; completes all write operations of the current block; after a thread completes writing, changes the corresponding efd state to notify the Spark RSS Native thread that the writing is completed.
[0152] Step 305, the Spark RSS Native thread polls the efd status and detects the write status of each write thread. When the efd status changes, the data in the corresponding buffer is read based on the mask value corresponding to the changed efd, and the completion status of the write thread is determined based on the data reading result. When all write threads have completed, it is determined that the current block is written. After the current block is written, the callback function is triggered to call back the Spark RSS file IO class thread.
[0153] For example, Fig.11 As shown, the Spark RSS Native thread registers the event notification descriptor efd 501 with the ublkc (control node) 502 of UBLK. After Ublkc determines that the write thread corresponding to efd has completed writing based on the CQ of io_uring, it changes the state of efd and notifies the application layer of the write status of the write thread. The Spark RSS Native thread polls the efd state, and after detecting the change of the efd state, it reads and processes the data from the corresponding buffer based on the mask value corresponding to efd.
[0154] The Spark RSS file IO thread detects whether there is a write request for the next block; if so, it triggers the write request for the next block and continues to execute step 302 to write the next block. If not, it indicates to the Spark file cache write thread that the file write to the L2 cache is completed, and the Spark file cache write thread destroys the related resources of this file write, for example, destroys the fd.
[0155] In an optional embodiment, the computer device has an L1 cache and an L2 cache, and the user-mode block device belongs to the L2 cache. The L1 cache is the memory of the computer device. When the usage rate of the L1 cache has reached an upper limit, the computing program determines to cache the first file in the L1 cache in the form of a block to the user-mode block device in the L2 cache.
[0156] like Fig.12As shown, before Spark RSS writes memory (i.e., L1 cache) data, it first checks whether the memory usage rate has exceeded the upper limit. If not, the pulled remote data 402 is directly cached to the local memory 403. If memory 403 exceeds the usage upper limit, Spark RSS wakes up the write-back thread pool 401, flushes the content in L1 cache 403 back to L2 cache 404, and clears the data in L1 cache 403 after the flush is completed. Among them, L2 cache 404 is an NVMe SSD storage disk. The remote data 402 pulled remotely is written to L1 cache 403. Among them, LVM (Logical Volume Manager) is a logical disk composed of multiple NVMe SSD disks, which can avoid IO errors caused by a single file size exceeding the remaining storage space of a single NVMe SSD disk in big data services.
[0157] For example, Java uses some programming interfaces of lib ublksrv for UBLK, and implements ublksrv (i.e., the upper user-mode programming interface corresponding to the ublk driver layer) inside the JVM, instead of using the traditional posix programming interface (file reading interfaces such as read and write, but using programming interfaces starting with ubdlib_, where ubd's programming interface for io_uring support is mainly used to implement an asynchronous callback mechanism based on file status). Java and lib ubd are implemented through JNI (Java native interface), and can also be implemented through JDK's FFI (Foreign Function & Memory API).
[0158] Exemplarily, the mechanism of io_uring is based on passing to the underlying layer the file descriptor to be written, the write / read buffer address, and the length, and then automatically completing the writing of this part of the data at the underlying layer and then notifying the upper layer of the completion. The upper layer is responsible for initializing the above read / write related parameters to the io_uring related interface and using this part of the data when the notification is completed. Therefore, only one block is submitted, and the read and write request of the next block depends on the completion callback of the previous block completed by the underlying layer to be triggered.
[0159] By adopting the cache acceleration method provided in the embodiment of the present application and using UIO (User Space IO), as shown in Table 1, the actual performance (bandwidth and IOPS) of Spark RSS can be improved by about 30%.
[0160] Table 1
[0161]
[0162] In summary, the method provided in this embodiment uses a user-state block device as a local cache device, so that the computing program can directly write cache data to the user-state block device, reducing the number of data transmissions between the user state and the kernel state, allowing the computing program to access the local cache device more directly, and reducing redundant processing in the kernel. Asynchronous writing is achieved through event notification descriptors, allowing tasks to be processed in parallel. When executing data caching, there is no need to wait for the previous write task to be completed, and other tasks can continue to be executed. After the write task is completed, the event notification descriptor triggers a notification message to notify the completion of the write, so as to trigger subsequent tasks of the computing program. This method improves the efficiency of data caching, especially in large data parallel computing programs, which can efficiently cache calculation data and intermediate results and improve storage performance.
[0163] Exemplarily, an embodiment of performing file reading using the cache acceleration method provided in an embodiment of the present application is provided.
[0164] Fig.13 A flowchart of a cache acceleration method provided by an exemplary embodiment of the present application is shown. The method can be executed by a computer device. Among them, the Spark file cache write thread, the Spark RSS file IO class thread, and the Spark RSSNative thread are threads running the computing program. UBLK is a thread running the IO engine. The method includes the following steps.
[0165] Step 401: The Spark file cache reading thread creates a file descriptor fd and initiates a read request for the first block of the first file to the Spark RSS file IO class thread.
[0166] Step 402: The Spark RSS file IO class thread determines the read address of the current block and the read address of the next block, registers the callback function for block reading, and initializes the context for block reading. The Spark RSS file IO class thread sends a read request to the Spark RSS Native thread, and the read request carries the read address of the current block, the read address of the next block, and the callback function.
[0167] Step 403, the Spark RSS Native thread generates at least one read thread for the current block (for example, the block size is 128MB) according to iodepth (io depth); registers the event notification descriptor efd of each read thread's read completion; starts the background submission task function to submit a read request to UBLK; starts the background event detection task to detect the efd status.
[0168] Optionally, a mask value corresponding to the event notification descriptor efd of each read thread is configured, and the mask value is used to indicate the buffer address for executing the read thread.
[0169] Step 404, UBLK performs disk reading based on io_uring; completes all read operations of the current block; after a thread completes reading, changes the corresponding efd state to notify the Spark RSS Native thread that the reading is completed.
[0170] Step 405, the Spark RSS Native thread polls the efd status and detects the reading status of each reading thread. When the efd status changes, the data in the corresponding buffer is read based on the mask value corresponding to the changed efd, and the completion status of the reading thread is determined based on the data reading result. When all reading threads have completed, it is determined that the current block reading is completed. After the current block reading is completed, the callback function is triggered to call back the Spark RSS file IO class thread.
[0171] The Spark RSS file IO thread detects whether there is a read request for the next block; if so, it triggers the read request for the next block and continues to execute step 302 to read the next block. If not, it indicates to the Spark file cache read thread that the file read L2 cache is completed, and the Spark file cache read thread destroys the related resources of this file read, for example, destroys fd.
[0172] In summary, the method provided in this embodiment uses a user-state block device as a local cache device, so that the computing program can directly read cache data from the user-state block device, reducing the number of data transmissions between the user state and the kernel state, allowing the computing program to access the local cache device more directly, and reducing redundant processing in the kernel. Asynchronous reading is achieved through event notification descriptors, allowing tasks to be processed in parallel. When executing data caching, there is no need to wait for the previous read task to be completed, and other tasks can continue to be executed. After the read task is completed, the event notification descriptor triggers a notification message to notify the completion of the read, so as to trigger subsequent tasks of the computing program. This method improves the efficiency of data caching, especially in large data parallel computing programs, and can efficiently cache calculation data and intermediate results, thereby improving storage performance.
[0173] The following is an embodiment of the device of the present application. For details not described in detail in the embodiment of the device, reference can be made to the corresponding records in the above method embodiment, and they will not be repeated herein.
[0174] Fig.14A schematic diagram of the structure of a cache acceleration device provided by an exemplary embodiment of the present application is shown. The device can be implemented as all or part of a computer device through software, hardware, or a combination of both. The device has a user-mode block device as a local cache device for a computing program, and the device includes:
[0175] A determination module 601 is used to determine a cache block corresponding to the first file in the process of reading and writing the first file to the user-mode block device;
[0176] The initiating module 602 is used to initiate a block read and write request of the cache block to the kernel-mode input and output IO engine, and to create an event notification descriptor; the event notification descriptor is used to indicate the read and write status of the block read and write request; the IO engine is used to asynchronously read and write the user-mode block device;
[0177] The notification module 603 is used to obtain the message notification of the IO engine after the reading and writing of the cache block is completed based on the event notification descriptor.
[0178] In an optional embodiment, the notification module 603 is used to poll the event notification descriptor;
[0179] The notification module 603 is used to determine, when the state of the event notification descriptor changes, that a message notification is received from the IO engine after the cache block reading and writing is completed;
[0180] The state of the event notification descriptor is changed by an event triggered by the IO engine after completing the block read / write request.
[0181] In an optional embodiment, the notification module 603 is used to split the read and write tasks of the cache block into at least two read and write threads according to the IO depth; the IO depth is used to indicate the number of IO requests processed in parallel by the IO engine;
[0182] The notification module 603 is used to create the event notification descriptors for the at least two read and write threads respectively;
[0183] The notification module 603 is used to determine that a message notification is received from the IO engine after the reading and writing of the cache block is completed when the states of the event notification descriptors corresponding to the at least two read and write threads are changed.
[0184] In an optional embodiment, the at least two read and write threads are respectively used to read and write data to corresponding buffers;
[0185] The notification module 603 is used to configure mask values corresponding to the at least two event notification descriptors respectively, and the mask values are used to indicate the buffer corresponding to the read / write thread;
[0186] The notification module 603 is used to determine that a message notification is received after the at least two read / write threads have completed reading and writing in their respective corresponding buffers when the states of the event notification descriptors respectively corresponding to the at least two read / write threads change.
[0187] In an optional embodiment, the at least two read-write threads include a first read-write thread, and the first read-write thread corresponds to a first event notification descriptor and a first mask value;
[0188] The notification module 603 is configured to read a first buffer corresponding to the first mask value according to the first mask value corresponding to the first event notification descriptor when the state of the first event notification descriptor changes;
[0189] The notification module 603 is used to determine, when the data in the first buffer is read successfully, that a message notification is received after the first reading and writing thread completes reading and writing in the first buffer.
[0190] In an optional embodiment, the cache block includes the i-th cache block and the i+1-th cache block;
[0191] The initiating module 602 is used to initiate a block read / write request for the (i+1)th cache block to the kernel-mode input / output IO engine when the reading and writing of the (i)th cache block is completed.
[0192] In an optional embodiment, the computing program includes an upper layer part and a lower layer part; the device further includes:
[0193] A callback module 604 is used for the upper layer to register a callback function of the i-th cache block to the native layer of the operating system, and the callback function is used to call back when the bottom layer determines that the reading and writing of the i-th cache block is completed;
[0194] The initiating module 602 is used for initiating a block read / write request of the i+1th cache block to the kernel-mode input / output IO engine when the callback function is called back by the bottom layer and the i-th cache block is not the last cache block.
[0195] In an optional embodiment, the device further includes:
[0196] The release module 606 is used to release the native resources occupied by the callback function in the operating system when the cache blocks belonging to the first file are all read and written.
[0197] In an optional embodiment, the device further includes:
[0198] The creation module 605 is used to create the NVMe flash disk as the user-mode block device.
[0199] In an optional embodiment, the apparatus has an L1 cache and an L2 cache, and the user-mode block device belongs to the L2 cache;
[0200] The determining module 601 is used to determine to cache the first file in the L1 cache in the form of blocks to the user-mode block device in the L2 cache when the usage rate of the L1 cache has reached an upper limit.
[0201] The present application also provides a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the cache acceleration method provided by each of the above method embodiments. It should be noted that the computer device can be as follows: Fig.15 Computer equipment provided.
[0202] Fig.15 The block diagram of a computer device 900 provided by an exemplary embodiment of the present application is shown. The computer device 900 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer IV), an MP4 player (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer IV), a laptop computer or a desktop computer. The computer device 900 may also be called a user account device, a portable computer device, a laptop computer device, a desktop computer device, or other names.
[0203] Those skilled in the art will understand that Fig.15 The structure shown in the figure does not constitute a limitation on the computer device 900, and the computer device 900 may include more or less components than those shown in the figure, or combine some components, or adopt a different arrangement of components.
[0204] The memory also includes one or more programs, which are stored in the memory and include a program for performing the cache acceleration method provided in the embodiment of the present application.
[0205] The present application also provides a computer device, which includes: a processor and a memory, wherein the storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the cache acceleration method provided by the above-mentioned method embodiments.
[0206] The present application also provides a computer-readable storage medium, which stores at least one instruction, at least one program, code set or instruction set. The at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the cache acceleration method provided by the above-mentioned method embodiments.
[0207] The present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the cache acceleration method provided in the above optional implementation.
[0208] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. A person of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware, or can be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium. The above-mentioned storage medium can be a read-only memory, a disk or an optical disk, etc. The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application.
[0209] It should be noted that before collecting relevant data of users and during the process of collecting relevant data of users, this application can display a prompt interface, pop-up window or output voice prompt information, and the prompt interface, pop-up window or voice prompt information is used to prompt the user that its relevant data is currently being collected, so that this application only starts to execute the relevant steps of obtaining relevant data of users after obtaining the confirmation operation issued by the user to the prompt interface or pop-up window, otherwise (that is, when the confirmation operation issued by the user to the prompt interface or pop-up window is not obtained), the relevant steps of obtaining relevant data of users are terminated, that is, the relevant data of users are not obtained. In other words, all user data collected by this application are collected with the consent and authorization of the user, and the collection, use and processing of relevant user data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
Claims
1. A cache acceleration method, characterized in that: The method is performed by a computer device having a user-mode block device as a local cache device for a computing program, and the method comprises: In the process of reading and writing a first file to the user-mode block device, determining a cache block corresponding to the first file; Initiate a block read and write request of the cache block to the kernel-mode input and output IO engine, and create an event notification descriptor; the event notification descriptor is used to indicate the read and write status of the block read and write request; the IO engine is used to asynchronously read and write the user-mode block device; Based on the event notification descriptor, a message notification is obtained after the IO engine completes reading and writing the cache block.
2. The method according to claim 1, characterized in that The obtaining, based on the event notification descriptor, a message notification after the IO engine completes reading and writing the cache block includes: polling the event notification descriptor; In the case where the state of the event notification descriptor changes, determining that a message notification is received from the IO engine after the cache block reading and writing is completed; The state of the event notification descriptor is changed by an event triggered by the IO engine after completing the block read / write request.
3. The method according to claim 2, characterized in that The creating event notification descriptor comprises: Splitting the read and write tasks of the cache block into at least two read and write threads according to the IO depth; the IO depth is used to indicate the number of IO requests processed in parallel by the IO engine; Creating the event notification descriptors for the at least two read-write threads respectively; In the case where the state of the event notification descriptor changes, determining that a message notification is received from the IO engine after the reading and writing of the cache block is completed includes: When the states of the event notification descriptors respectively corresponding to the at least two read and write threads change, it is determined that a message notification after the IO engine completes reading and writing the cache block is received.
4. The method according to claim 3, characterized in that The at least two read-write threads are respectively used to read and write data to the corresponding buffer; the method also includes: Configure mask values corresponding to the at least two event notification descriptors respectively, wherein the mask values are used to indicate the buffer corresponding to the read / write thread; When the states of the event notification descriptors respectively corresponding to the at least two read and write threads change, determining that a message notification is received from the IO engine after the reading and writing of the cache block is completed includes: When the states of the event notification descriptors respectively corresponding to the at least two read / write threads change, it is determined that a message notification is received after the at least two read / write threads complete reading and writing in their respective corresponding buffers.
5. The method according to claim 4, characterized in that The at least two read-write threads include a first read-write thread, and the first read-write thread corresponds to a first event notification descriptor and a first mask value; When the states of the event notification descriptors respectively corresponding to the at least two read / write threads change, determining that a message notification is received after the at least two read / write threads complete reading and writing the corresponding buffers includes: When the state of the first event notification descriptor changes, reading a first buffer corresponding to the first mask value according to the first mask value corresponding to the first event notification descriptor; When the data in the first buffer is read successfully, it is determined that a message notification is received after the first reading and writing thread completes the reading and writing of the first buffer.
6. The method according to any one of claims 1 to 5, characterized in that: The cache blocks include the i-th cache block and the i+1-th cache block; i is a positive integer; The initiating a block read and write request of the cache block to the kernel-mode input and output IO engine includes: When the reading and writing of the i-th cache block is completed, a block reading and writing request of the i+1-th cache block is initiated to the kernel-mode input and output IO engine.
7. The method according to claim 6, characterized in that The calculation program includes an upper layer part and a lower layer part; the method also includes: The upper layer part registers a callback function of the i-th cache block to the native layer of the operating system, and the callback function is used to call back when the bottom layer part determines that the reading and writing of the i-th cache block is completed; When the reading and writing of the i-th cache block is completed, initiating a block reading and writing request of the i+1-th cache block to the kernel-mode input and output IO engine includes: When the callback function is called back by the bottom layer part and the i-th cache block is not the last cache block, the upper layer part initiates a block read / write request for the i+1-th cache block to the kernel-mode input / output IO engine.
8. The method according to claim 6, characterized in that The method further comprises: When all cache blocks belonging to the first file have been read and written, the native resources occupied by the callback function in the operating system are released.
9. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: A non-volatile memory host controller interface specification NVMe flash disk is created as the user-mode block device.
10. The method according to any one of claims 1 to 5, characterized in that: The computer device has a first-level L1 cache and a second-level L2 cache, and the user-mode block device belongs to the L2 cache; The method further comprises: When the usage rate of the L1 cache has reached an upper limit, it is determined to cache the first file in the L1 cache in the form of blocks to the user-mode block device in the L2 cache.
11. A cache acceleration device, characterized in that: The device has a user-mode block device as a local cache device for a computing program, and the device comprises: A determination module, configured to determine a cache block corresponding to the first file during a process of reading and writing the first file to the user-mode block device; An initiating module, used to initiate a block read and write request of the cache block to the kernel-mode input and output IO engine, and to create an event notification descriptor; the event notification descriptor is used to indicate the read and write status of the block read and write request; the IO engine is used to asynchronously read and write the user-mode block device; The notification module is used to obtain the message notification of the IO engine after the reading and writing of the cache block is completed based on the event notification descriptor.
12. A computer device, characterized in that: The computer device includes: a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set are loaded and executed by the processor to implement the cache acceleration method as described in any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set are loaded and executed by the processor to implement the cache acceleration method as described in any one of claims 1 to 10.
14. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium; a processor reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to implement the cache acceleration method as described in any one of claims 1 to 10.