Data dump method and electronic device
By using thread pooling technology in electronic devices, parallel dumping of multiple image files is achieved, solving the problem of low dumping efficiency in the existing technology, and improving memory utilization and dumping speed.
Patent Information
- Application Number
- CN202410198071.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-21
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2044-02-21
AI Technical Summary
In the prior art, electronic devices spend a long time when dumping image files from memory to disk and occupy more memory resources, resulting in low dumping efficiency.
Using thread pooling technology, multiple threads simultaneously send memory addresses to the kernel layer, so that the kernel layer can read and dump multiple files to disk in parallel, reducing memory storage time and resource usage.
Improve the efficiency of image files dumping, reduce memory storage pressure and occupancy, and ensure an efficient data dumping process.
Smart Images

Figure CN119248673B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data dump method and electronic device. Background Art
[0002] Electronic devices such as mobile phones and tablet computers are usually equipped with cameras and have camera applications installed. The electronic devices can obtain images captured by the cameras based on the camera applications.
[0003] Currently, due to the fast reading and writing speed of memory, after the camera application obtains the initial image through the camera, it can store the frame files, metadata files, database files and other files corresponding to the initial image in the memory; after that, the electronic device dumps the aforementioned multiple files from the memory to the disk, making it easier for subsequent electronic devices to continue processing the initial image, ensuring that users obtain higher quality images.
[0004] However, the above dumping method takes a long time, occupies memory for a long time, and consumes a large amount of memory resources. Summary of the Invention
[0005] The present application provides a data dump method and electronic device, which can minimize the time memory is occupied and improve the efficiency of dumping.
[0006] In a first aspect, the present application provides a data dump method, which is applied to an electronic device. The electronic device includes a first application, a storage module, an input / output module, a first memory, and a second memory. The storage speed of the first memory is higher than that of the second memory. The data in the first memory is cleared when the electronic device is shut down, while the data in the second memory is not cleared when the electronic device is shut down. The method includes:
[0007] When the first application obtains the first data, it sends the first data to the storage module; the storage module saves the first file and the second file corresponding to the received first data to the first memory, the first file includes the first information of the first data, and the second file includes the second information of the first data; the storage module creates a thread pool, and the thread pool includes a first thread and a second thread; the storage module uses the first thread to send the first address to the input-output module, and at the same time, the storage module uses the second thread to send the second address to the input-output module, the first address is used to indicate the position of the first file in the first memory, and the second address is used to indicate the position of the second file in the first memory; the input-output module reads the first file from the first memory according to the received first address, and the input-output module reads the second file from the first memory according to the received second address; the input-output module sends the first file to the second memory, and the input-output module sends the second file to the second memory.
[0008] In the above method, after obtaining the first data, the first application can send the first data to the storage module of the hardware abstraction layer. The storage module can store the first file and the second file corresponding to the first data in the first memory, and create a thread pool including a first thread and a second thread. The first thread sends the first address of the first file in the first memory to the input / output module of the kernel layer, and simultaneously sends the second address of the second file in the first memory to the input / output module of the kernel layer. Thus, the input / output module can read the first file from the first memory according to the first address and send the first file to the second memory. Moreover, the input / output module can also read the second file from the first memory according to the second address and send the second file to the second memory. Based on this, by having multiple threads in the thread pool simultaneously send multiple addresses corresponding to the multiple files corresponding to the first data, the time for sending the addresses is saved, so that the multiple files corresponding to the first data can be dumped from the first memory to the second memory more efficiently, thereby reducing the storage time of the multiple files corresponding to the first data in the first memory, reducing the storage capacity of the first memory, and reducing the storage pressure of the first memory, while ensuring the dumping efficiency.
[0009] Moreover, since the transmission amount of the first address is smaller than that of the first file, the transmission speed of the first address is smaller than that of the first file, and the transmission amount of the second address is smaller than that of the second file, the transmission speed of the second address is smaller than that of the second file. The storage module sends the first address and the second address to the input and output module instead of the first file and the second file. This method further improves the dump efficiency.
[0010] In conjunction with the first aspect, in certain implementations of the first aspect, the electronic device further includes a splitting module, and the storage module uses the first thread to send the first address to the input / output module, including:
[0011] The storage module uses a first thread to send a first address to the splitting module; when receiving the first address, the splitting module splits the first file in the first memory to obtain N first sub-files, and sends a first creation request to the input-output module, the first creation request is used to instruct the input-output module to create a first circular queue; when receiving the first creation request, the input-output module creates a first circular queue, the first circular queue includes N first sub-areas, the N first sub-areas are used to simultaneously manage N first sub-addresses, and the N first sub-addresses are respectively the addresses of the N first sub-files in the first memory; the splitting module fills the N first sub-addresses into the N first sub-areas; the input-output module reads the first file from the first memory according to the received first address, including: the input-output module simultaneously reads the N first sub-files corresponding to the N first sub-addresses from the first memory; the input-output module sends the first file to the second memory, including: the input-output module simultaneously sends the N first sub-files to the second memory.
[0012] In the above method, the splitting module can split the first file to obtain N first sub-files, the input-output module can create a first circular queue including N first sub-areas, and the splitting module can fill the N first sub-addresses corresponding to the N first files obtained by splitting into the first circular queue, so that the first circular queue can manage N first sub-addresses at the same time each time, ensuring that the input-output module can read the N first sub-files corresponding to the N first sub-addresses from the first memory at the same time, realizing fast reading of the N first sub-files, and making data preparations for further improving the efficiency of dumping the N first files in the first memory into the second memory.
[0013] In addition, the input and output module can send N first sub-files to the second memory at the same time. In this way, the efficiency of dumping N first sub-files to the second memory can be improved, the time of dumping N first files to the second memory can be saved, and the storage time of N first files in the first memory can be shortened, thereby reducing the memory resource usage of the first memory and reducing the storage pressure of the first memory.
[0014] In conjunction with the first aspect, in certain implementations of the first aspect, splitting the first file in the first memory to obtain N first sub-files includes:
[0015] The splitting module reads the number of third threads from the input-output module, where the third thread is a thread that is not currently executing a task among all threads of the input-output module; the splitting module splits the first file according to the number N of third threads to obtain N first sub-files; the input-output module simultaneously reads N first sub-files corresponding to N first sub-addresses from the first memory, including: the input-output module uses N third threads to simultaneously read N first sub-files corresponding to N first sub-addresses from the first memory.
[0016] In the above method, the splitting module can determine the number of splits of the first file according to the number of third threads, so as to facilitate subsequent splitting of the first file and subsequent dumping of the first file according to the third threads.
[0017] In combination with the first aspect, in certain implementations of the first aspect, the splitting module splits the first file according to the number N of third threads to obtain N first sub-files, including:
[0018] The splitting module determines a first occupancy, where the first occupancy is the capacity of the storage space of the first memory occupied by the first file; when the first occupancy is less than or equal to a preset threshold, the splitting module splits the first file according to the number N of third threads to obtain N first sub-files.
[0019] In the above method, when the first occupancy is relatively small, the first file can be split according to the number N of third threads to obtain N first sub-files. As a result, the N first sub-files can be filled into the first circular queue at one time, the N first sub-files can be read from the first memory at one time, and the N first sub-files can be dumped into the second memory. In this way, the filling speed can be improved, and the speed of subsequently dumping the first file from the first memory to the second memory can be further improved.
[0020] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes:
[0021] When the first occupancy is greater than a preset threshold, the splitting module splits the first file according to a quantity M to obtain M first sub-files, where M is a positive integer greater than N; the splitting module fills the N first sub-addresses into the N first sub-areas in sequence through H filling operations, where H is a positive integer greater than or equal to 2; the input-output module simultaneously reads the N first sub-files corresponding to the N first sub-addresses from the first memory, including: the input-output module uses N third threads to read the M first sub-files corresponding to the M first sub-addresses from the first memory in sequence through H reading operations; the input-output module simultaneously sends the N first sub-files to the second memory, including: the input-output module uses N third threads to send the M first sub-files to the second memory in sequence through H sending operations.
[0022] In the above method, when the first occupancy is relatively large, the first file can be split according to the quantity M to obtain M first sub-files, where M is a positive integer greater than N, so as to facilitate splitting the first file into more copies. In the subsequent filling process, it is filled into the first circular queue 2 or more times, and then the first file can be read from the first memory a corresponding number of times and dumped into the second memory. In this way, the filling speed can be improved, and the subsequent dumping speed of the first file from the first memory to the second memory can be further improved.
[0023] In conjunction with the first aspect, in certain implementations of the first aspect, the second file includes Q second sub-files, the electronic device further includes a task appending module, and the storage module uses the second thread to send the second address to the input / output module, including:
[0024] The storage module uses a second thread to send Q second sub-addresses to the task appending module, and the Q second sub-addresses are respectively the addresses of the Q second sub-files in the first memory; when the task appending module receives the Q second sub-addresses, the task appending module sends a second creation request to the input-output module, and the second creation request is used to instruct the input-output module to create a second circular queue; when the input-output module receives the second creation request, it creates a second circular queue, and the second circular queue includes Q second sub-areas, and the Q second sub-areas are used to simultaneously manage the Q second sub-addresses; the task appending module fills the Q second sub-addresses into the Q second sub-areas; the input-output module reads the second file from the first memory according to the received second address, including: the input-output module simultaneously reads the Q second sub-files corresponding to the Q second sub-addresses from the first memory; the input-output module sends the second file to the second memory, including: the input-output module simultaneously sends the Q second sub-files to the second memory.
[0025] It should be understood that the second file is usually a fragmented file, including Q second sub-files, and therefore, there is no need to split the second file.
[0026] In the above method, the input-output module can create a second circular queue including Q second sub-areas, and the splitting module can fill the Q second sub-addresses corresponding to the Q second sub-files into the second circular queue, so that the second circular queue can manage the Q second sub-addresses at the same time, ensuring that the input-output module can read the Q second sub-files corresponding to the Q second sub-addresses from the first memory at the same time, realizing fast reading of the Q second sub-files, and making data preparations to further improve the efficiency of dumping the Q second sub-files in the first memory into the second memory.
[0027] In conjunction with the first aspect, in certain implementations of the first aspect, upon receiving the Q second sub-addresses, the task appending module sends a second creation request to the input / output module, including:
[0028] When receiving the Q second sub-addresses, the task appending module reads the number of fourth threads from the input-output module, where the fourth thread is a thread that is not currently executing a task among all threads of the input-output module; the task appending module sends a second creation request to the input-output module, where the second creation request includes the number P of fourth threads, and the second circular queue includes P second sub-regions, where the P second sub-regions are used to simultaneously manage the P second sub-addresses; the task appending module fills the Q second sub-addresses into the Q second sub-regions, including: the task appending module fills the Q second sub-addresses into the P second sub-regions; the input-output module simultaneously reads the Q second subfiles corresponding to the Q second subaddresses from the first memory, including: the input-output module uses the P fourth threads to read the Q second subfiles corresponding to the Q second subaddresses from the first memory.
[0029] In the above method, P fourth threads can be used to manage Q second sub-addresses simultaneously. P fourth threads can also be used to read Q second sub-files corresponding to the Q second sub-addresses from the first memory. In this way, the efficiency of dumping the Q second sub-files to the second memory can be improved.
[0030] In combination with the first aspect, in certain implementations of the first aspect, the task appending module fills the Q second sub-addresses into the P second sub-areas, including:
[0031] When the value of Q is equal to the value of P, the task appending module fills the Q second sub-addresses into the P second sub-areas accordingly.
[0032] In the above method, the number P of the fourth threads is the same as the number Q of the second sub-addresses. Then, the task appending module can directly fill the Q second sub-addresses with the P second sub-regions in a one-to-one correspondence.
[0033] In conjunction with the first aspect, in certain implementations of the first aspect, the method further includes:
[0034] When the value of Q is less than the value of P, the task adding module fills the Q second sub-addresses into the Q second sub-areas of the P second sub-areas respectively.
[0035] In the above method, the number Q of the second sub-addresses is less than the number P of the fourth threads, then the task appending module may fill the Q second sub-addresses with the Q second sub-regions in a one-to-one correspondence with the P second sub-regions.
[0036] In conjunction with the first aspect, in certain implementations of the first aspect, the method further includes:
[0037] When the value of Q is greater than the value of P, the task appending module fills the Q second sub-addresses into the P second sub-areas in sequence through R filling operations, where R is a positive integer greater than or equal to 2; the input-output module reads the Q second sub-files from the first memory at the same time according to the Q second sub-addresses, including: the input-output module uses P fourth threads to read the Q second sub-files corresponding to the Q second sub-addresses from the first memory in sequence through R reading operations; the input-output module sends the Q second sub-files to the second memory, including: the input-output module uses P fourth threads to send the Q second sub-files to the second memory in sequence through R sending operations.
[0038] In the above method, the number Q of second sub-addresses is greater than the number P of fourth threads. Then, the task appending module cannot fill the Q second sub-addresses into the P second sub-areas through one filling operation, but can fill the Q second sub-addresses 2 times or more, can read the Q second sub-addresses 2 times or more, and send the Q second sub-files to the second memory 2 times or more.
[0039] In conjunction with the first aspect, in certain implementations of the first aspect, the first application is a camera application, the first data includes a first image, and when the first application collects the first data, sending the first data to the storage module includes:
[0040] When the first application collects the first image, it sends the first image to the storage module. The first information includes pixel information of the first image, and the second information includes attribute information of the first image.
[0041] Pixel information may include image resolution, color space, color depth, etc. Attribute information may include shooting equipment, shooting time, geographic location, exposure parameters, camera model, etc.
[0042] In conjunction with the first aspect, in certain implementations of the first aspect, when the first application captures the first image, before sending the first image to the storage module, the method further includes:
[0043] A first interface is displayed, where the first interface is an interface of a first application in the electronic device; and a first image is acquired in response to a first operation on the first interface, where the first operation is a shooting operation.
[0044] In the above method, the first interface is the home page interface of the camera application, and the first operation is an operation on the shooting control in the home page interface.
[0045] In a second aspect, the present application provides an electronic device, which includes: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method in the first aspect and any possible implementation of the first aspect.
[0046] In a third aspect, the present application provides a chip system, which is applied to an electronic device. The chip system includes one or more processors, and the one or more processors are used to call computer instructions to enable the electronic device to execute the method in the first aspect and any possible implementation of the first aspect.
[0047] In a fourth aspect, the present application provides a computer-readable storage medium, which includes instructions. When the instructions are executed on an electronic device, the electronic device executes the method in the first aspect and any possible implementation of the first aspect.
[0048] In a fifth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method in the first aspect and any possible implementation manner of the first aspect.
[0049] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A flow chart of a data dump method provided by the prior art;
[0051] Figure 2 A schematic structural diagram of an electronic device provided in one embodiment of the present application;
[0052] Figure 3 A schematic diagram of a software architecture of an electronic device provided in one embodiment of the present application;
[0053] Figure 4 A flowchart of a data dump method provided in one embodiment of the present application;
[0054] Figure 5 A schematic diagram of creating a thread pool provided in one embodiment of the present application;
[0055] Figure 6 A flowchart of a data dump method provided in one embodiment of the present application;
[0056] Figure 7 A flowchart of a data dump method provided in one embodiment of the present application;
[0057] Figure 8 A flowchart of a data dump method provided in one embodiment of the present application. DETAILED DESCRIPTION
[0058] In this application, "at least one" refers to one or more, and "plurality" 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: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a alone, b alone, or c alone can represent: a alone, b alone, c alone, a and b in combination, a and c in combination, b and c in combination, or a, b, and c in combination, where a, b, and c can be single or multiple. In addition, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance.
[0059] To facilitate understanding, some of the examples given are provided for reference to the description of concepts related to the embodiments of the present application.
[0060] 1. IO_Uring.
[0061] Input output-uring (IO_Uring) is a high-performance asynchronous I / O framework in the Linux kernel. IO_Uring provides a novel I / O model that enables zero-copy data transfer between target modules and the kernel in electronic devices, achieving higher concurrency and lower latency.
[0062] IO_Uring allows the target module to bundle a large number of I / O operations into a request queue and submit them to the kernel all at once, avoiding frequent context switches. The kernel executes these operations in the order listed in the request queue and notifies the target module upon completion. This approach improves system throughput and concurrency.
[0063] IO_Uring can significantly accelerate the performance of I / O-intensive applications. IO_Uring has the following features:
[0064] a. True asynchronous I / O, achieving distributed storage and high storage performance.
[0065] b. Excellent activity and scalability. New system calls and user-space application programming interfaces (APIs) are provided for application modification. Targeted configuration is possible for data with different characteristics.
[0066] 2. IO_Uring circular queue.
[0067] The IO_Uring ring queue is a circular buffer used to store asynchronous I / O operation requests. It contains multiple request items, each corresponding to an asynchronous I / O operation. Each request item includes an opcode, a file descriptor, and other related parameters.
[0068] The design concept of the IO_Uring circular queue is inspired by the producer-consumer model. Target modules submit asynchronous I / O requests to the kernel through the IO_Uring circular queue. The kernel then processes these requests and writes the results to the queue for the user program to read.
[0069] The advantages of the IO_Uring ring queue lie in its efficient batch processing capabilities and zero-copy mechanism. The target module can submit multiple asynchronous I / O requests to the kernel at once, and the kernel can process these requests in a single system call, reducing system call overhead. Furthermore, the kernel can directly transfer data between the user buffer and the electronic device without requiring additional data copies, improving data transfer efficiency.
[0070] In general, the IO_Uring ring queue is an important concept in the IO_Uring framework, used to store and process asynchronous I / O operation requests. It has efficient batch processing capabilities and a zero-copy mechanism, which can improve the performance of asynchronous I / O operations.
[0071] 3. Thread pool.
[0072] A thread pool is a concurrent programming technique used to manage and reuse threads, improving program performance and resource utilization. A thread pool can contain multiple threads. Threads can be pre-created and stored in the thread pool, waiting to execute tasks, or they can be created when tasks are needed.
[0073] 4. Threads.
[0074] A thread is an execution unit used at the operating system level. As complex computing devices, electronic devices like mobile phones have many tasks that need to be performed simultaneously, such as drawing the user interface, processing network requests, and executing background tasks. To complete these tasks efficiently, the operating system can assign these tasks to different threads.
[0075] A thread is the smallest execution unit assigned by the operating system and an independent execution flow within a process, capable of independently executing tasks. Each thread has its own program counter, stack, registers, and resources, and threads share the process's address space and other resources.
[0076] By using multithreading technology, mobile phones and other electronic devices can perform multiple tasks simultaneously, improving system responsiveness and efficiency. Different tasks can be executed in parallel in different threads to avoid blocking the main thread and maintain the smoothness of the user interface.
[0077] Electronic devices such as mobile phones and tablet computers are usually equipped with cameras and have camera applications installed. The electronic devices can obtain images captured by the cameras based on the camera applications.
[0078] Currently, due to the fast reading and writing speed of memory, after the camera application obtains the initial image through the camera, it can store the frame files, metadata files, database files and other files corresponding to the initial image in the memory; after that, the electronic device dumps the aforementioned multiple files from the memory to the disk, making it easier for subsequent electronic devices to continue processing the initial image, ensuring that users obtain higher quality images.
[0079] like Figure 1 As shown, when saving, the electronic device can queue the frame file, metadata file, and database file and save them in the memory; when dumping, the electronic device can dequeue the database file and dump the database file to the disk through the library function, and then dump the metadata file to the disk through the library function, and then dump the frame file to the disk through the library function.
[0080] However, the above serial dump method takes a long time, occupies memory for a long time, and consumes a large amount of memory resources.
[0081] In response to the above problems, the present application can provide a data dump method, electronic device, chip system, computer-readable storage medium and computer program product. After the camera application stores multiple files corresponding to the captured image in the memory, the electronic device can create a thread pool including multiple threads, and simultaneously send the memory addresses corresponding to the aforementioned multiple files to the kernel layer through the multiple threads of the thread pool. After receiving the memory addresses corresponding to the multiple files, the kernel layer can read the aforementioned multiple files from the memory and send them to the disk. In this way, the storage time of the multiple files corresponding to the image in the memory can be reduced, the storage amount of the memory can be reduced, the storage pressure of the memory can be reduced, and the dump efficiency can be guaranteed at the same time.
[0082] The electronic device mentioned above may be an electronic device having a display screen and camera hardware as well as corresponding software support.
[0083] For example, the electronic device may be a mobile phone, tablet computer, vehicle-mounted device, laptop computer, wearable device, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), smart car, smart TV, robot, etc.
[0084] It should be noted that in some possible implementations, the electronic device may also be called a terminal device, a user equipment (UE), etc., and the embodiments of the present application do not limit this.
[0085] For ease of explanation, Figure 2 In the figure, the electronic device 100 is taken as a mobile phone as an example for illustration.
[0086] like Figure 2 As shown, the electronic device 100 may include a processor 101, a communication module 102, a display screen 103, a camera 104, a sensor 105, an internal memory 106, a USB interface 107, an external memory interface 108, a charging management module 109, a power management module 110, and a battery 111, etc.
[0087] The processor 101 may include one or more processing units. For example, the processor 101 may include an application processor (AP), a modem processor, a graphics processor, an image signal processor (ISP), a controller, a memory, a video stream codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors 101.
[0088] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0089] The processor 101 may also include a memory for storing instructions and data.
[0090] In some embodiments, the memory in processor 101 is a high-speed cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 101. If processor 101 needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces processor 101's waiting time, and thus improves system efficiency.
[0091] In some embodiments, the processor 101 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.
[0092] The communication module 102 may include antenna 1 and antenna 2 , a mobile communication module, and / or a wireless communication module.
[0093] The display screen 103 is used to display images or videos in the human-computer interaction interface. The display screen 103 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 103, where N is a positive integer greater than one.
[0094] The camera 104 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 104, where N is a positive integer greater than 1.
[0095] In some other embodiments, the power management module 110 may also be disposed in the processor 101 .
[0096] In other embodiments, the power management module 110 and the charging management module 109 may also be provided in the same device.
[0097] The external memory interface 108 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 101 via the external memory interface 108 to implement data storage functions. For example, files such as music and video streams can be stored on the external memory card.
[0098] The internal memory 106 can be used to store computer executable program codes, which include instructions. The processor 101 executes the instructions stored in the internal memory 106 to execute various functional applications and data processing of the electronic device 100. The internal memory 106 can include a program storage area and a data storage area.
[0099] The program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 106 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0100] Optionally, the electronic device 100 may further include peripheral devices, such as a mouse, buttons, indicator lights, a keyboard, a speaker, a microphone, etc.
[0101] The buttons include a power button, a volume button, etc. The buttons can be mechanical buttons or touch buttons. The electronic device 100 can receive button inputs and generate key signal inputs related to user settings and function control of the electronic device 100.
[0102] The indicator may be a light indicator, which may be used to indicate the charging status and power level change, and may also be used to indicate messages, missed calls, and notifications, etc.
[0103] It should be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100 .
[0104] In other embodiments, the electronic device 100 may include more or fewer components than shown, or combine some components, separate some components, or arrange the components differently. The components shown may be implemented in hardware, software, or a combination of software and hardware.
[0105] Please refer to Figure 3 , is a schematic diagram of the software architecture of an electronic device provided in an embodiment of the present application. The data storage method provided in an embodiment of the present application is applied to Figure 2 When the electronic device 100 is shown, the software in the electronic device 100 can be divided into the following categories: Figure 3 The illustrated layer includes an application layer 201 , a hardware abstraction layer (HAL) 202 , a kernel layer 203 , and a hardware layer 204 .
[0106] A plurality of applications may be installed in the application layer 201 , which may include a camera application for implementing a shooting function.
[0107] The camera application refers to a computer program that runs on an operating system and can perform a photo-taking task. When the camera application is in an Android application package (APK) format, the camera application can run on the Android operating system.
[0108] In the embodiment of the present application, the camera application can be an application with a shooting function. For example, an application with the function of sharing short videos can be used as the camera application in the embodiment of the present application if it has a shooting function.
[0109] The hardware abstraction layer 202 is software located between the operating system kernel and the hardware circuits. It is generally used to abstract the hardware to enable interaction between the operating system and the hardware circuits at the logical layer. In the embodiment of the present application, the hardware abstraction layer 202 may include a camera hardware abstraction layer (camera HAL) that enables interaction between the camera application and the image sensor at the logical layer.
[0110] The hardware abstraction layer 202 may include a storage module, a splitting module, and a task appending module. The storage module is connected to the camera application of the application layer 201. The splitting module is connected to the storage module. The task appending module is connected to the storage module.
[0111] The storage module is used to store multiple files corresponding to the images acquired by the camera application in the memory of the electronic device.
[0112] The splitting module is used to split the frame file corresponding to the image and fill the multiple sub-frame files after the split into the circular queue corresponding to the frame file.
[0113] The task appending module is used to fill multiple sub-metadata files corresponding to the metadata file into the circular queue corresponding to the metadata file.
[0114] The kernel layer 203 includes the kernel and the functional safety partition. The processes of ordinary applications run in the kernel, and the processes of functional safety applications run in the functional safety partition. In order to ensure that the functional safety partition is compatible with the kernel ecosystem, interaction can be carried out between the functional safety partition and the kernel, and the kernel can assist in completing some functional safety application operations.
[0115] The kernel layer may include an IO-Uring module (also called an input / output module), which is connected to the splitting module and the task appending module of the hardware abstraction layer 202 respectively.
[0116] The IO-Uring module is used to create a ring queue and send the aforementioned multiple sub-metadata files and multiple sub-metadata files to the disk through the ring queue.
[0117] The hardware layer 204 may include various hardware components and chips in the electronic device. The combination of these hardware layers constitutes the overall hardware system of the electronic device and works together with the software layers (such as the application layer 201, the hardware abstraction layer 202, and the kernel layer 203) to implement various functions and services.
[0118] The hardware layer 204 may include memory and disk.
[0119] Memory is used to temporarily store running applications and data. Disk is used to permanently store data, applications, and the operating system.
[0120] It should be noted that the application layer 201 , the hardware abstraction layer 202 , the kernel layer 203 , and the hardware layer 204 may also include other contents, which are not specifically limited here.
[0121] Based on the above scenario description, the present application takes an electronic device as an example, and combines the accompanying drawings and application scenarios to elaborate on the data dump method provided in the embodiment of the present application.
[0122] See also Figure 4 , Figure 4 A flow chart of a data dump method provided in an embodiment of the present application is shown.
[0123] like Figure 4 As shown, the data dump method provided by this application may include:
[0124] S11 . The camera application acquires a first image in response to a shooting operation.
[0125] Among them, the shooting operation can be achieved in multiple ways.
[0126] In some embodiments, the shooting operation can be a click operation; after receiving an operation by the user to trigger the icon of the camera application (application, APP) (such as a click, double-click or long press operation, etc.), the electronic device can display an interface, which may include a shooting control, and the shooting control is used to trigger the capture of an image. After the camera application detects the click operation on the shooting control, it can start acquiring the first image.
[0127] This application does not limit the display position, display style, display size and other parameters of the shooting control.
[0128] In other embodiments, the shooting operation can be a voice operation; a voice assistant is added to the electronic device, and after receiving a specific wake-up word input by the user's voice, the voice assistant can be woken up, and after receiving an indication of opening the camera application input by the user's voice, the electronic device can display an interface; and after receiving an indication of taking an image input by the user's voice, the camera application can start acquiring the first image.
[0129] For example, the voice assistant may be YOYO. After receiving the user's voice input of "Hello, YOYO", YOYO may be awakened. After receiving the user's voice input of the voice instruction "take an image", the camera application may start to acquire the first image.
[0130] It should be understood that the above description uses the shooting operation as a click operation or a voice operation as an example; the shooting operation can also be an operation of indicating the shooting of an image in other ways, and this application does not impose any limitation on the shooting operation.
[0131] The shooting request is used to instruct the camera driver to call the camera to capture images.
[0132] Specifically, after detecting a click operation on the shooting space, or receiving an instruction to shoot an image input by a user's voice, the camera application may send a shooting request to the camera driver, which may enable the camera driver to call the camera to capture an image.
[0133] After the camera driver receives the shooting request sent by the camera application, the camera driver can call the camera to facilitate the camera to capture images.
[0134] Thus, the camera can capture the first image, and thus can send the first image to the camera driver. After receiving the first image, the camera driver can send the first image to the camera application, so that the camera application obtains the first image.
[0135] S12: The camera application sends the first image to the storage module.
[0136] After obtaining the first image, the camera application may send the first image to the storage module of the hardware abstraction layer, so that the storage module can save the first image.
[0137] S13 . The storage module saves the frame file and metadata file corresponding to the first image into the memory 1 .
[0138] Frame file corresponding to the first image: a frame file is generally a binary data block, including pixel information of the first image, and may also include the manner in which the first image is displayed on the screen.
[0139] The frame file may indicate information such as resolution, color space, and color depth (such as 8 bits, 16 bits, etc.) of the first image. The frame file records the actual content of the first image and can be used to display, modify, and process the image.
[0140] Metadata (meta) file corresponding to the first image: a metadata file is a type of data describing data, and is used to provide additional information about the first image.
[0141] The metadata file may include various attribute information about the first image, such as shooting equipment, shooting time, geographic location, exposure parameters, camera model, etc. The metadata can be used for indexing, organization, and management of the first image, as well as for subsequent analysis and processing.
[0142] The first file may also include a database file corresponding to the first image.
[0143] Database (DB) file corresponding to the first image: The database file is used to store and manage a large amount of information such as indexes, tags, keywords, etc. of the first image.
[0144] The database file is typically used to quickly retrieve and classify the first image, and can be searched and filtered based on the features or attributes of the first image. The database file provides management and retrieval capabilities for the first image and can be used to build an image library or image search engine.
[0145] In some embodiments, the memory 1 may be referred to as a memory, and the memory 1 may be a random-access memory (RAM).
[0146] Among them, the memory 1 has the characteristics of fast reading and writing speed and high volatility.
[0147] It should be understood that due to the fast reading and writing speed of memory 1, after the electronic device obtains the first image through the camera application, it can store the first image in memory 1 to improve storage efficiency and avoid delays or errors in the storage process, loss of part of the image data, etc.
[0148] S14. The storage module creates a thread pool.
[0149] Among them, the execution order of S13 and S14 is not particular, and they can be executed simultaneously or sequentially. When executed sequentially, the storage module can execute S13 first and then S14, or can execute S14 first and then S13.
[0150] The number of threads in the thread pool may be determined according to the number of sub-files included in the first file corresponding to the first image.
[0151] For example, when the first file includes two sub-files and includes a frame file and a metadata file, the number of threads in the thread pool may be two.
[0152] For example, if the first file includes three sub-files, and the first file includes a frame file, a metadata file, and a database file, the number of threads in the thread pool may be three.
[0153] When the first file includes a frame file and a metadata file, the number of threads in the thread pool may be two, namely a first thread and a second thread.
[0154] Based on this, the storage module can process the frame file through the first thread and at the same time, process the metadata file through the second thread, which can avoid processing the frame file first and then the metadata file or processing the metadata file first and then the frame data file in a serial manner, resulting in a longer occupation time of memory 1 and a higher memory resource usage.
[0155] like Figure 5 As shown, when saving, the storage module can queue the sub-files included in the first file corresponding to the first image and save them in the memory 1; when dumping, the sub-files included in the first file can be dequeued to the created thread pool at the same time, and the sub-files included in the first file can be processed simultaneously by multiple threads in the thread pool.
[0156] The dumping process of the frame file can refer to the description of S151-S171 below, and the dumping process of the metadata file can refer to the description of S152-S172 below.
[0157] S151. The storage module sends the first address of the frame file in the memory 1 to the IO-Uring module through the first thread.
[0158] The first address is used to indicate the location of the frame file in the memory 1 , and the first address can be represented by characters, letters, and / or numbers.
[0159] It should be understood that the first address is a small data, while the frame file is a large data compared to the first address. Sending the first address only requires transmitting a few bytes of data, while sending the frame file requires transmitting a large amount of data. Based on this, the storage module sends a dump request 1 to the IO-Uring module. The dump request 1 carries the first address of the frame file in the memory 1, instead of directly sending the frame file. This can improve the transmission efficiency of the frame file and further improve the dump efficiency.
[0160] Among them, the storage module sends the first address of the frame file in the memory 1 to the IO-Uring module through the first thread, which can facilitate the IO-Uring module to subsequently read the frame file corresponding to the first image according to the first address.
[0161] S161. The IO-Uring module reads a frame file corresponding to the first image from the memory 1 according to the first address.
[0162] Based on S151, the IO-Uring module can obtain the first address of the frame file in the memory 1, so that the IO-Uring module can read the frame file from the memory 1 according to the first address.
[0163] S171. The IO-Uring module sends the frame file to the memory 2.
[0164] Among them, the memory 2 has the characteristics of slow reading and writing speed and non-volatile.
[0165] Since the reading and writing speed of memory 2 is slow, if the frame file corresponding to the first image is directly stored in memory 2, it may cause delays or errors in the storage process and lose some image data. Therefore, the frame file corresponding to the first image can be stored in memory 1 first and then dumped from memory 1 to memory 2.
[0166] In some embodiments, the memory 2 is a magnetic disk.
[0167] In some embodiments, the memory 2 is a universal flash storage (UFS).
[0168] In some other embodiments, the memory 2 is an embedded multi media card (EMMC).
[0169] After reading the frame file from memory 1, the IO-Uring module can send the frame file to memory 2. In this way, memory 2 can save the frame file in memory 2 after receiving the frame file, thereby realizing the dumping of the frame file from memory 1 to memory 2.
[0170] S152: The storage module sends the second address of the metadata file in the memory 1 to the IO-Uring module through the second thread.
[0171] The second address is used to indicate the location of the metadata file in the memory 1 , and the second address can be represented by characters, letters, and / or numbers.
[0172] It should be understood that the second address is a small data, while the metadata file is a large data compared to the second address. Sending the second address only requires transmitting a few bytes of data, while sending the metadata file requires transmitting a large amount of data. Based on this, the storage module sends a dump request 2 to the I / O-Uring module. The dump request 2 carries the second address of the metadata file in the memory 1, instead of directly sending the metadata file. This can improve the transmission efficiency of the metadata file and further improve the dump efficiency.
[0173] Among them, the storage module sends the second address of the metadata file in memory 1 to the IO-Uring module through the second thread, which can facilitate the IO-Uring module to subsequently read the metadata file corresponding to the first image according to the second address and dump it to memory 2.
[0174] Among them, S152 and S151 are executed simultaneously.
[0175] S162. The IO-Uring module reads the metadata file corresponding to the first image from the memory 1 according to the second address.
[0176] Based on S152, the IO-Uring module can obtain the second address of the metadata file in the memory 1, so that the IO-Uring module can read the metadata file from the memory 1 according to the second address.
[0177] S172. The IO-Uring module sends the metadata file to the storage 2.
[0178] Since the reading and writing speed of memory 2 is slow, if the metadata file corresponding to the first image is directly stored in memory 2, it may cause delays or errors in the storage process and lose some image data. Therefore, the metadata file corresponding to the first image can be first stored in memory 1 and then dumped from memory 1 to memory 2.
[0179] After reading the metadata file from memory 1, the IO-Uring module can send the metadata file to memory 2. In this way, memory 2 can save the metadata file in memory 2 after receiving the metadata file, thereby realizing the dumping of the metadata file from memory 1 to memory 2.
[0180] It should be noted that the first file may also include a database file, and the thread pool may also include a third thread. While the electronic device processes the frame file through the first thread and the metadata file through the second thread, it can also process the database file through the third thread, and in accordance with the subsequent dumping method of the frame file or the metadata file, the database file can also be dumped from memory 1 to memory 2.
[0181] According to the data dumping method of the present application, after obtaining the first image, the camera application can send the first image to the storage module of the hardware abstraction layer. The storage module can store the first file corresponding to the first image in the memory 1, and create a thread pool including a first thread and a second thread. The first thread sends the first address of the frame file in the memory 1 to the IO-Uring module of the kernel layer, so that the IO-Uring module can read the frame file from the memory 1 according to the first address and send the frame file to the memory 2; at the same time, the second thread sends the second address of the metadata file in the memory 1 to the IO-Uring module of the kernel layer, so that the IO-Uring module can read the metadata file from the memory 1 according to the second address and send the metadata file to the memory 2; based on this, by simultaneously processing multiple files corresponding to the first image in the electronic device, the multiple files corresponding to the first image can be dumped from the memory 1 to the memory 2 more efficiently, thereby reducing the storage time of the multiple files corresponding to the first image in the memory 1, reducing the storage capacity of the memory 1, reducing the storage pressure of the memory 1, and ensuring the dumping efficiency.
[0182] Moreover, since the transmission amount of the first address is smaller than that of the frame file, the transmission speed of the first address is smaller than that of the frame file, and the transmission amount of the second address is smaller than that of the metadata file, the transmission speed of the second address is smaller than that of the metadata file. The storage module sends the first address and the second address to the IO-Uring module instead of the frame file and the metadata file. This method further improves the dump efficiency.
[0183] Based on the above Figure 4 As described in S151-S171, the hardware abstraction layer also includes a splitting module, which can split the frame file. The IO-Uring module can create a circular queue, so that the splitting module can fill the circular queue with multiple addresses corresponding to the multiple sub-frame files obtained by splitting the frame file. The IO-Uring module can read multiple sub-frame files from the memory 1 through the multiple addresses in the circular queue, and dump the multiple sub-frame files to the memory 2 at the same time through the multiple threads corresponding to the circular queue.
[0184] Next, combine Figure 6 , which introduces in detail the specific implementation process of the data dump method of this application.
[0185] See also Figure 6 , Figure 6 A flow chart of a data dump method provided in an embodiment of the present application is shown.
[0186] like Figure 6 As shown, the data dump method provided by this application may include:
[0187] S21. The storage module sends the first address of the frame file in the memory 1 to the splitting module through the first thread.
[0188] Among them, S21 and Figure 4 The implementation of S151 in the illustrated embodiment is similar and will not be repeated here.
[0189] S22. The splitting module reads the number N corresponding to the third thread from the IO_Uring module.
[0190] The third thread is a thread that is not currently executing a task among all threads in the kernel layer.
[0191] It should be understood that there are usually several threads in the kernel layer. After the electronic device is turned on for the first time, the electronic device starts running, and some of the threads in the kernel layer start executing tasks (such as sending instructions to the camera in the hardware layer of the electronic device).
[0192] Based on this, it can be seen that at any moment during the operation of the electronic device, some threads in the kernel layer are executing tasks, while other threads are not executing tasks.
[0193] For example, when the electronic device is powered on for the first time, the number of all threads is 100, the number of threads that are not currently executing tasks among all threads is 8, that is, the number of third threads is 8, and the value of N is 8.
[0194] For another example, when the electronic device is powered on for the first time, the total number of threads is 100, and the number of threads that are not currently executing tasks among all threads is 16, that is, the number of third threads is 16, and the value of N is 16.
[0195] It should be noted that the number of threads in the kernel layer is relatively large. Generally, the number of threads that are not currently executing tasks is also relatively large.
[0196] S23. Determine the quantity M based on the quantity N of the split module.
[0197] S24. The splitting module splits the frame file corresponding to the first address according to the quantity M to obtain M sub-frame files.
[0198] The value of M is the number of copies that the frame file needs to be split into.
[0199] It should be understood that the dump request 1 can also carry the first occupancy of the frame file. The first occupancy is the amount of storage space occupied by the frame file in the memory 1. The first occupancy of the frame file may be large or small. When the first occupancy is large, if it is determined that the value of M is equal to the value of N, then the amount of storage space occupied by each sub-frame file in the memory 1 is large. Each time the frame sub-file is read in the subsequent S29 and the sub-frame file is sent to the memory 2 in S30, it takes a long time, which is not conducive to improving the dump efficiency and reducing the storage pressure of the memory 1.
[0200] Therefore, when the first occupancy is small, the splitting module can determine that the value of M is the value of N; when the first occupancy is large, the value of M can be determined to be a value greater than N (in this case, the value of M is usually a multiple of N).
[0201] If the splitting module determines that the value of M is greater than the value of N, then in the subsequent filling process in S27, the splitting module may fill the N first sub-addresses into the circular queue in two or more times.
[0202] Specifically, the split module can perform the following steps to determine the value of M:
[0203] Determine whether the first occupancy is greater than a preset threshold; when the first occupancy is less than or equal to the preset threshold, determine that the value of M is equal to the value of N; when the first occupancy is greater than the preset threshold, determine that the value of M is a value greater than M.
[0204] Based on the above description, when the first occupancy is relatively small, the value of M can be determined to be the value of N. Thus, the sub-frame file can be filled into the circular queue at one time, the sub-frame file can be read from memory 1 at one time, and the sub-frame file can be dumped into memory 2. In this way, the filling speed can be increased, and the subsequent speed of dumping the sub-frame file from memory 1 to memory 2 can be further increased.
[0205] When the first occupancy is relatively large, it can be determined that the value of M is greater than the value of N, so that the frame file can be split into more parts. In the subsequent filling process, it is filled into the circular queue 1 2 or more times, and then the sub-frame file can be read from the memory 1 a corresponding number of times and dumped into the memory 2. In this way, the filling speed can be improved, and the subsequent speed of dumping the sub-frame file from the memory 1 to the memory 2 can be further improved.
[0206] For example, when the value of N is 8, the first occupied size of the frame file is 8MB, and the preset threshold is 16MB, then the splitting module can set the value of M to 8, ie, split the frame file into 8 parts, each part is 1MB.
[0207] For another example, the value of N is 8, the first occupied space of the frame file is 16 MB, and the splitting module can set the value of M to 16, that is, split the frame file into 16 parts, each part is 1 MB.
[0208] S25. The splitting module sends a creation request 1 to the IO_Uring module.
[0209] The creation request 1 carries the value of N, and the creation request 1 is used to request the IO_Uring module to create a ring queue 1.
[0210] When the splitting module sends a creation request 1 to IO_Uring, it can carry the value of N, so that the IO_Uring module can subsequently create a ring queue 1 with a corresponding number of sub-areas.
[0211] Among them, the execution order of S23 and S25 is not particular, and they can be executed simultaneously or sequentially. When executed sequentially, the split module can execute S23 first and then S25, or it can execute S25 first and then S23.
[0212] S26. The IO_Uring module creates a ring queue 1 according to the value of N.
[0213] The circular queue 1 is used to indicate a queue buffer based on IO_Uring. The circular queue 1 includes N first sub-areas, and the N first sub-areas are used to manage N files simultaneously.
[0214] It should be understood that the circular queue 1 is used to implement simultaneous management of multiple tasks. By creating a circular queue 1 including N first sub-areas, N third threads can simultaneously read data in N first sub-areas (hereinafter referred to as N first sub-addresses).
[0215] S27 . The splitting module fills the M first sub-addresses into the N first sub-areas.
[0216] It should be understood that, among the M sub-frame files obtained by splitting the frame file by the splitting module, each sub-frame file has an address in the memory 1 , and thus, the M sub-frame files correspond to M first sub-addresses.
[0217] After the splitting module creates the circular queue 1 , the splitting module may fill the M first sub-addresses into the N first sub-areas.
[0218] In some embodiments, the value of M is equal to the value of N, and the splitting module can fill the M first sub-addresses into the N first sub-areas at one time.
[0219] For example, if the value of N is 8 and the value of M is 8, then the splitting module splits the frame file into 8 parts to obtain 8 frame files, corresponding to 8 first sub-addresses. The splitting module can fill the 8 first sub-addresses into the 8 first sub-areas at one time.
[0220] In some other embodiments, the value of M is greater than the value of N, and the splitting module may fill the M first sub-addresses into the N first sub-areas twice or more times.
[0221] For example, if the value of N is 8 and the value of M is 16, then the splitting module splits the frame file into 16 parts to obtain 16 frame files corresponding to 16 first sub-addresses. The splitting module can fill the 16 first sub-addresses into the 8 first sub-areas in 2 times.
[0222] Each time the splitting module fills the first sub-address, it can fill it simultaneously or in sequence.
[0223] If filling is performed at the same time, the filling time can be saved, and the time for the subsequent IO_Uring to dump the frame data from memory 1 to memory 2 can be further saved.
[0224] If filling is performed sequentially, the splitting module may sequentially fill the first sub-address into the first sub-area according to the order in which the M sub-frame files are stored in the memory 1 .
[0225] For example, the value of N is 8, the value of M is 8, and the circular queue 1 includes 8 first sub-areas, namely sub-area 1, sub-area 2, sub-area 3, sub-area 4, sub-area 5, sub-area 6, sub-area 7, and sub-area 8; the number of first sub-addresses is 8, namely sub-address 1, sub-address 2, sub-address 3, sub-address 4, sub-address 5, sub-address 6, sub-address 7, and sub-address 8.
[0226] Based on this, the splitting module can fill subaddress 1 in sub-area 1, subaddress 2 in sub-area 2, subaddress 3 in sub-area 3, subaddress 4 in sub-area 4, subaddress 5 in sub-area 5, subaddress 6 in sub-area 6, subaddress 7 in sub-area 7, and subaddress 8 in sub-area 8.
[0227] S28. The splitting module sends a dump request 1 to the IO_Uring module.
[0228] The dump request 1 is used to instruct the IO_Uring module to dump M sub-frame files from the memory 1 to the memory 2 .
[0229] In some embodiments, the value of N is equal to the value of M, and the splitting module can fill the M first sub-addresses into the N first sub-areas at one time. Then, after the splitting module fills the M first sub-addresses into the N first sub-areas at one time, it can send a dump request 1 to the IO_Uring module.
[0230] For example, the value of N is 8 and the value of M is 8. Then, the split module may send a dump request 1 to the IO_Uring module after filling the 8 first sub-addresses into the 8 first sub-areas.
[0231] In other embodiments, the value of M is greater than the value of N, and the splitting module can fill the M first sub-addresses into the N first sub-areas twice or more times. Then, the splitting module can send a dump request 1 to the IO_Uring module each time after filling the first sub-address into the first sub-area.
[0232] For example, the value of N is 8 and the value of M is 16. Then, the splitting module can fill the 16 first sub-addresses into the 8 first sub-areas in 2 times. After the splitting module fills the 8 first sub-addresses into the 8 first sub-areas for the first time, it can send a dump request 1 to the IO_Uring module. After filling the remaining 8 first sub-addresses into the 8 first sub-areas for the second time, it can also send a dump request 1 to the IO_Uring module.
[0233] S29. The IO_Uring module reads M subframe files from the memory 1 according to the M first subaddresses.
[0234] Based on the description of S28, IO_Uring may receive the dump request 1 only once, or may receive the dump request 1 two or more times.
[0235] In some embodiments, the value of M is equal to the value of N. After the splitting module fills M first sub-addresses into N first sub-areas at one time, it sends a dump request 1 to the IO_Uring module. Then, the IO_Uring module can use N third threads to read M sub-frame files from the memory 1 at the same time according to the M first sub-addresses at one time.
[0236] For example, the value of N is 8 and the value of M is 8. The splitting module can send a dump request 1 to the IO_Uring module after filling the 8 first sub-addresses into the 8 first sub-areas. Then, after receiving the dump request 1, the IO_Uring module can use 8 third threads to read 8 sub-frame files from the memory 1 at the same time according to the 8 first sub-addresses.
[0237] In other embodiments, the value of M is greater than the value of N. The splitting module can send a dump request 1 to the IO_Uring module after filling the M first sub-addresses into the N first sub-areas twice or more times. Then, the IO_Uring module can read the subframe file from the memory 1 twice or more times through N third threads.
[0238] For example, the value of N is 8 and the value of M is 16. The splitting module can send two dump requests 1 to the IO_Uring module. Then, after receiving the dump request 1 for the first time, the IO_Uring module can read 8 sub-frame files from the memory 1 according to the 8 first sub-addresses; after receiving the dump request 1 for the second time, the IO_Uring module can use 8 third threads to simultaneously read the remaining 8 sub-frame files from the memory 1 according to the remaining 8 first sub-addresses.
[0239] S30 , the IO_Uring module sends M subframe files to the memory 2 through N third threads.
[0240] Based on S22 , it can be known that the threads currently not executing tasks in all threads include N third threads. Therefore, the IO_Uring module can send the subframe file to the memory 2 of the hardware layer simultaneously through the N third threads each time.
[0241] In some embodiments, the value of M is equal to the value of N, and the IO_Uring module can read M subframe files from the memory 1 according to the M first subaddresses at one time. Thus, the IO_Uring module can send M subframe files to the memory 2 at the same time through N third threads at one time.
[0242] For example, the value of N is 8, the value of M is 8, the splitting module can send 1 dump request 1 to the IO_Uring module, then the IO_Uring module can read 8 sub-frame files from the memory 1 according to the 8 first sub-addresses at one time, and send the 8 sub-frame files to the memory 2 at the same time through 8 third threads.
[0243] In other embodiments, the value of M is greater than the value of N, and the splitting module may read the sub-frame file from the memory 1 twice or more times and then send the sub-frame file to the memory 2 simultaneously through N third threads.
[0244] For example, the value of N is 8 and the value of M is 16. After the splitting module receives the dump request 1 for the first time, the IO_Uring module can read 8 sub-frame files from the memory 1 according to the 8 first sub-addresses, and send the 8 sub-frame files to the memory 2 through 8 third threads; after receiving the dump request 1 for the second time, the IO_Uring module can read the remaining 8 sub-frame files from the memory 1 according to the remaining 8 first sub-addresses, and send the 8 sub-frame files to the memory 2 through 8 third threads.
[0245] Based on the above description, the IO_Uring module sends subframe files to the memory 2 of the hardware layer simultaneously through N third threads each time, which can improve the efficiency of dumping M subframe files to the memory 2, save the time of dumping M subframe files to the memory 2, and shorten the storage time of the M subframe files in the memory 1.
[0246] In the present application, the splitting module can determine the value of M through the value of N, and split the frame file according to the value of M to obtain M frame files. The IO_Uring module can create a circular queue 1 including N first sub-areas. The splitting module can fill the M first sub-addresses corresponding to the M frame files obtained by splitting into the circular queue 1, so that the circular queue 1 can manage N first sub-addresses at the same time, ensuring that the IO_Uring module can read N sub-frame files or less than N sub-frame files at the same time through N third threads, thereby realizing fast reading of sub-frame files, and making data preparations to further improve the efficiency of dumping the M sub-frame files in the memory 1 to the memory 2.
[0247] Moreover, the IO_Uring module can simultaneously send N sub-frame files or less than N sub-frame files to the memory 2 of the hardware layer through N third threads. In this way, the efficiency of dumping N sub-frame files to the memory 2 can be improved, the time for dumping N sub-frame files to the memory 2 can be saved, and the storage time of the N sub-frame files in the memory 1 can be shortened, thereby reducing the memory resource usage of the memory 1 and reducing the storage pressure of the memory 1.
[0248] Based on the above Figure 4 As described in S152-S172, since the metadata file is stored in the memory 1 in the form of fragments, that is, the metadata file includes multiple sub-metadata files, the hardware abstraction layer also includes a task appending module, and the task appending module can also create a circular queue, so that the splitting module can fill the addresses corresponding to the multiple sub-metadata files into the circular queue, and the I / O-Uring module can read the multiple sub-metadata files through the multiple addresses in the circular queue, and dump the multiple sub-metadata files to the memory 2 at the same time through the multiple threads corresponding to the circular queue.
[0249] Next, combine Figure 7 , which introduces in detail the specific implementation process of the data dump method of this application.
[0250] See also Figure 7 , Figure 7 A flow chart of a data dump method provided in an embodiment of the present application is shown.
[0251] like Figure 7 As shown, the data dump method provided by this application may include:
[0252] S41. The storage module sends the second addresses corresponding to the Q sub-metadata files in the memory 1 through the second thread.
[0253] It should be understood that since the metadata file is stored in the memory 1 in the form of fragments, the metadata file may include Q sub-metadata files. Among the Q sub-metadata files, each sub-metadata file has an address in the memory 1, then the Q sub-metadata files correspond to Q second sub-addresses.
[0254] Among them, S41 and Figure 4 The implementation of S152 in the illustrated embodiment is similar and will not be repeated here.
[0255] S42. The task appending module reads the number of the fourth thread from the IO_Uring module.
[0256] The fourth thread is a thread that is not currently executing a task among all threads in the kernel layer.
[0257] Among them, S42 and Figure 6 The implementation of S22 in the illustrated embodiment is similar and will not be described again here.
[0258] S43. The task appending module sends a creation request 2 to the IO_Uring module.
[0259] Among them, the creation request 2 carries the value of P, and the creation request 2 is used to request the IO_Uring module to create a ring queue 2.
[0260] Among them, S46 and Figure 6 The implementation of S24 in the illustrated embodiment is similar and will not be described again here.
[0261] S44. The IO_Uring module creates a ring queue 2 according to the value of P.
[0262] The circular queue 2 is used to indicate a queue buffer based on IO_Uring. The circular queue 2 includes P second sub-areas, and the P second sub-areas are used to manage P files simultaneously.
[0263] Among them, S44 and Figure 6The implementation of S26 in the illustrated embodiment is similar and will not be described again here.
[0264] S45 . The task adding module fills the Q second sub-addresses into the P first sub-areas.
[0265] After the task appending module creates the circular queue 2, the task appending module may fill the Q second sub-addresses into the P second sub-areas.
[0266] In some embodiments, the value of Q is equal to the value of P, and the task appending module may fill the Q second sub-addresses into the P second sub-areas at one time.
[0267] For example, if the value of P is 8 and the value of Q is 8, then 8 sub-metadata files correspond to 8 second sub-addresses, and the task appending module can fill the 8 second sub-addresses into the 8 second sub-areas at one time.
[0268] In some embodiments, the value of Q is smaller than the value of P, and the task appending module may also fill the Q second sub-addresses into the P second sub-areas at one time.
[0269] For example, the value of P is 8 and the value of Q is 7. Then, 7 sub-metadata files correspond to 7 second sub-addresses, and the task appending module can fill the 7 second sub-addresses into 7 second sub-areas of the 8 second sub-areas at one time.
[0270] In some other embodiments, the value of Q is greater than the value of P, and the task appending module may fill the Q second sub-addresses into the P second sub-areas in two or more times.
[0271] For example, the value of P is 8 and the value of Q is 16. Then, 16 sub-metadata files correspond to 16 second sub-addresses. The task appending module can fill the 16 second sub-addresses into the 8 second sub-areas in two times.
[0272] Wherein, each time the task appending module fills the second sub-address, it may fill it simultaneously or sequentially.
[0273] If filling is performed at the same time, the filling time can be saved, and the time for the subsequent IO_Uring to dump the frame data from memory 1 to memory 2 can be further saved.
[0274] If filling is performed sequentially, the task appending module may sequentially fill the second sub-address into the second sub-area according to the order in which the Q sub-metadata files are stored in the memory 1 .
[0275] For example, the value of P is 8, the value of Q is 8, and the circular queue 2 includes 8 second sub-areas, namely sub-area a, sub-area b, sub-area c, sub-area d, sub-area e, sub-area f, sub-area g, and sub-area h; the number of second sub-addresses is 8, namely sub-address a, sub-address b, sub-address c, sub-address d, sub-address e, sub-address f, sub-address g, and sub-address h.
[0276] Based on this, the task append module can fill sub-address a in sub-area a, sub-address b in sub-area b, sub-address c in sub-area c, sub-address d in sub-area d, sub-address e in sub-area e, sub-address f in sub-area f, sub-address g in sub-area g, and sub-address h in sub-area h.
[0277] S46. The task appending module sends a dump request 2 to the IO_Uring module.
[0278] Among them, dump request 2 is used to instruct the IO_Uring module to dump Q sub-metadata files from memory 1 to memory 2.
[0279] In some embodiments, the value of Q is equal to the value of P, and the task appending module can fill Q second sub-addresses into P second sub-areas at one time. Then, after filling Q second sub-addresses into P second sub-areas at one time, the task appending module can send a dump request 2 to the IO_Uring module.
[0280] For example, the value of P is 8 and the value of Q is 8. Then, the task appending module may send a dump request 2 to the IO_Uring module after filling the 8 second sub-addresses into the 8 second sub-areas.
[0281] In other embodiments, the value of Q is smaller than the value of P. After the task appending module fills the Q second sub-addresses into the Q second sub-regions of the P second sub-regions at one time, it may send a dump request 2 to the IO_Uring module.
[0282] For example, the value of P is 8 and the value of Q is 7. Then, 7 sub-metadata files correspond to 7 second sub-addresses. After the task append module fills the 7 second sub-addresses into 7 of the 8 second sub-areas at one time, it can send a dump request 2 to the IO_Uring module.
[0283] In some other embodiments, the value of Q is greater than the value of P, and the task appending module may send a dump request 2 to the IO_Uring module each time after filling the second sub-address into the second sub-area.
[0284] For example, the value of P is 8 and the value of Q is 16, then 16 sub-metadata files correspond to 16 second sub-addresses. The task append module can fill the 16 second sub-addresses into the 8 second sub-areas in 2 times. After the task append module fills the 8 second sub-addresses into the 8 second sub-areas for the first time, it can send a dump request 2 to the IO_Uring module. After filling the remaining 8 second sub-addresses into the 8 second sub-areas for the second time, it can also send a dump request 2 to the IO_Uring module.
[0285] S47. The IO_Uring module reads Q sub-metadata files from the memory 1 according to the Q second sub-addresses.
[0286] Based on the description of S46, IO_Uring may receive the dump request 2 only once, or may receive the dump request 2 twice or more.
[0287] In some embodiments, the value of Q is equal to the value of P. After the task appending module fills Q second sub-addresses into P second sub-areas at one time, it sends a dump request 2 to the IO_Uring module. Then, the IO_Uring module can use P fourth threads to read Q sub-metadata files from the memory 1 at the same time according to the Q second sub-addresses.
[0288] For example, the value of P is 8 and the value of Q is 8. The task append module can send a dump request 2 to the IO_Uring module after filling the 8 second sub-addresses into the 8 second sub-areas. Then, after receiving the dump request 2, the IO_Uring module can read 8 sub-metadata files from the memory 1 at the same time according to the 8 second sub-addresses through 8 fourth threads.
[0289] In other embodiments, the value of Q is smaller than the value of P. After the task appending module fills the Q second sub-addresses into the Q second sub-regions of the P second sub-regions at one time, it can send a dump request 2 to the IO_Uring module. Then, the IO_Uring module can read Q sub-metadata files from the memory 1 at the same time according to the Q second sub-addresses through P fourth threads.
[0290] For example, the value of P is 8 and the value of Q is 7, then the 7 sub-metadata files correspond to 7 second sub-addresses. After the task append module fills the 7 second sub-addresses into 7 second sub-areas of the 8 second sub-areas at one time, it can send a dump request 2 to the IO_Uring module. Then, after receiving the dump request 2, the IO_Uring module can read the 7 sub-metadata files from the memory 1 at the same time according to the 7 second sub-addresses through 7 threads of the 8 threads.
[0291] In other embodiments, the value of Q is greater than the value of P. The task append module can send a dump request 2 to the IO_Uring module after filling Q second sub-addresses into P second sub-areas twice or more times. Then, the IO_Uring module can read the sub-metadata file from the memory 1 twice or more times through P fourth threads.
[0292] For example, the value of P is 8 and the value of Q is 16. The task append module can send two dump requests 2 to the IO_Uring module. Then, after receiving the dump request 2 for the first time, the IO_Uring module can read 8 sub-metadata files from the memory 1 according to the 8 second sub-addresses through 8 fourth threads; after receiving the dump request 2 for the second time, the IO_Uring module can read the remaining 8 sub-metadata files from the memory 1 at the same time through 8 fourth threads according to the remaining 8 second sub-addresses.
[0293] S48. Send Q sub-metadata files through P fourth threads.
[0294] Based on S42 , it can be known that the threads currently not executing tasks in all threads include P fourth threads. Therefore, the IO_Uring module can send P sub-metadata files to the memory 2 of the hardware layer simultaneously through the P fourth threads each time.
[0295] In some embodiments, the value of Q is equal to the value of P, and the IO_Uring module can read P sub-metadata files from the memory 1 according to the Q second sub-addresses at one time. Thus, the IO_Uring module can send Q sub-metadata files to the memory 2 at the same time through P fourth threads at one time.
[0296] For example, the value of P is 8, the value of Q is 8, the task append module can send 1 dump request 2 to the IO_Uring module, then the IO_Uring module can read 8 sub-metadata files from the memory 1 according to the 8 second sub-addresses at one time, and send 8 sub-metadata files to the memory 2 at the same time through 8 fourth threads.
[0297] In other embodiments, the value of Q is smaller than the value of P, and the task appending module can read Q sub-metadata files from the memory 1 at one time according to the Q second sub-addresses. Thus, the IO_Uring module can send Q sub-metadata files to the memory 2 at the same time through the Q fourth threads among the P fourth threads.
[0298] For example, the value of P is 8 and the value of Q is 7. The task append module can send 1 dump request 2 to the IO_Uring module. Then, the IO_Uring module can read 7 sub-metadata files from the memory 1 according to the 7 second sub-addresses at one time, and send the 7 sub-metadata files to the memory 2 at the same time through 7 of the 8 fourth threads.
[0299] In other embodiments, the value of Q is greater than the value of P, and the task appending module may read the sub-metadata file from the memory 1 twice or more times and then send the sub-metadata file to the memory 2 simultaneously through P fourth threads.
[0300] For example, the value of P is 8 and the value of Q is 16. After the task append module receives the dump request 2 for the first time, the IO_Uring module can read 8 sub-metadata files from the memory 1 according to the 8 second sub-addresses, and send the 8 sub-metadata files to the memory 2 through 8 fourth threads; after receiving the dump request 2 for the second time, the IO_Uring module can read the remaining 8 sub-metadata files from the memory 1 according to the remaining 8 second sub-addresses, and send the remaining 8 sub-metadata files to the memory 2 at the same time through 8 fourth threads.
[0301] Based on the above description, the IO_Uring module sends sub-metadata files to the memory 2 of the hardware layer through P fourth threads at the same time, which can improve the efficiency of dumping Q sub-metadata files to the memory 2, save the time of dumping Q sub-metadata files to the memory 2, and shorten the storage time of Q sub-metadata files in the memory 1.
[0302] In the present application, the IO_Uring module can create a circular queue 2 including P second sub-areas, and the task appending module can fill the Q second sub-addresses corresponding to the Q sub-metadata files into the circular queue 2 once or multiple times, so that the circular queue 2 can manage P second sub-addresses or less than P second sub-addresses at a time, ensuring that the IO_Uring module can read P sub-metadata files or less than P sub-metadata files at the same time through P fourth threads each time, realizing fast reading of sub-metadata files, and making data preparations to further improve the efficiency of dumping the Q sub-metadata files in the memory 1 to the memory 2.
[0303] Moreover, the IO_Uring module can simultaneously send P sub-metadata files or less than P sub-metadata files to the memory 2 of the hardware layer through P fourth threads. In this way, the efficiency of dumping Q sub-metadata files to the memory 2 can be improved, the time for dumping Q sub-metadata files to the memory 2 can be saved, and the storage time of the Q sub-metadata files in the memory 1 can be shortened, thereby reducing the memory resource usage of the memory 1 and reducing the storage pressure of the memory 1.
[0304] Based on some of the aforementioned embodiments, the data dump method provided by this application is introduced below.
[0305] Illustratively, the present application provides a data dump method.
[0306] For the sake of convenience, the data dump method of this application can be Figure 2 The electronic device 100 is used to execute.
[0307] The electronic device 100 may include a first application, a storage module, an input / output module, a first memory and a second memory. The storage speed of the first memory is higher than that of the second memory. The data in the first memory will be cleared when the electronic device is turned off, and the data in the second memory will not be cleared when the electronic device is turned off.
[0308] The specific implementation of the first application can be found in Figure 4 Description of the camera application.
[0309] The specific implementation of the storage module can be found in Figure 4 For more information about the storage module, see .
[0310] The specific implementation of the input and output modules can be found in Figure 4 For more information about the IO_Uring module, see IO_Uring.
[0311] For the specific implementation of the first memory, please refer to Figure 4 For the description of memory 1, the specific implementation of the second memory can be found in Figure 4 The relevant description about memory 2 is not repeated here.
[0312] See also Figure 8 , Figure 8 A flow chart of a data dump method provided in an embodiment of the present application is shown.
[0313] like Figure 8 As shown, the data dump method provided by this application may include:
[0314] S301. When obtaining first data, the first application sends the first data to a storage module.
[0315] The specific implementation of the first data can be found in Figure 4 The description of the first image in S11-S12 is omitted here.
[0316] The specific implementation of S301 can be found in Figure 4 The description of S11-S12 in the above will not be repeated here.
[0317] S302: The storage module saves a first file and a second file corresponding to the received first data to a first memory, where the first file includes first information of the first data, and the second file includes second information of the first data.
[0318] The specific implementation of the first file can be found in Figure 4 For the description of the frame file, the specific implementation of the second file can be found in Figure 4 The description of metadata files in [1] is not repeated here.
[0319] The specific implementation of S302 can be found in Figure 4 The description of S13 in
[15] is omitted here.
[0320] S303: The storage module creates a thread pool, which includes a first thread and a second thread.
[0321] The specific implementation of the thread pool can be found in Figure 4 For the description of thread pool in S14, please refer to the specific implementation of the first thread and the second thread. Figure 4 The description of the first thread and the second thread in S14 is not repeated here.
[0322] The specific implementation of S303 can be found in Figure 4 The description of S14 in
[15] is omitted here.
[0323] S304. The storage module uses a first thread to send a first address to the input / output module. At the same time, the storage module uses a second thread to send a second address to the input / output module. The first address is used to indicate the location of the first file in the first memory, and the second address is used to indicate the location of the second file in the first memory.
[0324] The specific implementation of the first address can be found in Figure 4 The description of the first address in S151 and the specific implementation of the second address can be found in Figure 4 The description of the first address in S152 will not be repeated here.
[0325] The specific implementation of S304 can be found in Figure 4The description of S151 and S152 in the above section will not be repeated here.
[0326] S305: The input / output module reads the first file from the first memory according to the received first address, and the input / output module reads the second file from the first memory according to the received second address.
[0327] The specific implementation of S305 can be found in Figure 4 The description of S161 and S162 in the above section will not be repeated here.
[0328] S306: The input / output module sends the first file to the second storage, and the input / output module sends the second file to the second storage.
[0329] The specific implementation of S306 can be found in Figure 4 The description of S171 and S172 in the above section will not be repeated here.
[0330] The data dump method of the present application saves time in sending addresses by having multiple threads in a thread pool simultaneously send multiple addresses corresponding to multiple files corresponding to the first data, making it possible to more efficiently dump the multiple files corresponding to the first data from the first memory to the second memory. This reduces the storage time of the multiple files corresponding to the first data in the first memory, reduces the storage capacity of the first memory, reduces the storage pressure of the first memory, and ensures dump efficiency. Furthermore, since the transmission volume of the first address is smaller than that of the first file, the transmission speed of the first address is smaller than that of the first file, and the transmission volume of the second address is smaller than that of the second file, the transmission speed of the second address is smaller than that of the second file. The storage module sends the first address and the second address to the input / output module instead of the first file and the second file, which further improves dump efficiency.
[0331] In some embodiments, the electronic device further includes a splitting module, and the data dump method of the present application may include:
[0332] The storage module uses a first thread to send a first address to the splitting module; when receiving the first address, the splitting module splits the first file in the first memory to obtain N first sub-files, and sends a first creation request to the input-output module, the first creation request is used to instruct the input-output module to create a first circular queue; when receiving the first creation request, the input-output module creates a first circular queue, the first circular queue includes N first sub-areas, the N first sub-areas are used to simultaneously manage N first sub-addresses, and the N first sub-addresses are respectively the addresses of the N first sub-files in the first memory; the splitting module fills the N first sub-addresses into the N first sub-areas; the input-output module reads the first file from the first memory according to the received first address, including: the input-output module simultaneously reads the N first sub-files corresponding to the N first sub-addresses from the first memory; the input-output module sends the first file to the second memory, including: the input-output module simultaneously sends the N first sub-files to the second memory.
[0333] The specific implementation of the first sub-file can be found in Figure 6 The description of the first sub-metadata is not repeated here.
[0334] For the specific implementation of the first creation request, please refer to Figure 6 The description of creating request 1 in S25 is not repeated here.
[0335] The specific implementation of the first ring queue can be found in Figure 6 The relevant description about the ring queue 1 in S26 is not repeated here.
[0336] For the specific implementation of the first sub-address, please refer to Figure 6 The description of the first sub-address is not repeated here.
[0337] The specific implementation of the above steps can be found in Figure 6 The description of S23-S30 in the above is not repeated here.
[0338] In some embodiments, the data dump method of the present application may include:
[0339] The splitting module reads the number of third threads from the input-output module, where the third thread is a thread that is not currently executing a task among all threads of the input-output module; the splitting module splits the first file according to the number N of third threads to obtain N first sub-files; the input-output module simultaneously reads N first sub-files corresponding to N first sub-addresses from the first memory, including: the input-output module uses N third threads to simultaneously read N first sub-files corresponding to N first sub-addresses from the first memory.
[0340] The specific implementation of the third thread can be found in Figure 6 The description of the third thread is not repeated here.
[0341] For example, the value of the number N of the third threads is 8, then the first file can be split into 8 parts.
[0342] The specific implementation of the above steps can be found in Figure 6 The description of S23-S30 in the above is not repeated here.
[0343] In some embodiments, the data dump method of the present application may include:
[0344] The splitting module determines a first occupancy, where the first occupancy is the capacity of the storage space of the first memory occupied by the first file; when the first occupancy is less than or equal to a preset threshold, the splitting module splits the first file according to the number N of third threads to obtain N first sub-files.
[0345] The specific implementation of the first occupancy can be found in Figure 6 The description of the first occupancy in S23 will not be repeated here.
[0346] For example, the number N of third threads is 8, the first occupancy of the first file is 8MB, and the preset threshold is 16MB. Then, the splitting module can split the first file into 8 parts, each of which is 1MB, and the splitting module can fill the 8 first sub-addresses into the 8 first sub-areas at one time.
[0347] Furthermore, the input / output module can read eight first sub-files from the first memory at one time according to the eight first sub-addresses, and simultaneously send the eight first sub-files to the second memory through eight third threads.
[0348] The specific implementation of the above steps can be found in Figure 6 The relevant description of S23-S24 regarding the first occupancy being less than or equal to the preset threshold is not repeated here.
[0349] In some embodiments, the data dump method of the present application may further include:
[0350] When the first occupancy is greater than a preset threshold, the splitting module splits the first file according to a quantity M to obtain M first sub-files, where M is a positive integer greater than N; the splitting module fills the N first sub-addresses into the N first sub-areas in sequence through H filling operations, where H is a positive integer greater than or equal to 2; the input-output module simultaneously reads the N first sub-files corresponding to the N first sub-addresses from the first memory, including: the input-output module uses N third threads to read the M first sub-files corresponding to the M first sub-addresses from the first memory in sequence through H reading operations; the input-output module simultaneously sends the N first sub-files to the second memory, including: the input-output module uses N third threads to send the M first sub-files to the second memory in sequence through H sending operations.
[0351] For example, the number N of third threads is 8, and the first occupancy of the first file is 16MB. The splitting module can set the value of M to 16, that is, split the first file into 16 parts, each part is 1MB, and the value of H can be 2. The splitting module can fill the 16 first sub-addresses into the 8 first sub-areas in 2 times.
[0352] The specific implementation of the above steps can be found in Figure 6 The description of S23-S24 regarding the first occupancy being greater than the preset threshold is not repeated here.
[0353] In some embodiments, the second file includes Q second sub-files, and the electronic device further includes a task appending module. The data dump method of the present application may include:
[0354] The storage module uses a second thread to send Q second sub-addresses to the task appending module, and the Q second sub-addresses are respectively the addresses of the Q second sub-files in the first memory; when the task appending module receives the Q second sub-addresses, the task appending module sends a second creation request to the input-output module, and the second creation request is used to instruct the input-output module to create a second circular queue; when the input-output module receives the second creation request, it creates a second circular queue, and the second circular queue includes Q second sub-areas, and the Q second sub-areas are used to simultaneously manage the Q second sub-addresses; the task appending module fills the Q second sub-addresses into the Q second sub-areas; the input-output module reads the second file from the first memory according to the received second address, including: the input-output module simultaneously reads the Q second sub-files corresponding to the Q second sub-addresses from the first memory; the input-output module sends the second file to the second memory, including: the input-output module simultaneously sends the Q second sub-files to the second memory.
[0355] The specific implementation of the second sub-file can be found in Figure 7The description of the second sub-metadata is not repeated here.
[0356] The specific implementation of the second sub-address can be found in Figure 7 The description of the second sub-address is not repeated here.
[0357] For the specific implementation of the second creation request, please refer to Figure 7 The description of S43 regarding creation request 2 is not repeated here.
[0358] The specific implementation of the second ring queue can be found in Figure 7 The description of ring queue 2 in
[15] is omitted here.
[0359] The specific implementation of the above steps can be found in Figure 7 The description of S43-S48 in the above will not be repeated here.
[0360] In some embodiments, the data dump method of the present application may include:
[0361] When receiving the Q second sub-addresses, the task appending module reads the number of fourth threads from the input-output module, where the fourth thread is a thread that is not currently executing a task among all threads of the input-output module; the task appending module sends a second creation request to the input-output module, where the second creation request includes the number P of fourth threads, and the second circular queue includes P second sub-regions, where the P second sub-regions are used to simultaneously manage the P second sub-addresses; the task appending module fills the Q second sub-addresses into the Q second sub-regions, including: the task appending module fills the Q second sub-addresses into the P second sub-regions; the input-output module simultaneously reads the Q second subfiles corresponding to the Q second subaddresses from the first memory, including: the input-output module uses the P fourth threads to read the Q second subfiles corresponding to the Q second subaddresses from the first memory.
[0362] The specific implementation of the fourth thread can be found in Figure 7 The description of the fourth thread is not repeated here.
[0363] In some embodiments, the data dump method of the present application may include:
[0364] When the value of Q is equal to the value of P, the task appending module fills the Q second sub-addresses into the P second sub-areas accordingly.
[0365] For example, the number of fourth threads P is 8, and the number of second subaddresses Q is 8. Then, 8 second subfiles correspond to 8 second subaddresses, and the task appending module can fill the 8 second subaddresses into the 8 second subareas at one time.
[0366] Correspondingly, the input / output module can read eight second subfiles from the first memory at the same time according to the eight second subaddresses through the eight fourth threads, and send the eight second subfiles to the second memory through the eight fourth threads at the same time.
[0367] The specific implementation of the above steps can be found in Figure 7 The description of the situation in S45 regarding the case where the value of Q is equal to the value of P is not repeated here.
[0368] In some embodiments, the data dump method of the present application may include:
[0369] When the value of Q is less than the value of P, the task adding module fills the Q second sub-addresses into the Q second sub-areas of the P second sub-areas respectively.
[0370] For example, the number of fourth threads P is 8, and the number of second sub-addresses Q is 7. Then, 7 sub-metadata files correspond to 7 second sub-addresses, and the task appending module can fill the 7 second sub-addresses into 7 second sub-areas of the 8 second sub-areas at one time.
[0371] Correspondingly, the input / output module can read 7 second subfiles from the first memory at the same time according to the 7 second subaddresses through 7 threads out of 8 threads, and send the 7 second subfiles to the second memory at the same time through 7 fourth threads out of 8 fourth threads.
[0372] The specific implementation of the above steps can be found in Figure 7 The description of the situation in S45 regarding the case where the value of Q is less than the value of P is not repeated here.
[0373] In some embodiments, the data dump method of the present application may include:
[0374] When the value of Q is greater than the value of P, the task appending module fills the Q second sub-addresses into the P second sub-areas in sequence through R filling operations, where R is a positive integer greater than or equal to 2; the input-output module reads the Q second sub-files from the first memory at the same time according to the Q second sub-addresses, including: the input-output module uses P fourth threads to read the Q second sub-files corresponding to the Q second sub-addresses from the first memory in sequence through R reading operations; the input-output module sends the Q second sub-files to the second memory, including: the input-output module uses P fourth threads to send the Q second sub-files to the second memory in sequence through R sending operations.
[0375] For example, the number of fourth threads P is 8, and the number of second sub-addresses Q is 16. Then, 16 sub-metadata files correspond to 16 second sub-addresses, and the task appending module can fill the 16 second sub-addresses into 8 second sub-areas in 2 times.
[0376] Correspondingly, the input and output module can read the eight second subfiles from the first memory simultaneously in two times through the eight fourth threads, and send the eight second subfiles to the memory 2 in two times through the eight fourth threads.
[0377] The specific implementation of the above steps can be found in Figure 7 The description of the situation in S45 regarding the case where the value of Q is greater than the value of P is not repeated here.
[0378] In some embodiments, the first application is a camera application, and the data dump method of the present application may include:
[0379] When the first application collects the first image, it sends the first image to the storage module. The first information includes pixel information of the first image, and the second information includes attribute information of the first image.
[0380] The specific implementation of the above steps can be found in Figure 4 The description of S11-S12 in the above will not be repeated here.
[0381] In some embodiments, the data dump method of the present application may further include:
[0382] Displaying a first interface, where the first interface is an interface of a first application in the electronic device;
[0383] In response to a first operation on the first interface, a first image is acquired, where the first operation is a photographing operation.
[0384] The specific implementation of the above steps can be found in Figure 4 The description of how to obtain the first image is not repeated here.
[0385] Illustratively, the present application provides an electronic device, comprising a processor; when the processor executes computer code or instructions in a memory, the electronic device executes the data dump method in the foregoing embodiment.
[0386] Illustratively, the present application provides an electronic device comprising: a memory and a processor; the memory is coupled to the processor, and the memory is used to store program code or instructions; the processor is used to call the program code or instructions in the memory so that the electronic device executes the data dump method in the above embodiment.
[0387] Illustratively, the present application provides a chip system, which is applied to an electronic device including a memory, a display screen, and a sensor; the chip system includes: one or more interface circuits and one or more processors; the interface circuit and the processor are interconnected through lines; the interface circuit is used to receive signals from the memory and send signals to the processor, and the signals include computer code or instructions stored in the memory; when the processor executes the computer code or instructions, the electronic device executes the data dump method in the previous embodiment.
[0388] Illustratively, the present application provides a computer-readable storage medium storing codes or instructions. When the codes or instructions are executed on an electronic device, the electronic device implements the data dump method in the foregoing embodiment.
[0389] Illustratively, the present application provides a computer program product, which, when executed on a computer, enables an electronic device to implement the data dump method in the foregoing embodiments.
[0390] In the above embodiments, all or part of the functions can be implemented by software, hardware, or a combination of software and hardware. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer codes or instructions. When the computer program code or instructions are loaded and executed on a computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer code or instructions can be stored in a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0391] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by a computer program instructing related hardware to perform the processes. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A data dump method, characterized in that: The method is applied to an electronic device, the electronic device including a first application, a storage module, an input / output module, a first memory, and a second memory, wherein the storage speed of the first memory is higher than that of the second memory, data in the first memory is cleared when the electronic device is shut down, and data in the second memory is not cleared when the electronic device is shut down, and the method includes: When the first application obtains the first data, the first application sends the first data to the storage module; The storage module saves a first file and a second file corresponding to the received first data to a first memory, wherein the first file includes first information of the first data, and the second file includes second information of the first data; The storage module creates a thread pool, wherein the thread pool includes a first thread and a second thread; The storage module uses the first thread to send a first address to the input / output module. Simultaneously, the storage module uses the second thread to send a second address to the input / output module. The first address is used to indicate a location of the first file in the first memory, and the second address is used to indicate a location of the second file in the first memory. The input / output module reads the first file from the first memory according to the received first address, and the input / output module reads the second file from the first memory according to the received second address; The input-output module sends the first file to the second storage, and the input-output module sends the second file to the second storage.
2. The method according to claim 1, characterized in that The electronic device further includes a splitting module, and the storage module uses the first thread to send the first address to the input / output module, including: The storage module uses the first thread to send the first address to the splitting module; Upon receiving the first address, the splitting module splits the first file in the first memory into N first sub-files, and sends a first creation request to the input / output module, wherein the first creation request is used to instruct the input / output module to create a first circular queue; Upon receiving the first creation request, the input / output module creates the first circular queue, where the first circular queue includes N first sub-areas, where the N first sub-areas are used to simultaneously manage N first sub-addresses, where the N first sub-addresses are respectively addresses of the N first sub-files in the first memory; The splitting module fills the N first sub-addresses into the N first sub-areas accordingly; The input / output module reads the first file from the first memory according to the received first address, including: The input / output module simultaneously reads the N first sub-files corresponding to the N first sub-addresses from the first memory; The input / output module sending the first file to the second memory includes: The input / output module simultaneously sends the N first sub-files to the second memory.
3. The method according to claim 2, characterized in that The step of splitting the first file in the first memory to obtain N first sub-files includes: The splitting module reads the number of third threads from the input / output module, where the third threads are threads that are not currently executing tasks among all threads of the input / output module; The splitting module splits the first file according to the number N of the third threads to obtain the N first sub-files; The input / output module simultaneously reads the N first sub-files corresponding to the N first sub-addresses from the first memory, including: The input / output module uses the N third threads to simultaneously read the N first sub-files corresponding to the N first sub-addresses from the first memory.
4. The method according to claim 3, characterized in that The splitting module splits the first file according to the number N of the third threads to obtain the N first sub-files, including: The splitting module determines a first occupancy, where the first occupancy is the capacity of the storage space of the first memory occupied by the first file; When the first occupancy is less than or equal to a preset threshold, the splitting module splits the first file according to the number N of the third threads to obtain the N first sub-files.
5. The method according to claim 4, characterized in that The method further comprises: When the first occupancy is greater than the preset threshold, the splitting module splits the first file according to a number M to obtain M first sub-files, where M is a positive integer greater than N; The M first sub-files correspond to M first sub-addresses, and the splitting module fills the N first sub-addresses into the N first sub-areas, including: The splitting module sequentially fills the M first sub-addresses into the N first sub-areas through H filling operations, where H is a positive integer greater than or equal to 2; The input / output module simultaneously reads the N first sub-files corresponding to the N first sub-addresses from the first memory, including: The input / output module uses the N third threads to sequentially read the M first sub-files corresponding to the M first sub-addresses from the first memory through H read operations; The input / output module simultaneously sends the N first sub-files to the second memory, including: The input / output module uses the N third threads to sequentially send the M first sub-files to the second memory through H sending operations.
6. The method according to any one of claims 1 to 5, characterized in that The second file includes Q second sub-files, the electronic device further includes a task appending module, and the storage module uses the second thread to send a second address to the input / output module, including: The storage module uses the second thread to send Q second sub-addresses to the task appending module, where the Q second sub-addresses are respectively addresses of the Q second sub-files in the first memory; When receiving the Q second sub-addresses, the task appending module sends a second creation request to the input / output module, where the second creation request is used to instruct the input / output module to create a second circular queue; Upon receiving the second creation request, the input / output module creates the second circular queue, where the second circular queue includes Q second sub-areas, and the Q second sub-areas are used to simultaneously manage the Q second sub-addresses; The task appending module fills the Q second sub-addresses into the Q second sub-areas; The input / output module reads the second file from the first memory according to the received second address, including: The input / output module simultaneously reads the Q second sub-files corresponding to the Q second sub-addresses from the first memory; The input / output module sending the second file to the second storage includes: The input / output module simultaneously sends the Q second sub-files to the second memory.
7. The method according to claim 6, characterized in that Upon receiving the Q second sub-addresses, the task appending module sends a second creation request to the input / output module, including: When receiving the Q second sub-addresses, the task adding module reads the number of fourth threads from the input / output module, where the fourth threads are threads that are not currently executing tasks among all threads of the input / output module; The task appending module sends the second creation request to the input / output module, where the second creation request includes the number P of the fourth threads, and the second circular queue includes P second sub-areas, where the P second sub-areas are used to simultaneously manage P second sub-addresses; The task appending module fills the Q second sub-addresses into the Q second sub-areas, including: The task appending module fills the Q second sub-addresses into the P second sub-areas; The input / output module simultaneously reads the Q second sub-files corresponding to the Q second sub-addresses from the first memory, including: The input / output module uses the P fourth threads to read the Q second sub-files corresponding to the Q second sub-addresses from the first memory.
8. The method according to claim 7, characterized in that The task appending module fills the Q second sub-addresses into the P second sub-areas, including: When the value of Q is equal to the value of P, the task adding module fills the Q second sub-addresses into the P second sub-areas accordingly.
9. The method according to claim 8, characterized in that The method further comprises: When the value of Q is smaller than the value of P, the task adding module fills the Q second sub-addresses into the Q second sub-areas of the P second sub-areas respectively.
10. The method according to claim 8 or 9, characterized in that The method further comprises: When the value of Q is greater than the value of P, the task appending module sequentially fills the Q second sub-addresses into the P second sub-areas through R filling operations, where R is a positive integer greater than or equal to 2; The input / output module simultaneously reads the Q second sub-files from the first memory according to the Q second sub-addresses, including: The input / output module uses the P fourth threads to sequentially read the Q second sub-files corresponding to the Q second sub-addresses from the first memory through R read operations; The input / output module sends the Q second sub-files to the second memory, including: The input / output module uses the P fourth threads to sequentially send the Q second sub-files to the second memory through R sending operations.
11. The method according to any one of claims 1 to 5 or any one of claims 7 to 9, wherein the first application is a camera application, the first data includes a first image, and when the first application collects the first data, sending the first data to the storage module comprises: When the first application collects the first image, it sends the first image to the storage module. The first information includes pixel information of the first image, and the second information includes attribute information of the first image.
12. The method according to claim 11, characterized in that When the first application collects the first image, before sending the first image to the storage module, the method further includes: Displaying a first interface, where the first interface is an interface of a first application in the electronic device; In response to a first operation on the first interface, a first image is acquired, where the first operation is a photographing operation.
13. An electronic device, characterized in that: The electronic device includes: one or more processors, and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program code, where the computer program code includes computer instructions. The one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 1 to 12.
14. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that The computer-readable storage medium comprises instructions, which, when executed on an electronic device, cause the electronic device to perform the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Memory management method and device, electronic equipment and computer readable storage medium
CN114443268A
Method and System for Facilitating Memory Analysis
US20110078684A1