File reading method and device, computer equipment and readable storage medium
By creating dedicated data transmission channels for file reading senders and receivers during algorithm training, and directly using data block addresses to read files, the problem of low reading efficiency of massive small files and high IOPS resource consumption is solved, and efficient file processing is achieved. Read.
Patent Information
- Application Number
- CN202410934730.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-10-22
AI Technical Summary
In algorithm training scenarios, the reading efficiency of massive small files in traditional methods is low, resulting in high IOPS resource consumption and unable to effectively reduce the reading complexity and resource consumption of traditional file systems.
By creating a file reading sending end and receiving end, a dedicated file data transmission channel is formed, and file data is read directly by searching for the data block address, skipping the reading method of the traditional file system, reducing IOPS resource consumption, and improving file reading efficiency. .
In the algorithm training scenario, it greatly improves the reading efficiency of massive small files, reduces IOPS resource consumption, avoids the time-consuming establishment and destruction of multiple transmission channels, and saves storage space and network resources.
Smart Images

Figure CN118819418A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a file reading method, device, computer equipment, computer-readable storage medium and computer program product. Background Art
[0002] Currently, algorithm training is mainly carried out by reading data from storage servers. The reading process of each file requires at least one IOPS (Input / Output Operations Per Second) to determine whether the file exists and whether there is permission to read it, and then copy and transfer the file content. In the algorithm training scenario of massive file data, it usually consumes IOPS resources twice the number of files.
[0003] In order to reduce the consumption of IOPS resources, the traditional method reduces the consumption of IOPS resources by compressing and packaging a large number of small files into a large file in advance. In this way, only one file needs to be read during algorithm training, which consumes only one IOPS resource. However, the large file created in this way takes up a huge amount of space. If compression is used, it takes a long time to run the compression algorithm and the decompression algorithm. Therefore, the traditional method has the problem of low file reading efficiency in the algorithm training scenario. Summary of the invention
[0004] Based on this, it is necessary to provide a file reading method, device, computer equipment, computer-readable storage medium and computer program product that can improve the file reading efficiency in algorithm training scenarios in response to the above technical problems.
[0005] In a first aspect, the present application provides a file reading method, comprising:
[0006] In response to the algorithm training start instruction, a file reading sending end and a file receiving end are created;
[0007] After the file reading sending end and the file receiving end are successfully connected, the file reading sending end reads multiple data block addresses in the created index file, and reads the corresponding file data from the data area in sequence according to each data block address, and then serially packages each file data and sends it to the file receiving end in sequence;
[0008] Each packaged file data is unpacked and reassembled through the file receiving end to obtain multiple processed files; the processed files are used for algorithm training.
[0009] In one embodiment, the step of constructing the index file includes:
[0010] Obtain multiple files to be processed, and save the multiple files to be processed to the data area;
[0011] According to the file path and occupied space of each to-be-processed file in the data area, the data block address corresponding to the to-be-processed file is determined, and the data block address corresponding to each to-be-processed file is stored in the index file.
[0012] In one embodiment, the file reading method further includes:
[0013] When detecting that the occupied space of any file to be processed changes, the data block address corresponding to the file to be processed is updated according to the changed occupied space;
[0014] Update the index file according to the updated data block address.
[0015] In one embodiment, the data of each file is serially packaged and sent to the file receiving end in sequence, including:
[0016] Get the space occupied by each file data;
[0017] Serially packing the data of each file according to the occupied space to obtain a plurality of packed file data;
[0018] Send multiple packaged files to the file receiving end in sequence.
[0019] In one embodiment, each file data is serially packaged according to the occupied space to obtain a plurality of packaged file data, including:
[0020] Traversing all the read file data, if the space occupied by any file data is greater than a preset threshold, dividing the file data into multiple file segments according to the preset threshold; and packaging the multiple file segments respectively;
[0021] When the sum of the occupied space of the at least one file data is not greater than a preset threshold, packaging the at least one file data together;
[0022] Until all the file data are read, the traversal is completed and multiple packaged file data are obtained.
[0023] In one embodiment, the file receiving end unpacks and reassembles each packaged file data to obtain multiple processed files, including:
[0024] Unpacking each packaged file data through the file receiving end to obtain multiple unpacked files;
[0025] Determine a first candidate file including a file header and a second candidate file not including a file header from the multiple unpacked files, and cut the first candidate file according to the file header mark bit in the first candidate file to obtain multiple cut files;
[0026] For each cut file, a corresponding target file is determined from the second candidate file according to the data block address corresponding to the cut file; the cut file and the target file are concatenated to obtain a processed file.
[0027] In a second aspect, the present application also provides a file reading device, comprising:
[0028] A creation module, used for creating a file reading sending end and a file receiving end in response to an algorithm training start instruction;
[0029] The reading module is used to read multiple data block addresses in the created index file through the file reading sending end after the file reading sending end and the file receiving end are successfully connected, and read the corresponding file data from the data area in sequence according to each data block address, and serially package each file data and send it to the file receiving end in sequence;
[0030] The processing module is used to unpack and reassemble each packaged file data through the file receiving end to obtain multiple processed files; the processed files are used for algorithm training.
[0031] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0032] In response to the algorithm training start instruction, a file reading sending end and a file receiving end are created;
[0033] After the file reading sending end and the file receiving end are successfully connected, the file reading sending end reads multiple data block addresses in the created index file, and reads the corresponding file data from the data area in sequence according to each data block address, and then serially packages each file data and sends it to the file receiving end in sequence;
[0034] Each packaged file data is unpacked and reassembled through the file receiving end to obtain multiple processed files; the processed files are used for algorithm training.
[0035] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0036] In response to the algorithm training start instruction, a file reading sending end and a file receiving end are created;
[0037] After the file reading sending end and the file receiving end are successfully connected, the file reading sending end reads multiple data block addresses in the created index file, and reads the corresponding file data from the data area in sequence according to each data block address, and then serially packages each file data and sends it to the file receiving end in sequence;
[0038] Each packaged file data is unpacked and reassembled through the file receiving end to obtain multiple processed files; the processed files are used for algorithm training.
[0039] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0040] In response to the algorithm training start instruction, a file reading sending end and a file receiving end are created;
[0041] After the file reading sending end and the file receiving end are successfully connected, the file reading sending end reads multiple data block addresses in the created index file, and reads the corresponding file data from the data area in sequence according to each data block address, and then serially packages each file data and sends it to the file receiving end in sequence;
[0042] Each packaged file data is unpacked and reassembled through the file receiving end to obtain multiple processed files; the processed files are used for algorithm training.
[0043] The above-mentioned file reading method, device, computer equipment, computer-readable storage medium and computer program product, at the beginning of algorithm training, form a dedicated file data transmission channel by creating a file reading sending end and a file receiving end. Each file data is transmitted through the file data transmission channel, so that the transmission of file data skips the traditional file system reading method and reduces the file reading steps to one, that is, reading each file data by searching the data block address. Complex judgments such as whether the file exists and whether there is permission to read only need to be performed once, and the consumption of IOPS resources is reduced to only one, avoiding the time-consuming establishment and destruction of multiple transmission channels. When reading massive small files in the algorithm training scenario, the file reading efficiency is greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions 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 related drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 An application environment diagram of a file reading method in an embodiment;
[0046] Figure 2 A schematic diagram of a flow chart of a file reading method in an embodiment;
[0047] Figure 3 A schematic diagram of communication between a data area and a training area in one embodiment;
[0048] Figure 4 The figure is a schematic diagram of the overall process of a file reading method in one embodiment;
[0049] Figure 5 is a structural block diagram of a file reading device in an embodiment;
[0050] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0052] Currently, algorithm training is mainly carried out by reading data from storage servers. The reading process of each file requires at least one IOPS (Input / Output Operations Per Second) to determine whether the file exists and whether there is permission to read it, and then copy and transfer the file content. In the algorithm training scenario of massive file data, it usually consumes IOPS resources twice the number of files.
[0053] In order to reduce the consumption of IOPS resources, the traditional method 1 reduces the consumption of IOPS resources by compressing and packaging a large number of small files into a large file in advance. In this way, only one file needs to be read during algorithm training, which consumes only one IOPS resource. However, this large file takes up a huge amount of space. If it is not compressed, it needs to occupy the same space as the large number of small files for storage; if compression is used, it takes a long time to run the compression algorithm and decompression algorithm; and there is an upper limit on the storage of large files, which cannot exceed the maximum capacity of a single disk; in addition, after the file data is updated, the large file needs to be re-created, which takes a long time. In the traditional method 2, a large number of small files are pre-read on the reading end and cached. However, this method cannot reduce the consumption of the first IOPS resource reading. For example, a small file of 100 million still needs to consume at least 100 million IOPS resources, and the cache utilization rate is not high for large training centers that cannot fix training servers. In the traditional method 3, high-performance storage is purchased to support the concurrent reading of massive IOPS, but this method is very expensive and does not reduce the resource consumption of IOPS. Therefore, traditional methods have the problem of high IOPS resource consumption when reading massive small files in algorithm training scenarios, resulting in low file reading efficiency.
[0054] Therefore, an embodiment of the present application proposes a file reading method. At the beginning of algorithm training, a dedicated file data transmission channel is formed by creating a file reading sending end and a file receiving end. Each file data is transmitted through the file data transmission channel, so that the transmission of file data skips the traditional file system reading method, and the steps of reading files are reduced to one, that is, reading each file data by searching for the data block address. Complex judgments such as whether the file exists and whether there is permission to read only need to be performed once, and the consumption of IOPS resources is reduced to only one, avoiding the time-consuming establishment and destruction of multiple transmission channels. When reading massive small files in the algorithm training scenario, the file reading efficiency is greatly improved.
[0055] The file reading method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The file reading method provided in this embodiment can be applied to the terminal 102, or to the server 104, or to a system including the terminal 102 and the server 104, and is implemented through the interaction between the terminal 102 and the server 104. Taking the application to the server 104 as an example, the server 104 responds to the algorithm training start instruction and creates a file reading sending end and a file receiving end; after the file reading sending end and the file receiving end are successfully connected, the file reading sending end reads multiple data block addresses in the created index file, and reads the corresponding file data from the data area in turn according to each data block address, and sends each file data to the file receiving end after serial packaging in turn; each packaged file data is unpacked and reorganized by the file receiving end to obtain multiple processed files; the processed files are used for algorithm training. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be an independent physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.
[0056] In an exemplary embodiment, Figure 2 As shown, a file reading method is provided, which is applied to Figure 1 The server 104 in the example is used as an example to illustrate the method, which includes the following steps 202 to 206. Among them:
[0057] Step 202: In response to the algorithm training start instruction, a file reading sending end and a file receiving end are created.
[0058] Among them, algorithm training often requires massive data as training samples. The file reading method proposed in the embodiment of the present application is mainly aimed at algorithm training scenarios, reading massive small files and using them as sample data for algorithm training, which can be applied to algorithm training in various application fields.
[0059] After receiving the algorithm training start instruction, the server responds to the algorithm training start instruction and uses a software method to create a file reading sending end and a file receiving end. In some embodiments, the server can use a communication protocol such as UDP (User Datagram Protocol) to create a file reading sending end and a file receiving end.
[0060] Step 204, after the file reading sending end and the file receiving end are successfully connected, the file reading sending end reads multiple data block addresses in the created index file, and reads the corresponding file data from the data area in sequence according to each data block address, and then packages each file data serially and sends it to the file receiving end in sequence.
[0061] The file reading sending end sends a connection request, and after receiving a message fed back by the file receiving end, determines that the file reading sending end and the file receiving end are successfully connected.
[0062] In some embodiments, the data storage system is used as a data area, and an index file is pre-created. The index file stores the data block addresses corresponding to multiple files. Each data block address is used to indicate the position occupied by the corresponding file in the data area. The data block address refers to the physical address of the file.
[0063] The server reads multiple data block addresses in the created index file from the data area through the file reading sender.
[0064] The data area stores a plurality of files, which may be, for example, a large number of small files. For example, the large number of files may be small files of the order of tens of thousands or hundreds of millions, and the small files may be files of less than 100K. It is to be understood that the embodiment of the present application does not specifically limit the number of files and the size of the files.
[0065] Since the data block address corresponds to the file one by one, the server can read the corresponding file data from the data area according to the data block address. In some embodiments, each data block address has a front-to-back sequence, and the file reading sending end can read the corresponding file data in sequence according to the front-to-back sequence of each data block address.
[0066] Serial packaging refers to a method of packaging each file data in sequence, and after each file data is packaged, it will be sent to the file receiving end.
[0067] Step 206, unpacking and reorganizing each packaged file data through the file receiving end to obtain multiple processed files; the processed files are used for algorithm training.
[0068] Among them, since the file data transmitted to the file receiving end is packaged data, the packaged file can be unpacked to restore the file data. In some embodiments, if the file data exceeds a preset threshold, the file can be split and packaged, or if the file data is less than a preset threshold, multiple files can be packaged together. Therefore, there may be more than one file in the packaged file, and the server can reorganize the unpacked files to obtain a complete processed file that is the same as the original file.
[0069] In the above file reading method, at the beginning of algorithm training, a dedicated file data transmission channel is formed by creating a file reading sender and a file receiver. Each file data is transmitted through the file data transmission channel, so that the transmission of file data skips the traditional file system reading method and reduces the steps of reading files to one, that is, reading each file data by searching for the data block address. Complex judgments such as whether the file exists and whether there is permission to read only need to be performed once, and the consumption of IOPS resources is reduced to only one, avoiding the time-consuming establishment and destruction of multiple transmission channels. When reading massive small files in the algorithm training scenario, the file reading efficiency is greatly improved.
[0070] In an exemplary embodiment, the steps of constructing an index file include: obtaining multiple files to be processed and saving the multiple files to be processed to a data area; determining the data block address corresponding to the file to be processed according to the file path and occupied space of each file to be processed in the data area, and storing the data block address corresponding to each file to be processed in the index file.
[0071] The files to be processed may be files used for algorithm training. The files to be processed are stored in a remote data area, which communicates with the training area for algorithm training via a network. The index file needs to be constructed before algorithm training. Specifically, multiple files to be processed are obtained and saved in the data area. Figure 3 The figure shows a schematic diagram of the communication between the data area and the training area in one embodiment. The data area stores multiple small files and an index file small_images.dat. In the training area, a dedicated file data transmission channel is created through SmallFileDataLoader to read each small file in the data area and save it to the data buffer.
[0072] The file path refers to the address of the file to be processed in the user space. For example, the file path of the file to be processed is: / data / small_images. The occupied space is used to characterize the size of the file to be processed. An index file is established in the data area. For example, an index file can be established under the file path where the file to be processed is located. For example, the established index file is: / data / small_images.dat. The file path and occupied space of each file to be processed in the data area are converted into a data block address, and the data block address corresponding to each file to be processed is stored in the index file.
[0073] In this embodiment, by converting the file path of the file to be processed into a data block address and writing it into an index file, the index file stores the data block address corresponding to the file to be processed. When the file receiving end reads the file to be processed, it can directly read the file to be processed through the data block address, avoiding the need for complex permission judgment when reading the file according to the application layer file path, which is conducive to improving file reading efficiency.
[0074] In an exemplary embodiment, the file reading method further includes: upon detecting that the occupied space of any file to be processed changes, updating the data block address corresponding to the file to be processed according to the changed occupied space; and updating the index file according to the updated data block address.
[0075] If the space occupied by any file to be processed changes, for example, the space occupied by the file to be processed changes from 10K to 100K, it is necessary to recalculate the data block address corresponding to the file to be processed and update the data block address corresponding to the file to be processed in the index file.
[0076] In this embodiment, by timely updating the index file when the occupied space of the to-be-processed file changes, it is helpful to ensure that the latest data block address is stored in the index file, which is beneficial to the accuracy of file reading.
[0077] In an exemplary embodiment, each file data is packaged serially and sent to the file receiving end in sequence, including: obtaining the occupied space of each file data; serially packaging each file data according to the occupied space to obtain multiple packaged file data; and sending the multiple packaged files to the file receiving end in sequence.
[0078] Among them, since the space occupied by each file is different, the space occupied may be too large or too small. Serial packaging can cut files that occupy too much space or merge files that occupy too little space according to the occupied space, thereby improving the efficiency of file data transmission.
[0079] The file reading sender can create a queue, write multiple packaged files into the queue, and send the data to the file receiving end in the form of the queue.
[0080] In this embodiment, each file data is packaged serially according to the occupied space of the file data, and then sent to the file receiving end in sequence. Since the data block addresses of each file have a certain order, serial packaging and sequential sending are helpful to ensure that the order of data received by the file receiving end is consistent with the order of each file data in the data area.
[0081] In an exemplary embodiment, each file data is serially packaged according to the occupied space to obtain multiple packaged file data, including: traversing all the read file data, and when the occupied space of any file data is greater than a preset threshold, dividing the file data into multiple file fragments according to the preset threshold; packaging the multiple file fragments separately; when the sum of the occupied spaces of at least one file data is not greater than the preset threshold, packaging at least one file data together; until all the read file data are traversed, and multiple packaged file data are obtained.
[0082] Among them, for all file data to be read, the file reading sending end traverses in sequence. In the case that the occupied space of any file data is greater than a preset threshold, the file data can be divided into multiple file fragments according to the multiples of the occupied space and the preset threshold. For example, if the occupied space is 310K and the preset threshold is 100K, the file data can be divided into 4 text fragments, and each text fragment is at most 100K. In some embodiments, for the divided text fragments corresponding to each of the multiple file data, if the sum of at least one text fragment is not greater than the preset threshold, at least one text fragment can be packaged together into one file. For example, a text fragment A1 of file data A is 30K, and a text fragment B1 of text data B is 40K, and text fragment A1 and text fragment B1 can be packaged together into one file.
[0083] If the total occupied space of at least one file data is not greater than a preset threshold, the at least one file data may be packaged into one file. After all the file data are traversed, a plurality of packaged file data are obtained.
[0084] In this embodiment, text data larger than a preset threshold is divided into text segments and packaged separately, and at least one file whose total occupied space is not larger than the preset threshold is merged and packaged. This helps each packaged file to occupy a relatively uniform space, which helps to improve file transmission efficiency.
[0085] In an exemplary embodiment, each packaged file data is unpacked and reorganized by a file receiving end to obtain multiple processed files, including: unpacking each packaged file data by a file receiving end to obtain multiple unpacked files; determining a first candidate file containing a file header and a second candidate file not containing a file header from the multiple unpacked files, and cutting the first candidate file according to a file header mark bit in the first candidate file to obtain multiple cut files; for each cut file, determining a corresponding target file from the second candidate file according to a data block address corresponding to the cut file; and splicing the cut files and the target file to obtain a processed file.
[0086] Among them, since the file received by the file receiving end is a packaged file, the file receiving end needs to unpack the packaged file. If the file is compressed after packaging, the file receiving end can also decompress the file.
[0087] refer to Figure 3 ,Since the files may be divided into text segments or merged and packaged when ,packing, the unpacked files need to be reassembled to restore the original text data.
[0088] The multiple unpacked files include a first candidate file that includes a file header and a second candidate file that does not include a file header. For the first candidate file, the file receiving end can cut the first candidate file according to the file header mark bit, thereby obtaining multiple cut files. Each cut file is a file that includes a file header.
[0089] For each cut file, the corresponding target file can be determined in the second candidate file according to the data block address corresponding to the cut file. The processed data obtained by splicing the cut file with the target file is the original file data.
[0090] In this embodiment, each packaged file data is unpacked by the file receiving end. For the first candidate file containing the file header, it can be cut according to the file header mark bit. For the cut file, the corresponding target file can be found in the second candidate file. Thus, the cut file can be spliced with the target file to restore the original file data, thereby realizing remote reading of text data.
[0091] In some embodiments, if the file reading sending end detects that any packaged file data fails to be sent, the file reading sending end saves the corresponding data into a failure record table and continues to send the next packaged file data to the file receiving end. If the file receiving end detects that any packaged file data fails to be received, the file receiving end saves the corresponding data into a failure record table and continues to receive the next packaged file data.
[0092] In some embodiments, there are multiple index files that have been created; the file reading method also includes: in response to an algorithm training start instruction, creating multiple file data transmission channels, wherein each file data transmission channel includes a file reading sending end and a file receiving end; each file data transmission channel corresponds to an index file; for any file data transmission channel, after the file reading sending end and the file receiving end of the current file data transmission channel are successfully connected, the file reading sending end reads multiple data block addresses in the created index file, and reads the corresponding file data from the data area in turn according to each data block address, and packages each file data in series and sends it to the file receiving end in turn; the file receiving end unpacks and reassembles each packaged file data to obtain multiple processed files; the processed files are used for algorithm training.
[0093] To explain the file reading method and effect in this solution in detail, a most detailed embodiment is described below:
[0094] This article takes the reading of a large number of small files in the algorithm training scenario as an example. Figure 4 FIG. 1 is a schematic diagram of the overall process of a file reading method in an embodiment.
[0095] In response to the algorithm training start instruction, the server creates a dedicated file data transmission channel in the training area through SmallFileDataLoader. The file data transmission channel includes a file reading sender and a file receiving end. After the file reading sender and the file receiving end are successfully connected, the file reading sender reads multiple data block addresses in the created index file, and reads the corresponding file data from the data area in turn according to each data block address, and packages each file data in series and sends it to the file receiving end in turn; the file receiving end unpacks and reassembles each packaged file data to obtain multiple processed files, which are used for algorithm training.
[0096] The index file is extracted and constructed in the data area. Specifically, multiple files to be processed are obtained and saved in the data area. According to the file path and occupied space of each file to be processed in the data area, the data block address corresponding to the file to be processed is determined, and the data block address corresponding to each file to be processed is stored in the index file. For example, the file path of the file to be processed is: / data / small_images, and the index file is: / data / small_images.dat.
[0097] When it is detected that the occupied space of any to-be-processed file changes, the data block address corresponding to the to-be-processed file is updated according to the changed occupied space, and the index file is updated according to the updated data block address.
[0098] Among them, each file data is packaged serially and then sent to the file receiving end in sequence, including: obtaining the occupied space of each file data, traversing all the read file data, and when the occupied space of any file data is greater than a preset threshold, dividing the file data into multiple file fragments according to the preset threshold; packaging the multiple file fragments respectively; when the sum of the occupied spaces of at least one file data is not greater than the preset threshold, packaging at least one file data together; until all the read file data are traversed, a plurality of packaged file data are obtained.
[0099] The method comprises: unpacking and reorganizing each packaged file data through a file receiving end to obtain a plurality of processed files, including: unpacking each packaged file data through a file receiving end to obtain a plurality of unpacked files; determining a first candidate file including a file header and a second candidate file not including a file header from the plurality of unpacked files, cutting the first candidate file according to a file header mark bit in the first candidate file to obtain a plurality of cut files; for each cut file, determining a corresponding target file from the second candidate file according to a data block address corresponding to the cut file; and splicing the cut files and the target file to obtain a processed file.
[0100] In some embodiments, if the file reading sending end detects that any packaged file data fails to be sent, the file reading sending end saves the corresponding data into a failure record table and continues to send the next packaged file data to the file receiving end. If the file receiving end detects that any packaged file data fails to be received, the file receiving end saves the corresponding data into a failure record table and continues to receive the next packaged file data.
[0101] Since the embodiment of the application needs to make the index file small_files.dat in advance and reserve enough data cache space in the training area, the efficiency of the scenario of algorithm training reading a large number of small files is significantly improved, and the solution adopted in most algorithm training scenarios is to develop or purchase high-performance storage to solve this problem; the embodiment of the present application can be based on low-cost storage, by using the time and computing power of making small_files.dat, plus the data cache space in the training area to exchange for the efficiency of small file reading. In addition, the embodiment of the present application can also be applied to other scenarios that do not need to care about file permissions, and can build index files similar to small_files.dat in advance. It should be noted that if the file is updated, the index file also needs to be updated accordingly. At the same time, the file data transmission channel can also be designed as multiple channels. This is a balance issue. Opening too many channels will increase the time consumption of the reading end and the receiving end, and adjustments should be made based on specific circumstances and observations.
[0102] The above-mentioned file reading method, device, computer equipment, computer-readable storage medium and computer program product, at the beginning of algorithm training, form a dedicated file data transmission channel by creating a file reading sending end and a file receiving end, and each file data is transmitted through the file data transmission channel, so that the transmission of file data skips the reading method of the traditional file system, and reduces the steps of reading files to one, that is, reading each file data by finding the data block address, and complex judgments such as whether the file exists and whether there is permission to read only need to be performed once, and the consumption of IOPS resources is reduced to only one, avoiding the time-consuming establishment and destruction of multiple transmission channels, and greatly improving the file reading efficiency when reading massive small files in the algorithm training scenario. In addition, this method solves the network storage bottleneck of massive small files in algorithm training. Through a customized file reading sending end, a file receiving end and a proprietary file protocol, a proprietary file data transmission channel can be created, which can reduce the resource consumption of IOPS on the network without increasing the new file storage cost, saving storage space, and greatly reducing the occupied network, so as to achieve the purpose of low cost and efficiency.
[0103] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0104] Based on the same inventive concept, the embodiment of the present application also provides a file reading device for implementing the file reading method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more file reading device embodiments provided below can refer to the limitations on the file reading method above, and will not be repeated here.
[0105] In an exemplary embodiment, Figure 5 As shown, a file reading device 500 is provided, comprising: a creation module 520, a reading module 540 and a processing module 560, wherein:
[0106] A creation module 520, for creating a file reading sending end and a file receiving end in response to an algorithm training start instruction;
[0107] The reading module 540 is used to read multiple data block addresses in the created index file through the file reading sending end after the file reading sending end and the file receiving end are successfully connected, and read the corresponding file data from the data area in sequence according to each data block address, and serially package each file data and send it to the file receiving end in sequence;
[0108] The processing module 560 is used to unpack and reassemble each packaged file data through the file receiving end to obtain multiple processed files; the processed files are used for algorithm training.
[0109] The above-mentioned file reading device, at the beginning of algorithm training, forms a dedicated file data transmission channel by creating a file reading sending end and a file receiving end. Each file data is transmitted through the file data transmission channel, so that the transmission of file data skips the reading method of the traditional file system, and reduces the steps of reading files to one, that is, reading each file data by searching for the data block address. Complex judgments such as whether the file exists and whether there is permission to read only need to be performed once, and the consumption of IOPS resources is reduced to only one, avoiding the time-consuming establishment and destruction of multiple transmission channels. When reading massive small files in the algorithm training scenario, the file reading efficiency is greatly improved.
[0110] In one embodiment, in the step of constructing the index file, the reading module 540 is also used to: obtain multiple files to be processed, and save the multiple files to be processed to the data area; determine the data block address corresponding to the file to be processed according to the file path and occupied space of each file to be processed in the data area, and store the data block address corresponding to each file to be processed in the index file.
[0111] In one embodiment, the file reading device also includes an update module, which is used to: when detecting that the occupied space of any file to be processed changes, update the data block address corresponding to the file to be processed according to the changed occupied space; and update the index file according to the updated data block address.
[0112] In one embodiment, each file data is packaged serially and sent to the file receiving end in sequence. The reading module 540 is also used to: obtain the occupied space of each file data; package each file data serially according to the occupied space to obtain multiple packaged file data; and send the multiple packaged files to the training area in sequence.
[0113] In one embodiment, each file data is serially packaged according to the occupied space to obtain multiple packaged file data, and the reading module 540 is also used to: traverse all the read file data, and when the occupied space of any file data is greater than a preset threshold, divide the file data into multiple file fragments according to the preset threshold; package the multiple file fragments separately; when the sum of the occupied spaces of at least one file data is not greater than the preset threshold, package at least one file data together; until all the read file data are traversed and multiple packaged file data are obtained.
[0114] In one embodiment, each packaged file data is unpacked and reorganized through the file receiving end to obtain multiple processed files, and the processing module 560 is also used to: unpack each packaged file data through the file receiving end to obtain multiple unpacked files; determine a first candidate file containing a file header and a second candidate file not containing a file header from the multiple unpacked files, and cut the first candidate file according to the file header mark bit in the first candidate file to obtain multiple cut files; for each cut file, determine the corresponding target file from the second candidate file according to the data block address corresponding to the cut file; splice the cut files and the target file to obtain a processed file.
[0115] Each module in the above-mentioned file reading device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.
[0116] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store index files, file data, and processed files. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a file reading method is implemented.
[0117] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0118] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0119] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0120] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0121] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0122] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0123] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0124] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A file reading method, It is characterized in that The method comprises: In response to the algorithm training start instruction, a file reading sending end and a file receiving end are created; After the file reading sending end and the file receiving end are successfully connected, the file reading sending end reads multiple data block addresses in the created index file, reads corresponding file data from the data area in sequence according to each data block address, and serially packages each file data and sends it to the file receiving end in sequence; The file receiving end unpacks and reassembles each packaged file data to obtain a plurality of processed files; the processed files are used for algorithm training.
2. The method according to claim 1, It is characterized in that The steps of constructing the index file include: Obtain multiple files to be processed, and save the multiple files to be processed to the data area; According to the file path and occupied space of each to-be-processed file in the data area, the data block address corresponding to the to-be-processed file is determined, and the data block address corresponding to each to-be-processed file is stored in the index file.
3. The method according to claim 2, It is characterized in that The method further comprises: When detecting that the occupied space of any to-be-processed file changes, updating the data block address corresponding to the to-be-processed file according to the changed occupied space; The index file is updated according to the updated data block address.
4. The method according to claim 1, It is characterized in that The step of serially packaging the file data and sequentially sending the data to the file receiving end comprises: Get the space occupied by each file data; Serially packaging each file data according to the occupied space to obtain a plurality of packaged file data; The multiple packaged files are sent to the file receiving end in sequence.
5. The method according to claim 4, It is characterized in that The step of serially packaging each file data according to the occupied space to obtain a plurality of packaged file data includes: Traversing all the read file data, if the space occupied by any file data is greater than a preset threshold, dividing the file data into multiple file segments according to the preset threshold; and packaging the multiple file segments respectively; When the sum of the occupied space of at least one file data is not greater than a preset threshold, packing the at least one file data together; Until all the file data are read, the traversal is completed and multiple packaged file data are obtained.
6. The method according to claim 1, It is characterized in that The file receiving end unpacks and reassembles each packaged file data to obtain multiple processed files, including: Unpacking each packaged file data through the file receiving end to obtain multiple unpacked files; Determine a first candidate file including a file header and a second candidate file not including a file header from the multiple unpacked files, and split the first candidate file according to the file header mark bit in the first candidate file to obtain multiple split files; For each cut file, a corresponding target file is determined from the second candidate file according to the data block address corresponding to the cut file; and the cut file and the target file are concatenated to obtain a processed file.
7. A file reading device, It is characterized in that The device comprises: A creation module, used for creating a file reading sending end and a file receiving end in response to an algorithm training start instruction; A reading module, used for reading a plurality of data block addresses in the created index file through the file reading sending end after the file reading sending end and the file receiving end are successfully connected, and reading the corresponding file data from the data area in sequence according to each data block address, and serially packaging each file data and sending it to the file receiving end in sequence; The processing module is used to unpack and reassemble each packaged file data through the file receiving end to obtain multiple processed files; the processed files are used for algorithm training.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
