WO2024087724A1 - Garbage collection method, page storage method, and electronic device - Google Patents

Garbage collection method, page storage method, and electronic device Download PDF

Info

Publication number
WO2024087724A1
WO2024087724A1 PCT/CN2023/105033 CN2023105033W WO2024087724A1 WO 2024087724 A1 WO2024087724 A1 WO 2024087724A1 CN 2023105033 W CN2023105033 W CN 2023105033W WO 2024087724 A1 WO2024087724 A1 WO 2024087724A1
Authority
WO
WIPO (PCT)
Prior art keywords
erase block
page
pages
reuse
electronic device
Prior art date
Application number
PCT/CN2023/105033
Other languages
French (fr)
Chinese (zh)
Inventor
孙殿森
宋云龙
彭宝领
卢方舟
邓向
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2024087724A1 publication Critical patent/WO2024087724A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0652Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0614Improving the reliability of storage systems
    • G06F3/0616Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • G06F3/0679Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]

Definitions

  • the present application relates to the field of electronic devices, and more specifically, to a garbage collection method, a page storage method and an electronic device.
  • Flash memory is an electrically erasable programmable read-only memory (EEPROM).
  • the storage space of flash memory is divided into many erase blocks, each of which contains several data pages. New data pages can be written to the free positions of the erase blocks in an append-write manner.
  • garbage collection (GC) operations need to be performed on some erase blocks of the flash memory.
  • free space can only be released by erasing the entire erase block, that is, clearing the garbage pages in the erase block, and then writing the valid pages in the erase block and the new data pages into the new erase block together.
  • Garbage collection efficiency refers to the proportion of garbage pages in the erased erase block. The higher the garbage collection efficiency, the fewer valid pages need to be written, the faster the garbage collection operation is performed, and the fewer the number of erases, the longer the service life of the flash memory.
  • the embodiments of the present application provide a garbage collection method, a page storage method and an electronic device, which are beneficial to improving the efficiency of flash memory garbage collection, increasing the speed of garbage collection and extending the service life of the flash memory.
  • a method for garbage collection comprising: obtaining a first score based on the number of garbage pages in a first erase block and a growth rate of garbage pages in a second erase block; obtaining a second score based on the number of garbage pages in the second erase block and a growth rate of garbage pages in the first erase block; and performing garbage collection on the first erase block when the first score is greater than the second score.
  • first erase block and the second erase block are any two different erase blocks in the flash memory.
  • the erase block with the fastest growth rate of garbage pages will not necessarily be the object of garbage collection.
  • a large number of garbage pages may be accumulated in the erase block with the fastest growth rate of garbage pages, so that the efficiency of garbage collection of the erase block is higher, thereby improving the efficiency of garbage collection.
  • the efficiency of garbage collection is higher, the write amplification factor is reduced, and the number of flash memory erases is reduced, which is conducive to improving the service life of the flash memory.
  • the first erase block belongs to a first erase block set
  • the first erase block is the erase block with the largest number of junk pages in the first erase block set
  • the erase blocks in the first erase block set are used to store pages of a first heat level
  • the second erase block belongs to a second erase block set
  • the second erase block is the erase block with the largest number of junk pages in the second erase block set
  • the erase blocks in the second erase block set are used to store pages of a second heat level
  • the frequency of updating pages of the first heat level is different from the frequency of updating pages of the second heat level.
  • the erase blocks corresponding to each heat level store pages of the corresponding heat level. Since the pages of each heat level are updated at different frequencies, the growth rate of garbage pages in the erase blocks corresponding to each heat level is also different, and can even be clearly distinguished.
  • the erase block with the fastest growth rate of garbage pages will not necessarily be the object of garbage collection.
  • the erase block with the fastest growth rate of garbage pages may accumulate a large number of garbage pages, so that the efficiency of garbage collection of this erase block is higher, thereby improving the efficiency of garbage collection.
  • the higher the efficiency of garbage collection the higher the write amplification factor.
  • the number of flash memory erases is reduced, which is beneficial to improving the service life of the flash memory.
  • the erase blocks are classified according to the heat level, the number of erase blocks that need to calculate the scores is small, and the speed of determining the target erase blocks for garbage collection is faster, which is beneficial to improving the speed of garbage collection.
  • the method also includes: determining at least two thermal levels, and a range of reuse distances corresponding to each of the at least two thermal levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent updates of the first page, the at least two thermal levels including the first thermal level and the second thermal level; determining a set of erase blocks corresponding to each thermal level.
  • the erase block set includes one or more erase blocks.
  • each heat level corresponds to each reuse distance range one by one.
  • the reuse distance range corresponding to each heat level can be preset by the user or the system, or can be determined based on historical reuse distance data.
  • the heat level of the page is divided based on the reuse distance, which can more accurately quantify the division of heat levels and is conducive to improving the efficiency of garbage collection.
  • the determining of at least two heat levels, and the range of reuse distances corresponding to each of the at least two heat levels includes: obtaining the reuse distances of multiple pages written within a first time period; and determining the range of reuse distances corresponding to each heat level by clustering the reuse distances of the multiple pages.
  • the range of reuse distances corresponding to the heat level can be divided according to the reuse distances of multiple pages written in the first time period. Therefore, the division of heat levels is more reasonable, so as to facilitate the classified storage of data in the flash memory, which is conducive to improving the efficiency of garbage collection.
  • the range of reuse distances corresponding to the heat level can also be regularly updated to reflect the changes in the flash memory load hotspot.
  • the method also includes: predicting a second reuse distance of the second page based on one or more first reuse distances of the second page within a second time period, the second reuse distance being used to indicate the number of write operations performed by the second page on pages other than the second page between the current moment and the next update moment; determining the thermal level to which the second page belongs based on the second reuse distance and the range of reuse distances corresponding to each thermal level; and writing the second page to an erase block in an erase block set corresponding to the thermal level to which the second page belongs.
  • the page belongs to the first heat level.
  • all pages that need to be written or updated can be distinguished based on the heat level, so as to write into the erase blocks of the corresponding heat level, thereby making the growth rate of garbage pages in the erase blocks corresponding to different heat levels clearly distinguishable, which is conducive to improving the efficiency of garbage collection.
  • the garbage collection of the first erase block includes: extracting valid pages in the first erase block; writing the valid pages into a third erase block; and erasing all pages in the first erase block.
  • the method further includes: writing a third page into the first erase block, the third page belonging to a third heat level; adding the first erase block to an erase block set corresponding to the third heat level.
  • a method for storing pages comprising: determining at least two heat levels and a range of a reuse distance corresponding to each of the at least two heat levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent update moments of the first page;
  • An erase block set corresponding to each thermal level is determined, the erase block set includes a first erase block set, the at least two thermal levels include a first thermal level, and the erase blocks in the first erase block set are used to store pages of the first thermal level.
  • the erase block set includes one or more erase blocks.
  • each heat level corresponds to each reuse distance range one by one.
  • the reuse distance range corresponding to each heat level can be preset by the user or the system, or can be determined based on historical reuse distance data.
  • the use of dividing the heat level of pages based on reuse distance can more accurately quantify the division of heat levels, which is conducive to improving the efficiency of garbage collection.
  • the determination of at least two heat levels and the range of reuse distances corresponding to each of the at least two heat levels includes: obtaining the reuse distances of multiple pages written in a first time period; clustering the reuse distances of the multiple pages to determine the range of reuse distances corresponding to each heat level; The range of reuse distance.
  • the range of reuse distances corresponding to the heat level can be divided according to the reuse distances of multiple pages written in the first time period. Therefore, the division of heat levels is more reasonable, so as to facilitate the classified storage of data in the flash memory, which is conducive to improving the efficiency of garbage collection.
  • the range of reuse distances corresponding to the heat level can also be regularly updated to reflect the changes in the flash memory load hotspot.
  • the method also includes: predicting a second reuse distance of the second page based on a first reuse distance of the second page within a first time period, the second reuse distance being used to indicate the number of times the second page performs write operations on pages other than the second page between the current moment and the next update moment; determining that the second page belongs to the first heat level based on the second reuse distance and the range of reuse distances corresponding to each heat level; and writing the second page to an erase block in the first erase block set.
  • the page belongs to the first heat level.
  • all pages that need to be written or updated can be distinguished based on the heat level, so as to write into the erase blocks of the corresponding heat level, thereby making the growth rate of garbage pages in the erase blocks corresponding to different heat levels clearly distinguishable, which is conducive to improving the efficiency of garbage collection.
  • an electronic device comprising:
  • processors one or more processors
  • the one or more memories store one or more computer programs, and the one or more computer programs include instructions.
  • the electronic device executes the following steps:
  • a first score is obtained according to the number of garbage pages in a first erase block and a growth rate of garbage pages in a second erase block; a second score is obtained according to the number of garbage pages in the second erase block and a growth rate of garbage pages in the first erase block; and when the first score is greater than the second score, garbage collection is performed on the first erase block.
  • the first erase block belongs to a first erase block set
  • the first erase block is the erase block with the largest number of junk pages in the first erase block set
  • the erase blocks in the first erase block set are used to store pages of a first heat level
  • the second erase block belongs to a second erase block set
  • the second erase block is the erase block with the largest number of junk pages in the second erase block set
  • the erase blocks in the second erase block set are used to store pages of a second heat level
  • the frequency of updating pages of the first heat level is different from the frequency of updating pages of the second heat level.
  • the electronic device when the instruction is executed by the one or more processors, performs the following steps: determine at least two thermal levels, and a range of reuse distances corresponding to each of the at least two thermal levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent updates of the first page, the at least two thermal levels including the first thermal level and the second thermal level; determine a set of erase blocks corresponding to each thermal level.
  • the electronic device when the instruction is executed by the one or more processors, performs the following steps: obtaining the reuse distances of multiple pages written within a first time period; and determining the range of the reuse distances corresponding to each heat level by clustering the reuse distances of the multiple pages.
  • the electronic device when the instruction is executed by the one or more processors, performs the following steps: predicting a second reuse distance of the second page based on one or more first reuse distances of the second page within a second time period, the second reuse distance being used to indicate the number of write operations performed by the second page on pages other than the second page between the current moment and the next update moment; determining the thermal level to which the second page belongs based on the second reuse distance and the range of reuse distances corresponding to each thermal level; and writing the second page to an erase block in an erase block set corresponding to the thermal level to which the second page belongs.
  • the electronic device when the instruction is executed by the one or more processors, performs the following steps: extracting valid pages in the first erase block; writing the valid pages into a third erase block; and erasing all pages in the first erase block.
  • the electronic device when the instruction is executed by the one or more processors, the electronic device performs the following steps: writing a third page into the first erase block, the third page belonging to a third thermal level; The first erase block is added to an erase block set corresponding to the third thermal level.
  • an electronic device comprising:
  • processors one or more processors
  • the one or more memories store one or more computer programs, and the one or more computer programs include instructions.
  • the electronic device When the instructions are executed by the one or more processors, the electronic device performs the following steps: determining at least two thermal levels and a range of reuse distances corresponding to each of the at least two thermal levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent updates of the first page; determining an erase block set corresponding to each thermal level, the erase block set including a first erase block set, the at least two thermal levels including the first thermal level, and the erase blocks in the first erase block set being used to store pages of the first thermal level.
  • the electronic device when the instruction is executed by the one or more processors, performs the following steps: obtaining the reuse distances of multiple pages written within a first time period; and determining the range of the reuse distances corresponding to each heat level by clustering the reuse distances of the multiple pages.
  • the electronic device when the instruction is executed by the one or more processors, performs the following steps: predicting a second reuse distance of the second page based on the first reuse distance of the second page within the first time period, the second reuse distance being used to indicate the number of write operations performed by the second page on pages other than the second page between the current moment and the next update moment; determining that the second page belongs to the first heat level based on the second reuse distance and the range of reuse distances corresponding to each heat level; and writing the second page to an erase block in the first erase block set.
  • a chip comprising a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the method described in the first aspect and any possible implementation of the first aspect is executed, or the method described in the second aspect and any possible implementation of the second aspect is executed.
  • a computer-readable storage medium characterized in that it includes computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect and any possible implementation of the first aspect, or executes the method described in the second aspect and any possible implementation of the second aspect.
  • a computer program product includes: a computer program code, which, when executed, implements the method described in the first aspect and any possible implementation manner of the first aspect, or implements the method described in the second aspect and any possible implementation manner of the second aspect.
  • FIG1 is a schematic diagram of the structure of an electronic device provided by this embodiment.
  • FIG. 2 is a software structure block diagram of the electronic device according to an embodiment of the present application.
  • FIG. 3 is a schematic diagram of the structure of a flash memory applicable to an embodiment of the present application.
  • FIG. 4 is a schematic diagram of garbage collection applicable to an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a reuse distance of a data page according to an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of a page storage method provided in an embodiment of the present application.
  • FIG. 7 is a schematic flowchart of another example of a page storage method provided in an embodiment of the present application.
  • FIG8 is a schematic flowchart of a garbage collection method provided in an embodiment of the present application.
  • FIG. 9 is a schematic diagram of an example process of writing a page provided in an embodiment of the present application.
  • FIG. 10 is a schematic diagram of another example of a process of writing a page provided in an embodiment of the present application.
  • FIG. 11 is a schematic diagram of the effects of garbage collection under different strategies provided in an embodiment of the present application.
  • FIG. 12 is a schematic diagram of another example of the effect of garbage collection under different strategies provided in an embodiment of the present application.
  • FIG. 13 is a schematic diagram of the effect of garbage collection under different space utilizations provided in an embodiment of the present application.
  • FIG. 14 is a schematic diagram of the hardware structure of the device provided in an embodiment of the present application.
  • a and/or B can represent: A exists alone, A and B exist at the same time, and B exists 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.
  • references to "one embodiment” or “some embodiments” etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application.
  • the phrases “in one embodiment”, “in some embodiments”, “in some other embodiments”, “in some other embodiments”, etc. appearing in different places in this specification do not necessarily all refer to the same embodiment, but mean “one or more but not all embodiments", unless otherwise specifically emphasized in other ways.
  • the terms “including”, “comprising”, “having” and their variations all mean “including but not limited to”, unless otherwise specifically emphasized in other ways.
  • the electronic device may be a portable electronic device that also includes other functions such as a personal digital assistant and/or a music player, such as a mobile phone, a tablet computer, a wearable electronic device with wireless communication functions (such as a smart watch), etc.
  • portable electronic devices include but are not limited to devices equipped with Or a portable electronic device with other operating systems.
  • the portable electronic device may also be other portable electronic devices, such as a laptop computer, etc. It should also be understood that in some other embodiments, the electronic device may not be a portable electronic device, but a desktop computer.
  • FIG1 shows a schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
  • SIM subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100.
  • the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently.
  • the components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural-network processing unit (NPU), etc.
  • AP application processor
  • GPU graphics processor
  • ISP image signal processor
  • controller a memory
  • video codec a digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • Different processing units may be independent devices or integrated in one or more processors.
  • 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.
  • the processor 110 may also be provided with a memory for storing instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
  • the processor 110 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 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, etc.
  • I2C inter-integrated circuit
  • I2S inter-integrated circuit sound
  • PCM pulse code modulation
  • UART universal asynchronous receiver/transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL).
  • SDA serial data line
  • SCL serial clock line
  • the I2S interface can be used for audio communication.
  • the processor 110 can include multiple I2S buses.
  • the processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170.
  • the PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals.
  • the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface.
  • the UART interface is a universal serial data bus for asynchronous communication.
  • the bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication.
  • the UART interface is generally used to connect the processor 110 and the wireless communication module 160.
  • the MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193.
  • the GPIO interface can be configured by software.
  • the GPIO interface can be configured as a control signal or a data signal.
  • the GPIO interface can be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc.
  • the USB interface 130 is an interface that complies with USB standard specifications, and may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc.
  • the USB interface 130 may be used to connect a charger to charge the electronic device 100, and may also be used to transmit data between the electronic device 100 and a peripheral device.
  • the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100.
  • the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
  • the charging management module 140 is used to receive charging input from a charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 140 may receive charging input from a wired charger through the USB interface 130.
  • the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
  • the power management module 141 is used to connect the battery 142 , the charging management module 140 and the processor 110 .
  • the wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
  • the mobile communication module 150 can provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 .
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
  • the demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194.
  • the modem processor may be an independent device.
  • the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide wireless communication solutions for application in the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.
  • WLAN wireless local area networks
  • Wi-Fi wireless fidelity
  • BT Bluetooth
  • GNSS global navigation satellite system
  • FM frequency modulation
  • NFC near field communication technology
  • IR infrared technology
  • antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with the network and other devices through wireless communication technology.
  • the electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor.
  • the GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • the processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
  • the display screen 194 is used to display images, videos, etc.
  • the display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (liquid)
  • the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.
  • the display screen 194 may also be integrated with a touch function, which may also be called a touch screen.
  • the electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
  • the external memory interface 120 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.
  • an external memory card such as a Micro SD card
  • the internal memory 121 may be used to store computer executable program codes, which include instructions.
  • the processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121 .
  • the electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
  • the audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals.
  • the speaker 170A also called “speaker”, is used to convert audio electrical signals into sound signals.
  • the receiver 170B also called “earpiece”, is used to convert audio electrical signals into sound signals.
  • the microphone 170C also called “microphone”, “microphone”, is used to convert sound signals into electrical signals.
  • the headphone interface 170D is used to connect wired headphones.
  • the pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal.
  • the pressure sensor 180A can be set on the display screen 194.
  • the gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100.
  • the air pressure sensor 180C is used to measure the air pressure.
  • the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.
  • the acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes).
  • the distance sensor 180F is used to measure the distance.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the touch sensor 180K is also called a "touch panel".
  • the touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen”.
  • the bone conduction sensor 180M can obtain a vibration signal.
  • the bone conduction sensor 180M can obtain a vibration signal of a vibrating bone block of the human vocal part.
  • the bone conduction sensor 180M can also contact the human pulse and receive blood pressure beat signals.
  • the buttons 190 include a power button, a volume button, etc.
  • the motor 191 can generate a vibration prompt.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging status, power change, messages, missed calls, notifications, etc.
  • the SIM card interface 195 is used to connect a SIM card.
  • FIG2 is a software structure diagram of the electronic device 100 of an embodiment of the present application.
  • the layered architecture divides the software into several layers, each layer has a clear role and division of labor.
  • the layers communicate with each other through software interfaces.
  • the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer.
  • the application layer can include a series of application packages.
  • the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, APP1, and APP2.
  • applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, APP1, and APP2.
  • the application framework layer provides application programming interface (API) and programming framework for the applications in the application layer.
  • API application programming interface
  • the application framework layer includes some predefined functions.
  • the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.
  • the window manager is used to manage window programs.
  • the window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
  • Content providers are used to store and retrieve data and make it accessible to applications.
  • This data can include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
  • the view system includes visual controls, such as controls for displaying text, controls for displaying images, etc.
  • the view system can be used to build applications.
  • a display interface can be composed of one or more views.
  • a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
  • the phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).
  • the resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
  • the notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc.
  • the notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
  • Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
  • the core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
  • the application layer and the application framework layer run in a virtual machine.
  • the virtual machine executes the Java files of the application layer and the application framework layer as binary files.
  • the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
  • the system library can include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
  • functional modules such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
  • the surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing.
  • a 2D graphics engine is a drawing engine for 2D drawings.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer can include display drivers, camera drivers, audio drivers, and sensor drivers.
  • the electronic device in the embodiments of the present application may also be an electronic device installed with an operating system such as Windows, Linux, Android, Hongmeng or Apple.
  • FIG3 is a schematic diagram of the structure of a flash memory applicable to an embodiment of the present application.
  • a square filled with white may represent an erase block, and a square filled with a dot pattern may represent a data page.
  • the entire storage space of the flash memory device is divided into a plurality of erase blocks, and each erase block may store a plurality of data pages.
  • the data page is usually written to the free position of the erase block in an append write manner.
  • garbage collection may be required for some of the erase blocks therein. That is, garbage collection is performed in units of erase blocks, and free space is released by erasing the entire erase block.
  • FIG. 4 is a schematic diagram of garbage collection applicable to an embodiment of the present application, wherein a square filled with a diagonal pattern may represent a garbage page, a square filled with a dot pattern may represent a valid page, and a square filled with a grid pattern may represent an idle page or idle space.
  • the bare flash file system is a file system for the onboard NAND bare flash chip on the embedded system, such as UBIFS, YAFFS2, JFFS and other bare flash file systems.
  • Data pages can be written into the erase block in a log structure.
  • a remote update strategy can be adopted.
  • the bare flash file system will write the new data page to a new erase block, and by modifying the index pointer corresponding to the data page, replace the old page with the page containing the new data, making the page containing the old data invalid.
  • the page containing new data is marked as a valid page, and the page containing old data is marked as a garbage page.
  • the garbage page can also be called a dirty page or an invalid page.
  • the garbage page becomes a free page after garbage collection, and data can be rewritten.
  • pages and data pages may also be referred to as data blocks
  • valid pages may also be referred to as valid data
  • junk pages may also be referred to as invalid data.
  • Garbage collection efficiency is defined as the ratio of the number of garbage pages to the total number of default pages in the erase block. The higher the garbage collection efficiency, the more garbage pages there are in the erase block, which means that fewer valid pages need to be moved each time garbage collection occurs, and the faster the garbage collection process. In addition, a higher garbage collection efficiency also means fewer erase times and a longer flash life. If the garbage collection efficiency is low, it may also lead to This leads to a serious write amplification problem.
  • Write amplification also known as write amplification, is an undesirable phenomenon in flash memory and solid-state drives (SSDs), where the actual amount of physical data written is multiple times the amount of data written.
  • pages of different temperatures are placed in different erase blocks by separating hot and cold data pages.
  • data pages can be divided into hot pages and cold pages according to the access frequency, and hot pages are concentrated in hot erase blocks, and cold pages are concentrated in cold erase blocks, so that hot erase blocks have a higher proportion of garbage pages than cold erase blocks.
  • the file system triggers garbage collection, it often selects the erase block with the most garbage pages.
  • this selection strategy will make the number of garbage pages in the selected target erase block decrease, and the garbage collection efficiency will decrease. Even if the hot and cold separation of data pages is used, the garbage collection efficiency will decrease rapidly.
  • the existing hot and cold separation methods have problems such as high resource overhead, inaccurate heat level classification, and inability to quickly identify hot spot changes.
  • the least recently used page replacement algorithm (LRU) and the least frequently used page replacement algorithm (LFU) need to maintain heat management metadata for all pages in the file system, which takes up a lot of memory.
  • LFU a method based on access frequency sorting, when faced with changes in data set hot spots, data pages with a high historical cumulative access frequency will still be considered hot pages for a period of time in the future, resulting in a certain lag in identifying page heat changes.
  • FIG5 is a schematic diagram of the reuse distance of a data page in an embodiment of the present application.
  • the number of file system write operations between two consecutive updates of a data page in the file system is defined as the reuse distance of the data page.
  • the horizontal axis represents the write sequence number of the file system, and the vertical axis represents the heat of the page.
  • the file system may perform write operations on other pages, and the number of times the file system performs write operations on other pages is taken as the reuse distance of the page.
  • each time a page is written the write sequence number of the page is recorded, and when the page is written again, a reuse distance of the page can be obtained based on the write sequence numbers when the page is written twice.
  • the file system performs 5 write operations on other pages, and the reuse distance between the first update and the second update of page 501 is 5; between the first update and the second update of page 502, the file system performs 11 write operations on other pages, and the reuse distance between the first update and the second update of page 502 is 11; between the first update and the second update of page 503, the file system performs 100 write operations on other pages, and the reuse distance between the first update and the second update of page 503 is 100.
  • the average reuse distance between two adjacent updates of page 501 is the shortest
  • the average reuse distance between two adjacent updates of page 502 is in the middle
  • the average reuse distance between two adjacent updates of page 503 is the longest.
  • Page 501 has the highest heat
  • page 502 has the second highest heat
  • page 503 has the lowest heat.
  • a page with a shorter reuse distance has a higher frequency of page updates, that is, the page has a higher popularity.
  • a page with a longer reuse distance has a lower frequency of page updates, that is, the page has a lower popularity.
  • FIG6 is a schematic flow chart of a method 600 provided in an embodiment of the present application.
  • the method 600 is mainly used for classifying the heat levels when flash memory data is stored in a classified manner.
  • the method 600 may include the following steps:
  • a data set of multiple page reuse distances can be divided into multiple subsets by a clustering method, so that the difference in reuse distance of each subset is maximized.
  • the user or the system can preset the number of subsets, that is, the number of heat levels, such as two groups of cold and hot, or three groups of cold, warm, and hot. In other words, the user or the system can predetermine at least two heat levels, and then determine the range of reuse distances corresponding to each heat level by a clustering method.
  • each subset corresponds to a range of reuse distances and also corresponds to a heat level.
  • the UBIFS file system performs 16,000 write operations.
  • the reuse intervals of the pages written the most recently for 16,000 times are clustered.
  • the reuse distances of the pages written the most recently for 16,000 times are clustered.
  • the number of heat levels is specified as 3
  • the pages with a reuse distance less than 3,500 times are classified as hot pages; the pages with a reuse distance between 3,500 and 11,000 times are classified as warm pages, and the pages with a reuse distance greater than 11,000 times are classified as cold pages.
  • the clustering method may use, for example, the K-means clustering algorithm (K-Means) and the natural breakpoint method (natural breaks).
  • K-Means K-means clustering algorithm
  • natural breakpoint method natural breaks
  • step S620 is performed again at intervals of the first time period. That is, the embodiment of the present application can regularly update the range of reuse distances corresponding to each heat level.
  • the system and the user can preset the range of reuse distances corresponding to each heat level.
  • the user can estimate the range of reuse distances corresponding to each heat level based on experience or experimental conclusions. For example, pages with a reuse distance of less than 4,000 times are classified as hot pages; pages with a reuse distance between 4,000 and 10,000 times are classified as warm pages; and pages with a reuse distance greater than 10,000 times are classified as cold pages.
  • the heat levels may be divided in other ways, and the heat level to which the data page belongs may be determined.
  • the heat levels may be divided and the heat levels of the data pages may be determined according to the number of times the data pages are updated within a unit time.
  • a data page whose number of updates per unit time is less than a first threshold is a cold page
  • a data page whose number of updates per unit time is greater than or equal to the first threshold and less than or equal to a second threshold is a warm page
  • a data page whose number of updates per unit time is greater than the second threshold is a hot page.
  • the heat level may be divided and the heat level of the data page may be determined according to the historical accumulated access (update) frequency of the data page.
  • a data page whose historical accumulated access frequency is greater than a first threshold is a hot page; and a data page whose historical accumulated access frequency is less than the first threshold is a cold page.
  • the heat level of the data page may be determined according to the number of write operations performed on the data page in the most recent N operations of the file system.
  • a certain page is written M times, and the heat of the page is M/N.
  • the heat is greater than a first threshold, the page is a hot page; when the heat is less than the first threshold, the page is a cold page.
  • a corresponding erase block set may be allocated to each of the at least two thermal levels.
  • each thermal level may correspond to an erase block set, and each erase block set may include one or more erase blocks.
  • the number of erase blocks corresponding to each heat level can be determined based on the distribution of the number of pages of each heat level in the first time period. For example, in the first time period, the number of pages of the first heat level is the largest, so the number of erase blocks corresponding to the first heat level is the largest; the number of pages of the second heat level is the smallest, so the number of erase blocks corresponding to the second heat level is the smallest.
  • the erase block that once corresponded to other thermal levels other than the first thermal level is preferentially selected. For example, if the first erase block once corresponded to a cold page, the first erase block is preferentially selected when determining the erase block corresponding to the hot page.
  • the erase blocks in the erase block set corresponding to each thermal level are used to store pages of the thermal level.
  • the erase blocks in the erase block set corresponding to the first thermal level are used to store pages of the first thermal level.
  • the hot erase blocks in the hot erase block set are used to store hot pages
  • the cold erase blocks in the cold erase block set are used to store cold pages.
  • FIG7 is a schematic flow chart of a method 700 provided in an embodiment of the present application.
  • the method 700 is mainly used to store written pages into erase blocks of corresponding thermal levels.
  • the method 700 may include the following steps:
  • the second page is any page that needs to be written or updated.
  • the first reuse distance is the reuse distance of the second page in the second time period.
  • the second page may be updated multiple times, that is, the number of the first reuse distances may be multiple.
  • the second reuse distance is the number of times the file system performs write operations on other pages between the current time and the time when the second page is next updated.
  • time series forecasting also known as time series forecasting, is a process of predicting the historical value changes of a certain indicator. Predict its value in the future.
  • the historical data exponential smoothing method is similar to it, both of which predict the value of the indicator in the future based on historical data.
  • S720 Determine the heat level to which the second page belongs according to the second reuse distance and the range of the reuse distance corresponding to each heat level.
  • the second reuse distance is within a range of reuse distances corresponding to a certain heat level, it is determined that the second page belongs to the heat level.
  • the second page is determined to be at the first heat level, or the second page is determined to be a hot page.
  • a corresponding erase block set is determined for each thermal level, or a corresponding erase block is determined for each thermal level.
  • S730 when writing the second page, it is possible to first check whether there is enough space in the erase block corresponding to the thermal level to which the second page belongs to store the second page, and if so, write the second page in the erase block.
  • the second page belongs to the first heat level
  • the first heat level corresponds to the first erase block set
  • the first erase block set includes the first erase block
  • when writing the second page the erase blocks in the first erase block set are traversed, and if it is found that the first erase block has sufficient space, the second page is written to the first erase block.
  • a garbage collection operation may be triggered to erase the target erase block and write the second page into the target erase block.
  • the target erase block is added to the erase block set corresponding to the thermal level to which the second page belongs.
  • FIG8 is a schematic flow chart of a method 800 provided in an embodiment of the present application.
  • the method 800 is mainly used to determine a target erase block for garbage collection.
  • the method 800 includes:
  • S810 Obtain a first score according to the number of garbage pages in the first erase block and the growth rate of garbage pages in the second erase block.
  • S820 Obtain a second score according to the number of garbage pages in the second erase block and the growth rate of garbage pages in the first erase block.
  • Score(EB i ) represents the score of erase block EB i
  • Garbage(EB i ) represents the number of garbage pages of erase block EB i
  • V(EB j ) represents the growth rate of garbage pages of erase block EB j
  • the increase in the number of garbage pages in the erase block is P
  • the growth rate of the garbage pages in the erase block is P/N.
  • the growth rate of garbage pages in an erase block is: the number of garbage pages added in the erase block per unit time.
  • the number of garbage pages in the erase block at a first moment is recorded, and then the number of garbage pages in the erase block at a second moment is recorded, and the growth rate of the garbage pages in the erase block can be calculated.
  • the growth rate of garbage pages in an erase block is: the number of increased garbage pages in the erase block in the most recent N write operations of the file system.
  • the number of garbage pages in the erase block when the file system writes for the first time (or the Xth time, where X is a positive integer greater than or equal to zero) is recorded, and then the number of garbage pages in the erase block when the file system writes for the Nth time (N is a positive integer greater than X) is recorded, and the growth rate of the garbage pages in the erase block can be calculated.
  • the growth rate of garbage pages in a certain erase block can be calculated multiple times, and the average value, weighted average, historical data exponential smoothing algorithm, etc. can be used as the real growth rate of garbage pages in the erase block.
  • the erase block with the fastest growth rate of garbage pages will not necessarily be the object of garbage collection.
  • a large number of garbage pages may be accumulated in the erase block with the fastest growth rate of garbage pages, so that the erase block is garbage collected.
  • the efficiency of garbage collection is higher, thereby improving the efficiency of garbage collection.
  • the efficiency of garbage collection is higher, the write amplification factor is reduced, and the number of flash memory erases is reduced, which is beneficial to improving the service life of the flash memory.
  • the number of garbage pages of each erase block in the candidate erase block set is recorded as Garbage(CEB i )
  • the growth rate of garbage pages of each erase block is recorded as V(CEB i )
  • each erase block in the candidate erase block set is scored according to the following formula, and the erase block with the largest score is garbage collected.
  • Score(CEB i ) max ⁇ Garbage(CEB i ) ⁇ (1+V(CEB j )) ⁇
  • Score(CEB i ) represents the score of erase block CEB i
  • Garbage(CEB i ) represents the number of garbage pages of erase block CEB i
  • V(CEB j ) represents the growth rate of garbage pages of erase block CEB j
  • CEB i ⁇ CEB, CEB j ⁇ CEB CEB j ⁇ CEB i , i ⁇ q, j ⁇ q.
  • the erase blocks corresponding to each heat level store pages of the corresponding heat level. Since the pages of each heat level are updated at different frequencies, the growth rate of garbage pages in the erase blocks corresponding to each heat level is also different, and can even be clearly distinguished.
  • the erase block with the fastest growth rate of garbage pages will not necessarily be the object of garbage collection.
  • a large number of garbage pages may be accumulated in the erase block with the fastest growth rate of garbage pages, so that the efficiency of garbage collection of the erase block is higher, thereby improving the efficiency of garbage collection.
  • the efficiency of garbage collection is higher, the write amplification factor is reduced, and the number of flash memory erases is reduced, which is beneficial to improving the service life of the flash memory.
  • the erase blocks are classified according to the heat level, the number of erase blocks in the candidate erase block set is small, and the speed of determining the target erase block for garbage collection is faster, which is beneficial to improving the speed of garbage collection.
  • valid pages in the first erase block may be extracted first, and the valid pages may be written into the third erase block, and all pages in the first erase block may be erased.
  • valid pages in the first erase block may be first extracted, and the valid pages may be loaded into other storage spaces, and all pages in the first erase block may be erased.
  • the third page that needs to be written or updated may be written into the first erase block. If the third page belongs to the third heat level, the first erase block is added to the erase block set corresponding to the third heat level.
  • garbage collection can be performed at any time, and is not limited to when there is insufficient space in the flash memory or the erase block. For example, garbage collection can also be performed when the file system is idle.
  • FIG. 9 is a schematic diagram of the process of writing a page to a file system according to an embodiment of the present application.
  • the file system When writing the fourth page, the file system first searches for the meta information of the page according to the index. If the fourth page has no index, an index is created, the write sequence number of the fourth page is recorded, and the future reuse distance of the fourth page is reset to -1.
  • the fourth page may be any page that needs to be written or updated.
  • S902 predicting the future reuse distance of the fourth page according to the information related to the reuse distance in the meta information.
  • step S902 reference may be made to the relevant description of step S710, which will not be repeated here for the sake of brevity.
  • S903 Determine the popularity level of the fourth page according to the future reuse distance of the fourth page.
  • step S903 reference may be made to the relevant description of step S720, which will not be repeated here for the sake of brevity.
  • the fourth page can be a page of any popularity level, and the present application does not limit the popularity level of the fourth page.
  • the file system Since the file system writes pages into the erase block of the flash memory in a log structured manner, and the fourth page is a hot page, when writing the fourth page, it is first determined whether the erase block corresponding to the hot log header has enough space.
  • the number is recorded in the file system page index structure. According to the mapping relationship between the page logical address and the physical position, that is, the file pointer of the fourth page is pointed to the erase block written in step S905.
  • step S907 and step S908 the process returns to step S904.
  • the garbage collection method provided in the embodiment of the present application can be used to perform garbage collection.
  • the erase block with the largest number of garbage pages in the erase block set corresponding to each heat level can be selected to form a candidate erase block set, and then each erase block in the candidate erase block is scored, and the erase block with the highest score is selected as the target erase block, and garbage collection is performed. After all data pages of the target erase block are erased, the erase block corresponding to the hot log header is switched to the target erase block.
  • step S907 and step S909 the process returns to step S904.
  • Fig. 10 is a schematic diagram of the process of writing pages provided by an embodiment of the present application. Referring to Fig. 10, when the fifth page needs to be written or updated, the reuse distance between the time of the fifth page being updated this time and the time of the last update is recorded and transmitted to the heat level classification module.
  • the heat level division module can periodically divide the heat levels and determine the range of reuse distances corresponding to each heat level. For example, the heat level division module clusters the reuse distances of multiple pages written in the first time period every first time period to obtain at least two groups of reuse distance ranges, and each group of reuse distance ranges corresponds to a heat level.
  • the reuse distance prediction module can predict the future reuse distance of the fifth page according to one or more historical reuse distances of the fifth page, that is, predict how many write operations the file system may perform between the current update and the next update of the fifth page.
  • the heat level of the fifth page can be determined, and the fifth page is written into an erase block with sufficient space in the erase block set of the corresponding heat level. For example, if the fifth page is a cold page, the fifth page is written into a cold erase block.
  • the target erase block selection module will select the target erase block for garbage collection operation.
  • the target erase block can be selected by the method of the embodiment shown in Figure 8. For brevity, it will not be repeated here. After garbage collection is performed on the target erase block, the fifth page is written into the target erase block.
  • the target erase block is added to an erase block set corresponding to the thermal level to which the fifth page belongs.
  • FIG11 is a schematic diagram of the effect of garbage collection under different strategies provided in an embodiment of the present application.
  • FIG12 is a schematic diagram of the effect of garbage collection under another different strategy provided in an embodiment of the present application.
  • FIG11 and FIG12 respectively show the results of write-only tests on UBIFS file systems of 64MB and 128MB space sizes.
  • the solution provided in the embodiment of the present application is to fill in black patterns; to fill in white patterns means that there is no heat level division, and the garbage collection strategy is a greedy strategy, that is, the erase block with the largest number of garbage pages is always selected for garbage collection; to fill in left-slash patterns means that heat levels are divided, and the garbage collection strategy is a greedy strategy; to fill in right-slash patterns means that heat levels are divided, and the garbage collection strategy is a trade-off strategy.
  • the write amplification factor is reduced by 9% to 16%
  • the garbage collection efficiency is improved by 10% to 19%
  • the number of flash memory erase times is reduced by 10% to 17%.
  • FIG13 is a schematic diagram of the effect of garbage collection under different space utilizations provided by an embodiment of the present application.
  • the solution of the present application and the traditional solution are implemented on the UBIFS file system.
  • the solution of the present application (dashed line in the figure) has different degrees of performance optimization compared with the traditional solution (solid line in the figure).
  • the space utilization increases, the write amplification of the two file systems becomes more serious, the efficiency of garbage collection decreases, and the number of erasures increases.
  • the solution of the present application has an optimization effect compared with the traditional solution under different file system space utilizations.
  • method 600, method 700, and method 800 may be used in combination or independently.
  • method 600 and method 700 may be used to implement the classification of heat levels and the classified storage of flash memory data, and other methods may be used to determine the objects for garbage collection. (target erase block); or, using other methods to implement the division of thermal levels and classified storage of flash memory data, and using method 800 to determine the object of garbage collection (target erase block); or, using method 600 or method 700 to implement the division of thermal levels and classified storage of flash memory data, and using method 800 to determine the object of garbage collection (target erase block).
  • FIG14 is a schematic diagram of the hardware structure of the device 1400 provided in an embodiment of the present application.
  • the device 1400 shown in FIG14 (the device 1400 may be an electronic device) includes a memory 1410, a processor 1420, a communication interface 1430, and a bus 1440.
  • the memory 1410, the processor 1420, and the communication interface 1430 are connected to each other through the bus 1440.
  • the memory 1410 may be a ROM, a static storage device, a dynamic storage device or a RAM.
  • the memory 1410 may store a program. When the program stored in the memory 1410 is executed by the processor 1420, the processor 1420 is used to execute the various steps of the garbage collection method and the page storage method of the embodiment of the present application.
  • Processor 1420 can adopt a general-purpose CPU, microprocessor, ASIC, GPU or one or more integrated circuits to execute relevant programs to implement the functions required to be performed by the units in the device 1400 of the embodiment of the present application, or to execute the garbage collection method and page storage method of the method embodiment of the present application.
  • the processor 1420 may also be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the garbage collection method and the page storage method of the present application may be completed by an integrated logic circuit of hardware or software instructions in the processor 1420.
  • the above-mentioned processor 1420 may also be a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
  • the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in a decoding processor.
  • the software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc.
  • the storage medium is located in the memory 1410, and the processor 1420 reads the information in the memory 1410, and combines its hardware to complete the functions required to be performed by the units included in the device 1400 of the embodiment of the present application, or executes the garbage collection method and page storage method of the method embodiment of the present application.
  • the communication interface 1430 uses a transceiver device such as but not limited to a transceiver to implement communication between the apparatus 1400 and other devices or a communication network.
  • a transceiver device such as but not limited to a transceiver to implement communication between the apparatus 1400 and other devices or a communication network.
  • the bus 1440 may include a path for transmitting information between the various components of the device 1400 (eg, the memory 1410 , the processor 1420 , and the communication interface 1430 ).
  • the device 1400 shown in FIG. 14 only shows a memory, a processor, and a communication interface, in the specific implementation process, those skilled in the art should understand that the device 1400 also includes other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the device 1400 may also include hardware devices for implementing other additional functions. In addition, those skilled in the art should understand that the device 1400 may also only include the devices necessary for implementing the embodiments of the present application, and does not necessarily include all the devices shown in FIG. 14.
  • An embodiment of the present application also provides a chip, which includes a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the garbage collection method and the page storage method described in any possible implementation method in the foregoing text are executed.
  • This embodiment further provides a computer-readable storage medium, in which computer instructions are stored.
  • the garbage collection method and the page storage method in the above embodiments are executed.
  • This embodiment also provides a computer program product.
  • the computer program product runs on a computer, it enables the computer to execute the above-mentioned related steps, so that the garbage collection method and the page storage method in the above-mentioned embodiment are executed.
  • the electronic device can be divided into functional modules according to the above method example.
  • each functional module can be divided into Each functional module may also integrate two or more functions into one processing module.
  • the above integrated modules may be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
  • the disclosed systems, devices and methods can be implemented in other ways.
  • the device embodiments described above are only schematic.
  • the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
  • Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.
  • the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application provides a garbage collection method, a page storage method, and an electronic device. The garbage collection method comprises: obtaining a first score according to the number of garbage pages in a first erase block and an increase rate of the number of garbage pages in a second erase block; obtaining a second score according to the number of the garbage pages in the second erase block and an increase rate of the number of the garbage pages in the first erase block; and when the first score is greater than the second score, performing garbage collection on the first erase block. On the basis of the described solution, the garbage collection efficiency for a flash memory is improved, the garbage collection speed is increased, the write amplification coefficient is reduced, the number of flash memory erasures is decreased, and the service life of the flash memory is prolonged.

Description

垃圾回收的方法、页面存储的方法和电子设备Garbage collection method, page storage method and electronic device
本申请要求于2022年10月28日提交中国专利局、申请号为202211337526.X、申请名称为“垃圾回收的方法、页面存储的方法和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the China Patent Office on October 28, 2022, with application number 202211337526.X and application name “Garbage Recovery Method, Page Storage Method and Electronic Device”, the entire contents of which are incorporated by reference in this application.
技术领域Technical Field
本申请涉及电子设备领域,并且更加具体地,涉及一种垃圾回收的方法、页面存储的方法和电子设备。The present application relates to the field of electronic devices, and more specifically, to a garbage collection method, a page storage method and an electronic device.
背景技术Background technique
闪存是一种电可擦除可编程只读存储器(Electrically Erasable ProgrammableRead Only Memory,EEPROM)。Flash memory is an electrically erasable programmable read-only memory (EEPROM).
闪存的存储空间被划分为许多个擦除块(erase block),每个擦除块包含若干个数据页面,新的数据页面可以以追加写的方式写入擦除块的空闲位置。然而当闪存空间被写满时,需要对闪存的某些擦除块执行垃圾回收(garbage collection,GC)操作。在进行垃圾回收时,只能通过擦除整个擦除块的方式释放出空闲空间,即清除擦除块中的垃圾页面,然后将擦除块中的有效页面和新的数据页面一起写入新的擦除块中。The storage space of flash memory is divided into many erase blocks, each of which contains several data pages. New data pages can be written to the free positions of the erase blocks in an append-write manner. However, when the flash memory space is full, garbage collection (GC) operations need to be performed on some erase blocks of the flash memory. When performing garbage collection, free space can only be released by erasing the entire erase block, that is, clearing the garbage pages in the erase block, and then writing the valid pages in the erase block and the new data pages into the new erase block together.
垃圾回收效率是指被擦除的擦除块中垃圾页面所占的比例。垃圾回收效率越高,则需要写入的有效页面越少,则垃圾回收操作执行速度更快,并且擦除次数越少,闪存的使用寿命越长。Garbage collection efficiency refers to the proportion of garbage pages in the erased erase block. The higher the garbage collection efficiency, the fewer valid pages need to be written, the faster the garbage collection operation is performed, and the fewer the number of erases, the longer the service life of the flash memory.
因此,如何提升闪存的垃圾回收的效率是目前亟需解决的问题。Therefore, how to improve the efficiency of garbage collection of flash memory is a problem that needs to be solved urgently.
发明内容Summary of the invention
本申请实施例提供一种垃圾回收的方法、页面存储的方法和电子设备,有利于提升闪存垃圾回收的效率,提升垃圾回收的速度以及延长闪存的使用寿命。The embodiments of the present application provide a garbage collection method, a page storage method and an electronic device, which are beneficial to improving the efficiency of flash memory garbage collection, increasing the speed of garbage collection and extending the service life of the flash memory.
第一方面,提供了一种垃圾回收的方法,该方法包括:根据第一擦除块中的垃圾页面的数量,以及第二擦除块中的垃圾页面的增速,得到第一分数;根据所述第二擦除块中的垃圾页面的数量,以及所述第一擦除块中的垃圾页面的增速,得到第二分数;在所述第一分数大于所述第二分数的情况下,对所述第一擦除块进行垃圾回收。In a first aspect, a method for garbage collection is provided, the method comprising: obtaining a first score based on the number of garbage pages in a first erase block and a growth rate of garbage pages in a second erase block; obtaining a second score based on the number of garbage pages in the second erase block and a growth rate of garbage pages in the first erase block; and performing garbage collection on the first erase block when the first score is greater than the second score.
应理解,第一擦除块和第二擦除块是闪存中任意两个不同的擦除块。It should be understood that the first erase block and the second erase block are any two different erase blocks in the flash memory.
基于上述方案,基于上述方案,垃圾页面的增速最大的擦除块将不一定被作为垃圾回收的对象,这样,在下一次垃圾回收时,该垃圾页面的增速最大的擦除块中可能积累了数量较多的垃圾页面,从而该擦除块被垃圾回收时的效率较高,进而提升垃圾回收的效率。另一方面,垃圾回收的效率较高,写放大系数得以减小,闪存擦除次数得以减少,有利于提升闪存的使用寿命。Based on the above scheme, the erase block with the fastest growth rate of garbage pages will not necessarily be the object of garbage collection. In this way, during the next garbage collection, a large number of garbage pages may be accumulated in the erase block with the fastest growth rate of garbage pages, so that the efficiency of garbage collection of the erase block is higher, thereby improving the efficiency of garbage collection. On the other hand, the efficiency of garbage collection is higher, the write amplification factor is reduced, and the number of flash memory erases is reduced, which is conducive to improving the service life of the flash memory.
结合第一方面,在一种可能的实现方式中,所述第一擦除块属于第一擦除块集合,所述第一擦除块为所述第一擦除块集合中垃圾页面的数量最大的擦除块,所述第一擦除块集合中的擦除块用于存储第一热度等级的页面,所述第二擦除块属于第二擦除块集合,所述第二擦除块为所述第二擦除块集合中垃圾页面的数量最大的擦除块,所述第二擦除块集合中的擦除块用于存储第二热度等级的页面,所述第一热度等级的页面更新的频次与所述第二热度等级的页面更新的频次不同。In combination with the first aspect, in a possible implementation, the first erase block belongs to a first erase block set, the first erase block is the erase block with the largest number of junk pages in the first erase block set, the erase blocks in the first erase block set are used to store pages of a first heat level, the second erase block belongs to a second erase block set, the second erase block is the erase block with the largest number of junk pages in the second erase block set, the erase blocks in the second erase block set are used to store pages of a second heat level, and the frequency of updating pages of the first heat level is different from the frequency of updating pages of the second heat level.
应理解,每个热度等级对应的擦除块中存储相应热度等级的页面。由于每个热度等级的页面更新的频次不同,每个热度等级对应的擦除块中的垃圾页面的增速也不相同,甚至可以具有明显区分。It should be understood that the erase blocks corresponding to each heat level store pages of the corresponding heat level. Since the pages of each heat level are updated at different frequencies, the growth rate of garbage pages in the erase blocks corresponding to each heat level is also different, and can even be clearly distinguished.
基于上述方案,垃圾页面的增速最大的擦除块将不一定被作为垃圾回收的对象,这样,在下一次垃圾回收时,该垃圾页面的增速最大的擦除块中可能积累了数量较多的垃圾页面,从而该擦除块被垃圾回收时的效率较高,进而提升垃圾回收的效率。另一方面,垃圾回收的效率较高,写放大系数得以 减小,闪存擦除次数得以减少,有利于提升闪存的使用寿命。并且,由于对擦除块按照热度等级进行了分类,需要计算分数的擦除块数量较少,确定垃圾回收的目标擦除块的速度较快,有利于提升垃圾回收的速度。Based on the above scheme, the erase block with the fastest growth rate of garbage pages will not necessarily be the object of garbage collection. In this way, during the next garbage collection, the erase block with the fastest growth rate of garbage pages may accumulate a large number of garbage pages, so that the efficiency of garbage collection of this erase block is higher, thereby improving the efficiency of garbage collection. On the other hand, the higher the efficiency of garbage collection, the higher the write amplification factor. The number of flash memory erases is reduced, which is beneficial to improving the service life of the flash memory. In addition, since the erase blocks are classified according to the heat level, the number of erase blocks that need to calculate the scores is small, and the speed of determining the target erase blocks for garbage collection is faster, which is beneficial to improving the speed of garbage collection.
结合第一方面,在一种可能的实现方式中,所述方法还包括:确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,所述重用距离为在第一页面相邻两次更新的时刻之间,对除所述第一页面外的其他页面进行的写操作的次数,所述至少两个热度等级包括所述第一热度等级和所述第二热度等级;确定所述每个热度等级对应的擦除块集合。In combination with the first aspect, in a possible implementation, the method also includes: determining at least two thermal levels, and a range of reuse distances corresponding to each of the at least two thermal levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent updates of the first page, the at least two thermal levels including the first thermal level and the second thermal level; determining a set of erase blocks corresponding to each thermal level.
应理解,第一页面为任意一个页面。擦除块集合包括一个或多个擦除块。It should be understood that the first page is any page. The erase block set includes one or more erase blocks.
应理解,每个热度等级与每个重用距离的范围一一对应。每个热度等级对应的重用距离的范围可以是用户或系统预设置的,也可以是根据历史重用距离的数据确定的。It should be understood that each heat level corresponds to each reuse distance range one by one. The reuse distance range corresponding to each heat level can be preset by the user or the system, or can be determined based on historical reuse distance data.
基于上述方案,采用基于重用距离划分页面的热度等级,能够更准确的量化热度等级的划分,有利于提高垃圾回收的效率。Based on the above solution, the heat level of the page is divided based on the reuse distance, which can more accurately quantify the division of heat levels and is conducive to improving the efficiency of garbage collection.
结合第一方面,在一种可能的实现方式中,所述确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,包括:获取在第一时间段内写入的多个页面的重用距离;通过对所述多个页面的重用距离进行聚类,确定所述每个热度等级对应的重用距离的范围。In combination with the first aspect, in a possible implementation, the determining of at least two heat levels, and the range of reuse distances corresponding to each of the at least two heat levels, includes: obtaining the reuse distances of multiple pages written within a first time period; and determining the range of reuse distances corresponding to each heat level by clustering the reuse distances of the multiple pages.
基于上述方案,可以根据在第一时间段内写入的多个页面的重用距离,划分热度等级对应的重用距离的范围。因而,热度等级的划分更加合理,以便于对闪存的数据进行分类存储,有利于提高垃圾回收的效率。另一方面,还能通过定期更新热度等级对应的重用距离的范围,从而可以反映闪存负载热点的变化。Based on the above scheme, the range of reuse distances corresponding to the heat level can be divided according to the reuse distances of multiple pages written in the first time period. Therefore, the division of heat levels is more reasonable, so as to facilitate the classified storage of data in the flash memory, which is conducive to improving the efficiency of garbage collection. On the other hand, the range of reuse distances corresponding to the heat level can also be regularly updated to reflect the changes in the flash memory load hotspot.
结合第一方面,在一种可能的实现方式中,所述方法还包括:根据第二页面在第二时间段内的一个或多个第一重用距离,预测所述第二页面的第二重用距离,所述第二重用距离用于指示所述第二页面在当前时刻和下一次更新的时刻之间,对除第二页面之外的其他页面进行写操作的次数;根据所述第二重用距离和所述每个热度等级对应的重用距离的范围,确定所述第二页面所属的热度等级;将所述第二页面写入所述第二页面所属的热度等级对应的擦除块集合中的擦除块。In combination with the first aspect, in a possible implementation, the method also includes: predicting a second reuse distance of the second page based on one or more first reuse distances of the second page within a second time period, the second reuse distance being used to indicate the number of write operations performed by the second page on pages other than the second page between the current moment and the next update moment; determining the thermal level to which the second page belongs based on the second reuse distance and the range of reuse distances corresponding to each thermal level; and writing the second page to an erase block in an erase block set corresponding to the thermal level to which the second page belongs.
应理解,当第二页面的第二重用距离在第一热度等级对应的重用距离的范围内时,该页面属于第一热度等级。It should be understood that when the second reuse distance of the second page is within the range of the reuse distance corresponding to the first heat level, the page belongs to the first heat level.
基于上述方案,可以对所有需要写入或需要更新的页面在热度等级上进行区分,从而写入对应热度等级的擦除块,进而使得不同热度等级对应的擦除块中的垃圾页面的增速有明显区分,有利于提高垃圾回收的效率。Based on the above scheme, all pages that need to be written or updated can be distinguished based on the heat level, so as to write into the erase blocks of the corresponding heat level, thereby making the growth rate of garbage pages in the erase blocks corresponding to different heat levels clearly distinguishable, which is conducive to improving the efficiency of garbage collection.
结合第一方面,在一种可能的实现方式中,所述对所述第一擦除块进行垃圾回收,包括:提取所述第一擦除块中的有效页面;将所述有效页面写入到第三擦除块中;擦除所述第一擦除块中的全部页面。In combination with the first aspect, in a possible implementation, the garbage collection of the first erase block includes: extracting valid pages in the first erase block; writing the valid pages into a third erase block; and erasing all pages in the first erase block.
结合第一方面,在一种可能的实现方式中,在对所述第一擦除块进行垃圾回收之后,所述方法还包括:将第三页面写入到所述第一擦除块中,所述第三页面属于第三热度等级;将所述第一擦除块添加到所述第三热度等级对应的擦除块集合中。In combination with the first aspect, in a possible implementation, after performing garbage collection on the first erase block, the method further includes: writing a third page into the first erase block, the third page belonging to a third heat level; adding the first erase block to an erase block set corresponding to the third heat level.
第二方面,提供了一种页面存储的方法,该方法包括:确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,所述重用距离为在第一页面相邻两次更新的时刻之间,对除所述第一页面外的其他页面进行的写操作的次数;In a second aspect, a method for storing pages is provided, the method comprising: determining at least two heat levels and a range of a reuse distance corresponding to each of the at least two heat levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent update moments of the first page;
确定所述每个热度等级对应的擦除块集合,所述擦除块集合包括第一擦除块集合,所述至少两个热度等级包括第一热度等级,所述第一擦除块集合中的擦除块用于存储所述第一热度等级的页面。An erase block set corresponding to each thermal level is determined, the erase block set includes a first erase block set, the at least two thermal levels include a first thermal level, and the erase blocks in the first erase block set are used to store pages of the first thermal level.
应理解,第一页面为任意一个页面。擦除块集合包括一个或多个擦除块。It should be understood that the first page is any page. The erase block set includes one or more erase blocks.
应理解,每个热度等级与每个重用距离的范围一一对应。每个热度等级对应的重用距离的范围可以是用户或系统预设置的,也可以是根据历史重用距离的数据确定的。It should be understood that each heat level corresponds to each reuse distance range one by one. The reuse distance range corresponding to each heat level can be preset by the user or the system, or can be determined based on historical reuse distance data.
基于上述方案,采用基于重用距离划分页面的热度等级,能够更准确的量化热度等级的划分,有利于提高垃圾回收的效率。结合第二方面,在一种可能的实现方式中,所述确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,包括:获取在第一时间段内写入的多个页面的重用距离;通过对所述多个页面的重用距离进行聚类,确定所述每个热度等级对应的 重用距离的范围。Based on the above scheme, the use of dividing the heat level of pages based on reuse distance can more accurately quantify the division of heat levels, which is conducive to improving the efficiency of garbage collection. In combination with the second aspect, in a possible implementation, the determination of at least two heat levels and the range of reuse distances corresponding to each of the at least two heat levels includes: obtaining the reuse distances of multiple pages written in a first time period; clustering the reuse distances of the multiple pages to determine the range of reuse distances corresponding to each heat level; The range of reuse distance.
基于上述方案,可以根据在第一时间段内写入的多个页面的重用距离,划分热度等级对应的重用距离的范围。因而,热度等级的划分更加合理,以便于对闪存的数据进行分类存储,有利于提高垃圾回收的效率。另一方面,还能通过定期更新热度等级对应的重用距离的范围,从而可以反映闪存负载热点的变化。Based on the above scheme, the range of reuse distances corresponding to the heat level can be divided according to the reuse distances of multiple pages written in the first time period. Therefore, the division of heat levels is more reasonable, so as to facilitate the classified storage of data in the flash memory, which is conducive to improving the efficiency of garbage collection. On the other hand, the range of reuse distances corresponding to the heat level can also be regularly updated to reflect the changes in the flash memory load hotspot.
结合第二方面,在一种可能的实现方式中,所述方法还包括:根据第二页面在第一时间段内的第一重用距离,预测所述第二页面的第二重用距离,所述第二重用距离用于指示所述第二页面在当前时刻和下一次更新的时刻之间,对第二页面之外的其他页面进行写操作的次数;根据所述第二重用距离和所述每个热度等级对应的重用距离的范围,确定所述第二页面属于第一热度等级;将所述第二页面写入所述第一擦除块集合中的擦除块。In combination with the second aspect, in a possible implementation, the method also includes: predicting a second reuse distance of the second page based on a first reuse distance of the second page within a first time period, the second reuse distance being used to indicate the number of times the second page performs write operations on pages other than the second page between the current moment and the next update moment; determining that the second page belongs to the first heat level based on the second reuse distance and the range of reuse distances corresponding to each heat level; and writing the second page to an erase block in the first erase block set.
应理解,当第二页面的第二重用距离在第一热度等级对应的重用距离的范围内时,该页面属于第一热度等级。It should be understood that when the second reuse distance of the second page is within the range of the reuse distance corresponding to the first heat level, the page belongs to the first heat level.
基于上述方案,可以对所有需要写入或需要更新的页面在热度等级上进行区分,从而写入对应热度等级的擦除块,进而使得不同热度等级对应的擦除块中的垃圾页面的增速有明显区分,有利于提高垃圾回收的效率。Based on the above scheme, all pages that need to be written or updated can be distinguished based on the heat level, so as to write into the erase blocks of the corresponding heat level, thereby making the growth rate of garbage pages in the erase blocks corresponding to different heat levels clearly distinguishable, which is conducive to improving the efficiency of garbage collection.
第三方面,提供了一种电子设备,所述电子设备包括:According to a third aspect, an electronic device is provided, the electronic device comprising:
一个或多个处理器;one or more processors;
一个或多个存储器;one or more memories;
所述一个或多个存储器存储有一个或多个计算机程序,所述一个或多个计算机程序包括指令,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The one or more memories store one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by the one or more processors, the electronic device performs the following steps:
根据第一擦除块中的垃圾页面的数量,以及第二擦除块中的垃圾页面的增速,得到第一分数;根据所述第二擦除块中的垃圾页面的数量,以及所述第一擦除块中的垃圾页面的增速,得到第二分数;在所述第一分数大于所述第二分数的情况下,对所述第一擦除块进行垃圾回收。A first score is obtained according to the number of garbage pages in a first erase block and a growth rate of garbage pages in a second erase block; a second score is obtained according to the number of garbage pages in the second erase block and a growth rate of garbage pages in the first erase block; and when the first score is greater than the second score, garbage collection is performed on the first erase block.
结合第三方面,在一种可能的实现方式中,所述第一擦除块属于第一擦除块集合,所述第一擦除块为所述第一擦除块集合中垃圾页面的数量最大的擦除块,所述第一擦除块集合中的擦除块用于存储第一热度等级的页面,所述第二擦除块属于第二擦除块集合,所述第二擦除块为所述第二擦除块集合中垃圾页面的数量最大的擦除块,所述第二擦除块集合中的擦除块用于存储第二热度等级的页面,所述第一热度等级的页面更新的频次与所述第二热度等级的页面更新的频次不同。In combination with the third aspect, in a possible implementation, the first erase block belongs to a first erase block set, the first erase block is the erase block with the largest number of junk pages in the first erase block set, and the erase blocks in the first erase block set are used to store pages of a first heat level, the second erase block belongs to a second erase block set, the second erase block is the erase block with the largest number of junk pages in the second erase block set, and the erase blocks in the second erase block set are used to store pages of a second heat level, and the frequency of updating pages of the first heat level is different from the frequency of updating pages of the second heat level.
结合第三方面,在一种可能的实现方式中,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,所述重用距离为在第一页面相邻两次更新的时刻之间,对除所述第一页面外的其他页面进行的写操作的次数,所述至少两个热度等级包括所述第一热度等级和所述第二热度等级;确定所述每个热度等级对应的擦除块集合。In combination with the third aspect, in a possible implementation, when the instruction is executed by the one or more processors, the electronic device performs the following steps: determine at least two thermal levels, and a range of reuse distances corresponding to each of the at least two thermal levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent updates of the first page, the at least two thermal levels including the first thermal level and the second thermal level; determine a set of erase blocks corresponding to each thermal level.
结合第三方面,在一种可能的实现方式中,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:获取在第一时间段内写入的多个页面的重用距离;通过对所述多个页面的重用距离进行聚类,确定所述每个热度等级对应的重用距离的范围。In combination with the third aspect, in one possible implementation, when the instruction is executed by the one or more processors, the electronic device performs the following steps: obtaining the reuse distances of multiple pages written within a first time period; and determining the range of the reuse distances corresponding to each heat level by clustering the reuse distances of the multiple pages.
结合第三方面,在一种可能的实现方式中,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:根据第二页面在第二时间段内的一个或多个第一重用距离,预测所述第二页面的第二重用距离,所述第二重用距离用于指示所述第二页面在当前时刻和下一次更新的时刻之间,对除第二页面之外的其他页面进行写操作的次数;根据所述第二重用距离和所述每个热度等级对应的重用距离的范围,确定所述第二页面所属的热度等级;将所述第二页面写入所述第二页面所属的热度等级对应的擦除块集合中的擦除块。In combination with the third aspect, in a possible implementation, when the instruction is executed by the one or more processors, the electronic device performs the following steps: predicting a second reuse distance of the second page based on one or more first reuse distances of the second page within a second time period, the second reuse distance being used to indicate the number of write operations performed by the second page on pages other than the second page between the current moment and the next update moment; determining the thermal level to which the second page belongs based on the second reuse distance and the range of reuse distances corresponding to each thermal level; and writing the second page to an erase block in an erase block set corresponding to the thermal level to which the second page belongs.
结合第三方面,在一种可能的实现方式中,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:提取所述第一擦除块中的有效页面;将所述有效页面写入到第三擦除块中;擦除所述第一擦除块中的全部页面。In combination with the third aspect, in one possible implementation, when the instruction is executed by the one or more processors, the electronic device performs the following steps: extracting valid pages in the first erase block; writing the valid pages into a third erase block; and erasing all pages in the first erase block.
结合第三方面,在一种可能的实现方式中,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:将第三页面写入到所述第一擦除块中,所述第三页面属于第三热度等级; 将所述第一擦除块添加到所述第三热度等级对应的擦除块集合中。In conjunction with the third aspect, in a possible implementation manner, when the instruction is executed by the one or more processors, the electronic device performs the following steps: writing a third page into the first erase block, the third page belonging to a third thermal level; The first erase block is added to an erase block set corresponding to the third thermal level.
第四方面,提供了一种电子设备,所述电子设备包括:In a fourth aspect, an electronic device is provided, the electronic device comprising:
一个或多个处理器;one or more processors;
一个或多个存储器;one or more memories;
所述一个或多个存储器存储有一个或多个计算机程序,所述一个或多个计算机程序包括指令,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,所述重用距离为在第一页面相邻两次更新的时刻之间,对除所述第一页面外的其他页面进行的写操作的次数;确定所述每个热度等级对应的擦除块集合,所述擦除块集合包括第一擦除块集合,所述至少两个热度等级包括第一热度等级,所述第一擦除块集合中的擦除块用于存储所述第一热度等级的页面。The one or more memories store one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by the one or more processors, the electronic device performs the following steps: determining at least two thermal levels and a range of reuse distances corresponding to each of the at least two thermal levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent updates of the first page; determining an erase block set corresponding to each thermal level, the erase block set including a first erase block set, the at least two thermal levels including the first thermal level, and the erase blocks in the first erase block set being used to store pages of the first thermal level.
结合第四方面,在一种可能的实现方式中,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:获取在第一时间段内写入的多个页面的重用距离;通过对所述多个页面的重用距离进行聚类,确定所述每个热度等级对应的重用距离的范围。In combination with the fourth aspect, in a possible implementation, when the instruction is executed by the one or more processors, the electronic device performs the following steps: obtaining the reuse distances of multiple pages written within a first time period; and determining the range of the reuse distances corresponding to each heat level by clustering the reuse distances of the multiple pages.
结合第四方面,在一种可能的实现方式中,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:根据第二页面在第一时间段内的第一重用距离,预测所述第二页面的第二重用距离,所述第二重用距离用于指示所述第二页面在当前时刻和下一次更新的时刻之间,对第二页面之外的其他页面进行写操作的次数;根据所述第二重用距离和所述每个热度等级对应的重用距离的范围,确定所述第二页面属于第一热度等级;将所述第二页面写入所述第一擦除块集合中的擦除块。In combination with the fourth aspect, in a possible implementation, when the instruction is executed by the one or more processors, the electronic device performs the following steps: predicting a second reuse distance of the second page based on the first reuse distance of the second page within the first time period, the second reuse distance being used to indicate the number of write operations performed by the second page on pages other than the second page between the current moment and the next update moment; determining that the second page belongs to the first heat level based on the second reuse distance and the range of reuse distances corresponding to each heat level; and writing the second page to an erase block in the first erase block set.
应理解,上述装置对应的具体实现方式以及有益效果在上述方法实施例中已经详细说明,具体可参考上述方法实施例,为了简洁,在此不再赘述。It should be understood that the specific implementation methods and beneficial effects corresponding to the above-mentioned devices have been described in detail in the above-mentioned method embodiments. For details, please refer to the above-mentioned method embodiments. For the sake of brevity, they will not be repeated here.
第五方面,提供了一种芯片,所述芯片包括处理器和通信接口,所述通信接口用于接收信号,并将所述信号传输至所述处理器,所述处理器处理所述信号,使得第一方面以及第一方面任一种可能的实现方式中所述的方法被执行,或使得第二方面以及第二方面任一种可能的实现方式中所述的方法被执行。In a fifth aspect, a chip is provided, comprising a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the method described in the first aspect and any possible implementation of the first aspect is executed, or the method described in the second aspect and any possible implementation of the second aspect is executed.
第六方面,提供了一种计算机可读存储介质,其特征在于,包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行第一方面以及第一方面任一种可能的实现方式中所述的方法,或者执行第二方面以及第二方面任一种可能的实现方式中所述的方法。In the sixth aspect, a computer-readable storage medium is provided, characterized in that it includes computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect and any possible implementation of the first aspect, or executes the method described in the second aspect and any possible implementation of the second aspect.
第七方面,提供了一种计算机程序产品,其特征在于,所述计算机程序产品包括:计算机程序代码,当所述计算机程序代码被运行时,实现第一方面以及第一方面任一种可能的实现方式中所述的方法,或者实现第二方面以及第二方面任一种可能的实现方式中所述的方法。In the seventh aspect, a computer program product is provided, characterized in that the computer program product includes: a computer program code, which, when executed, implements the method described in the first aspect and any possible implementation manner of the first aspect, or implements the method described in the second aspect and any possible implementation manner of the second aspect.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1是本实施例提供的一种电子设备的结构示意图。FIG1 is a schematic diagram of the structure of an electronic device provided by this embodiment.
图2是本申请实施例的电子设备的软件结构框图。FIG. 2 is a software structure block diagram of the electronic device according to an embodiment of the present application.
图3是适用于本申请实施例的闪存的结构的示意图。FIG. 3 is a schematic diagram of the structure of a flash memory applicable to an embodiment of the present application.
图4是适用于本申请实施例的垃圾回收的示意图。FIG. 4 is a schematic diagram of garbage collection applicable to an embodiment of the present application.
图5是本申请实施例的数据页面的重用距离的示意图。FIG. 5 is a schematic diagram of a reuse distance of a data page according to an embodiment of the present application.
图6是本申请实施例提供的一例页面存储的方法的示意性流程图。FIG. 6 is a schematic flowchart of a page storage method provided in an embodiment of the present application.
图7是本申请实施例提供的另一例页面存储的方法的示意性流程图。FIG. 7 is a schematic flowchart of another example of a page storage method provided in an embodiment of the present application.
图8是本申请实施例提供的垃圾回收的方法的示意性流程图。FIG8 is a schematic flowchart of a garbage collection method provided in an embodiment of the present application.
图9是本申请实施例提供的一例写入页面时的流程的示意图。FIG. 9 is a schematic diagram of an example process of writing a page provided in an embodiment of the present application.
图10是本申请实施例提供的另一例写入页面的流程的示意图。FIG. 10 is a schematic diagram of another example of a process of writing a page provided in an embodiment of the present application.
图11是本申请实施例提供的一例不同策略下垃圾回收的效果的示意图。FIG. 11 is a schematic diagram of the effects of garbage collection under different strategies provided in an embodiment of the present application.
图12是本申请实施例提供的另一例不同策略下垃圾回收的效果的示意图。FIG. 12 is a schematic diagram of another example of the effect of garbage collection under different strategies provided in an embodiment of the present application.
图13是本申请实施例提供的不同空间利用率下垃圾回收的效果的示意图。FIG. 13 is a schematic diagram of the effect of garbage collection under different space utilizations provided in an embodiment of the present application.
图14是本申请实施例提供的装置的硬件结构的示意图。 FIG. 14 is a schematic diagram of the hardware structure of the device provided in an embodiment of the present application.
具体实施方式Detailed ways
以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请以下各实施例中,“至少一个”、“一个或多个”是指一个、两个或两个以上。术语“和/或”,用于描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。The terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one, two or more. The term "and/or" is used to describe the association relationship of associated objects, indicating that three relationships may exist; for example, A and/or B can represent: A exists alone, A and B exist at the same time, and B exists alone, 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.
在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
以下介绍电子设备和用于使用这样的电子设备的实施例。在一些实施例中,电子设备可以是还包含其它功能诸如个人数字助理和/或音乐播放器功能的便携式电子设备,诸如手机、平板电脑、具备无线通讯功能的可穿戴电子设备(如智能手表)等。便携式电子设备的示例性实施例包括但不限于搭载或者其它操作系统的便携式电子设备。上述便携式电子设备也可以是其它便携式电子设备,诸如膝上型计算机(Laptop)等。还应当理解的是,在其他一些实施例中,上述电子设备也可以不是便携式电子设备,而是台式计算机。The following describes electronic devices and embodiments for using such electronic devices. In some embodiments, the electronic device may be a portable electronic device that also includes other functions such as a personal digital assistant and/or a music player, such as a mobile phone, a tablet computer, a wearable electronic device with wireless communication functions (such as a smart watch), etc. Exemplary embodiments of portable electronic devices include but are not limited to devices equipped with Or a portable electronic device with other operating systems. The portable electronic device may also be other portable electronic devices, such as a laptop computer, etc. It should also be understood that in some other embodiments, the electronic device may not be a portable electronic device, but a desktop computer.
示例性的,图1示出了本申请实施例提供的一例电子设备100的结构示意图。例如,如图1所示,电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。Exemplarily, FIG1 shows a schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application. For example, as shown in FIG1 , the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated in one or more processors.
其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。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.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从该存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART) 接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, the processor 110 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 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, etc.
其中,I2C接口是一种双向同步串行总线,包括一根串行数据线(serial data line,SDA)和一根串行时钟线(derail clock line,SCL)。Among them, the I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL).
I2S接口可以用于音频通信。在一些实施例中,处理器110可以包含多组I2S总线。处理器110可以通过I2S总线与音频模块170耦合,实现处理器110与音频模块170之间的通信。The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170.
PCM接口也可以用于音频通信,将模拟信号抽样,量化和编码。在一些实施例中,音频模块170与无线通信模块160可以通过PCM总线接口耦合。The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface.
UART接口是一种通用串行数据总线,用于异步通信。该总线可以为双向通信总线。它将要传输的数据在串行通信与并行通信之间转换。在一些实施例中,UART接口通常被用于连接处理器110与无线通信模块160。The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160.
MIPI接口可以被用于连接处理器110与显示屏194,摄像头193等外围器件。GPIO接口可以通过软件配置。The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The GPIO interface can be configured by software.
GPIO接口可以被配置为控制信号,也可被配置为数据信号。在一些实施例中,GPIO接口可以用于连接处理器110与摄像头193,显示屏194,无线通信模块160,音频模块170,传感器模块180等。The GPIO interface can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc.
USB接口130是符合USB标准规范的接口,具体可以是Mini USB接口,Micro USB接口,USB Type C接口等。USB接口130可以用于连接充电器为电子设备100充电,也可以用于电子设备100与外围设备之间传输数据。The USB interface 130 is an interface that complies with USB standard specifications, and may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 may be used to connect a charger to charge the electronic device 100, and may also be used to transmit data between the electronic device 100 and a peripheral device.
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接口130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
电源管理模块141用于连接电池142,充电管理模块140与处理器110。The power management module 141 is used to connect the battery 142 , the charging management module 140 and the processor 110 .
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。The mobile communication module 150 can provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 .
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。The wireless communication module 160 can provide wireless communication solutions for application in the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with the network and other devices through wireless communication technology.
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid  crystal display,LCD),也可以采用有机发光二极管(organic light-emitting diode,OLED)、有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode,AMOLED)、柔性发光二极管(flex light-emitting diode,FLED)、Miniled、MicroLed、Micro-oLed或量子点发光二极管(quantum dot light emitting diodes,QLED)等材料中的一种所制作的显示面板。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。在一些实施例中,显示屏194还可以集成触控功能,也可以称为触摸屏。The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (liquid In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1. In some embodiments, the display screen 194 may also be integrated with a touch function, which may also be called a touch screen.
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。The external memory interface 120 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.
内部存储器121可以用于存储计算机可执行程序代码,该可执行程序代码包括指令。处理器110通过运行存储在内部存储器121的指令,从而执行电子设备100的各种功能应用以及数据处理。The internal memory 121 may be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121 .
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。耳机接口170D用于连接有线耳机。The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The speaker 170A, also called "speaker", is used to convert audio electrical signals into sound signals. The receiver 170B, also called "earpiece", is used to convert audio electrical signals into sound signals. The microphone 170C, also called "microphone", "microphone", is used to convert sound signals into electrical signals. The headphone interface 170D is used to connect wired headphones.
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。陀螺仪传感器180B可以用于确定电子设备100的运动姿态。气压传感器180C用于测量气压。在一些实施例中,电子设备100通过气压传感器180C测得的气压值计算海拔高度,辅助定位和导航。加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。距离传感器180F,用于测量距离。指纹传感器180H用于采集指纹。触摸传感器180K,也称“触控面板”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。骨传导传感器180M可以获取振动信号。在一些实施例中,骨传导传感器180M可以获取人体声部振动骨块的振动信号。骨传导传感器180M也可以接触人体脉搏,接收血压跳动信号。The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. The air pressure sensor 180C is used to measure the air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation. The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). The distance sensor 180F is used to measure the distance. The fingerprint sensor 180H is used to collect fingerprints. The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The bone conduction sensor 180M can obtain a vibration signal. In some embodiments, the bone conduction sensor 180M can obtain a vibration signal of a vibrating bone block of the human vocal part. The bone conduction sensor 180M can also contact the human pulse and receive blood pressure beat signals.
按键190包括开机键,音量键等。马达191可以产生振动提示。指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。SIM卡接口195用于连接SIM卡。The buttons 190 include a power button, a volume button, etc. The motor 191 can generate a vibration prompt. The indicator 192 can be an indicator light, which can be used to indicate the charging status, power change, messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect a SIM card.
图2是本申请实施例的电子设备100的软件结构框图。分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。应用程序层可以包括一系列应用程序包。FIG2 is a software structure diagram of the electronic device 100 of an embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer. The application layer can include a series of application packages.
如图2所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息,APP1,APP2等应用程序。As shown in FIG. 2 , the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, APP1, and APP2.
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
如图2所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。As shown in FIG. 2 , the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。该数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。Content providers are used to store and retrieve data and make it accessible to applications. This data can include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。 The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
电话管理器用于提供电子设备100的通信功能。例如通话状态的管理(包括接通,挂断等)。The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
Android runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(media libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。The system library can include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
三维图形处理库用于实现三维图形绘图、图像渲染、合成和图层处理等。The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing.
2D图形引擎是2D绘图的绘图引擎。A 2D graphics engine is a drawing engine for 2D drawings.
内核层是硬件和软件之间的层。内核层可以包含显示驱动,摄像头驱动,音频驱动,传感器驱动。The kernel layer is the layer between hardware and software. The kernel layer can include display drivers, camera drivers, audio drivers, and sensor drivers.
应理解,本申请实施例中的电子设备也可以是安装有Windows、Linux、安卓、鸿蒙或苹果等操作系统的电子设备。It should be understood that the electronic device in the embodiments of the present application may also be an electronic device installed with an operating system such as Windows, Linux, Android, Hongmeng or Apple.
为方便理解,下面结合图3、图4和图5本申请所涉及的技术术语进行解释和描述。For ease of understanding, the technical terms involved in this application are explained and described below in conjunction with Figures 3, 4 and 5.
图3是适用于本申请实施例的闪存的结构的示意图。其中填充白色的方块可以表示擦除块,填充点阵图案的方块可以表示数据页面。参考图3,闪存设备整个存储空间被划分为许多个擦除块,每个擦除块上可以存储若干个数据页面。数据页面通常以追加写的方式写入擦除块的空闲位置。当闪存设备的存储空间不足时,可能需要对其中的某些擦除块进行垃圾回收。即以擦除块为单位进行垃圾回收,通过擦除整个擦除块来释放出空闲空间。FIG3 is a schematic diagram of the structure of a flash memory applicable to an embodiment of the present application. A square filled with white may represent an erase block, and a square filled with a dot pattern may represent a data page. Referring to FIG3 , the entire storage space of the flash memory device is divided into a plurality of erase blocks, and each erase block may store a plurality of data pages. The data page is usually written to the free position of the erase block in an append write manner. When the storage space of the flash memory device is insufficient, garbage collection may be required for some of the erase blocks therein. That is, garbage collection is performed in units of erase blocks, and free space is released by erasing the entire erase block.
图4是适用于本申请实施例的垃圾回收的示意图。其中填充斜线图案的方块可以表示垃圾页面,填充点阵图案的方块可以表示有效页面,填充网格图案的方块可以表示空闲页面或空闲空间。4 is a schematic diagram of garbage collection applicable to an embodiment of the present application, wherein a square filled with a diagonal pattern may represent a garbage page, a square filled with a dot pattern may represent a valid page, and a square filled with a grid pattern may represent an idle page or idle space.
裸闪存文件系统是嵌入式系统上的板载NAND裸闪存芯片的文件系统,如UBIFS、YAFFS2、JFFS等裸闪存文件系统。数据页面可以以日志结构的方式写入擦除块内。为避免在垃圾回收时,对存储在擦除块上的其他数据产生干扰,可以采取异地更新的策略。当数据页面需要更新时,裸闪存文件系统将会将新的数据页面写入一个新的擦除块,通过修改数据页面对应的索引指针,使用包含新数据的页面替换旧页面,使包含旧数据的页面无效。The bare flash file system is a file system for the onboard NAND bare flash chip on the embedded system, such as UBIFS, YAFFS2, JFFS and other bare flash file systems. Data pages can be written into the erase block in a log structure. In order to avoid interference with other data stored on the erase block during garbage collection, a remote update strategy can be adopted. When a data page needs to be updated, the bare flash file system will write the new data page to a new erase block, and by modifying the index pointer corresponding to the data page, replace the old page with the page containing the new data, making the page containing the old data invalid.
在本申请实施例中,包含新数据的页面被标记为有效页面,包含旧数据的页面被标记为垃圾页面。垃圾页面也可以称为脏页、无效页。垃圾页面经过垃圾回收后变为空闲页面,才可以重新写入数据。In the embodiment of the present application, the page containing new data is marked as a valid page, and the page containing old data is marked as a garbage page. The garbage page can also be called a dirty page or an invalid page. The garbage page becomes a free page after garbage collection, and data can be rewritten.
在本申请实施例中,页面和数据页面也可以称为数据块,有效页面也可以称为有效数据,垃圾页面也可以称为无效数据。In the embodiment of the present application, pages and data pages may also be referred to as data blocks, valid pages may also be referred to as valid data, and junk pages may also be referred to as invalid data.
参考图4,当进行垃圾回收时,首先选择目标擦除块作为垃圾回收的对象,然后读取并识别目标擦除块中的有效页面,并将目标擦除块中的有效页面写入到新的有空闲空间的擦除块中,或者将有效页面加载到主存中,或者将有效页面加载到其他的存储空间中,最后清除目标擦除块中的全部数据,以释放空间。Referring to Figure 4, when performing garbage collection, first select the target erase block as the object of garbage collection, then read and identify the valid pages in the target erase block, and write the valid pages in the target erase block to a new erase block with free space, or load the valid pages into the main memory, or load the valid pages into other storage spaces, and finally clear all data in the target erase block to free up space.
垃圾回收效率被定义为垃圾页面数量与擦除块默认总页面数的比值。垃圾回收效率越高,说明擦除块内的垃圾页面越多,意味着每次垃圾回收时需要移动的有效页面的越少,垃圾回收的速度越快。并且,垃圾回收效率越高还意味着擦除次数越少,闪存寿命越长。如果垃圾回收的效率低,还可能导 致严重的写放大的问题。写入放大(write amplification,WA),简称写放大,是闪存和固态硬盘(SSD)中一种不良的现象,即实际写入的物理数据量是写入数据量的多倍。Garbage collection efficiency is defined as the ratio of the number of garbage pages to the total number of default pages in the erase block. The higher the garbage collection efficiency, the more garbage pages there are in the erase block, which means that fewer valid pages need to be moved each time garbage collection occurs, and the faster the garbage collection process. In addition, a higher garbage collection efficiency also means fewer erase times and a longer flash life. If the garbage collection efficiency is low, it may also lead to This leads to a serious write amplification problem. Write amplification (WA), also known as write amplification, is an undesirable phenomenon in flash memory and solid-state drives (SSDs), where the actual amount of physical data written is multiple times the amount of data written.
传统的方案中,通过数据页面的冷热分离放置,将不同热度的页面放置在不同的擦除块内。例如,可以将数据页面按照访问频次分为热页面和冷页面,并将热页面集中在热擦除块内,冷页面集中在冷擦除块中,从而使得热擦除块相较于冷擦除块具有更高的垃圾页面的比例。当文件系统触发垃圾回收时,常常会选择垃圾页面最多的擦除块。然而这种选择策略会使得选择的目标擦除块的垃圾页面数量越来越少,垃圾回收效率越来越低。即使使用了数据页面的冷热分离放置,垃圾回收效率也会快速降低。In the traditional solution, pages of different temperatures are placed in different erase blocks by separating hot and cold data pages. For example, data pages can be divided into hot pages and cold pages according to the access frequency, and hot pages are concentrated in hot erase blocks, and cold pages are concentrated in cold erase blocks, so that hot erase blocks have a higher proportion of garbage pages than cold erase blocks. When the file system triggers garbage collection, it often selects the erase block with the most garbage pages. However, this selection strategy will make the number of garbage pages in the selected target erase block decrease, and the garbage collection efficiency will decrease. Even if the hot and cold separation of data pages is used, the garbage collection efficiency will decrease rapidly.
并且,目前已有的冷热分离方法存在资源开销大,热度等级分类不准确和无法快速识别热点变化等问题。例如最近最少使用页面置换算法(least recently used,LRU)、最近最不常用页面置换算法(least frequently used,LFU)排序需要对文件系统所有页面维护热度管理元信息,内存占用较大。对于LFU这种基于访问频次排序的方法,当面临数据集热点变化情况时,访问频次历史累计量高的数据页面在未来一段时间内会仍被认为是热页面,导致识别页面热度变化存在一定的滞后性。In addition, the existing hot and cold separation methods have problems such as high resource overhead, inaccurate heat level classification, and inability to quickly identify hot spot changes. For example, the least recently used page replacement algorithm (LRU) and the least frequently used page replacement algorithm (LFU) need to maintain heat management metadata for all pages in the file system, which takes up a lot of memory. For LFU, a method based on access frequency sorting, when faced with changes in data set hot spots, data pages with a high historical cumulative access frequency will still be considered hot pages for a period of time in the future, resulting in a certain lag in identifying page heat changes.
下面结合图5-13图介绍本申请实施例提供的方案。The solution provided by the embodiment of the present application is introduced below in conjunction with Figures 5-13.
图5是本申请实施例的数据页面的重用距离的示意图。在本申请实施例中,将文件系统中某个数据页面连续两次更新之间文件系统写入操作次数定义为数据页面的重用距离。参考图5,横轴表示文件系统的写入序号,纵轴表示页面的热度。FIG5 is a schematic diagram of the reuse distance of a data page in an embodiment of the present application. In an embodiment of the present application, the number of file system write operations between two consecutive updates of a data page in the file system is defined as the reuse distance of the data page. Referring to FIG5, the horizontal axis represents the write sequence number of the file system, and the vertical axis represents the heat of the page.
可以理解的是,在某个页面连续两次更新之间,文件系统可能还会对其他页面进行写操作,将文件系统对其他页面进行写操作的次数作为该页面的重用距离。It is understandable that, between two consecutive updates of a certain page, the file system may perform write operations on other pages, and the number of times the file system performs write operations on other pages is taken as the reuse distance of the page.
示例性的,每次写入页面时,记录该页面的写入序号,当再次写入该页面时,根据两次写入该页面时的写入序号,即可得到该页面的一个重用距离。Exemplarily, each time a page is written, the write sequence number of the page is recorded, and when the page is written again, a reuse distance of the page can be obtained based on the write sequence numbers when the page is written twice.
示例性的,如图5所示,页面501在第一次更新和第二次更新之间,文件系统对其他页面进行了5次写操作,则页面501在第一次更新和第二次更新之间的重用距离为5;页面502在第一次更新和第二次更新之间,文件系统对其他页面进行了11次写操作,则页面502在第一次更新和第二次更新之间的重用距离为11;页面503在第一次更新和第二次更新之间,文件系统对其他页面进行了100次写操作,则页面503在第一次更新和第二次更新之间的重用距离为100。其中,页面501在相邻两次更新之间的平均重用距离最短,页面502在相邻两次更新之间的平均重用距离居中,页面503在相邻两次更新之间的平均重用距离最长。页面501的热度最高,页面502的热度其次,页面503的热度最低。For example, as shown in FIG5 , between the first update and the second update of page 501, the file system performs 5 write operations on other pages, and the reuse distance between the first update and the second update of page 501 is 5; between the first update and the second update of page 502, the file system performs 11 write operations on other pages, and the reuse distance between the first update and the second update of page 502 is 11; between the first update and the second update of page 503, the file system performs 100 write operations on other pages, and the reuse distance between the first update and the second update of page 503 is 100. Among them, the average reuse distance between two adjacent updates of page 501 is the shortest, the average reuse distance between two adjacent updates of page 502 is in the middle, and the average reuse distance between two adjacent updates of page 503 is the longest. Page 501 has the highest heat, page 502 has the second highest heat, and page 503 has the lowest heat.
应理解,重用距离越短的页面,表示该页面更新的频次越高,即该页面的热度越高。重用距离越长的页面,表示该页面更新的频次越低,即该页面的热度越低。It should be understood that a page with a shorter reuse distance has a higher frequency of page updates, that is, the page has a higher popularity. A page with a longer reuse distance has a lower frequency of page updates, that is, the page has a lower popularity.
应理解,文件系统对其他页面进行的写操作的次数,也可以是对其他页面进行更新的次数。It should be understood that the number of write operations performed by the file system on other pages may also be the number of updates performed on other pages.
图6是本申请实施例提供的方法600的示意性流程图。该方法600主要用于闪存数据分类存储时的热度等级的划分。参考图6,该方法600可以包括以下步骤:FIG6 is a schematic flow chart of a method 600 provided in an embodiment of the present application. The method 600 is mainly used for classifying the heat levels when flash memory data is stored in a classified manner. Referring to FIG6 , the method 600 may include the following steps:
S610,获取第一时间段内写入的多个页面的重用距离。S610, obtaining reuse distances of multiple pages written in a first time period.
示例性的,在第一时间段内,每当写入一个页面时,将该页面这次更新与上次更新之间的重用距离记录下来。Exemplarily, during the first time period, each time a page is written, the reuse distance between the current update and the last update of the page is recorded.
S620,通过对多个页面的重用距离进行聚类,确定至少两个热度等级。S620, determining at least two heat levels by clustering reuse distances of multiple pages.
在本申请实施例中,可以通过聚类方法将多个页面重用距离的数据集合划分成多个子集,使得每个子集的重用距离的差异最大。用户或系统可以预设置子集的数量,即热度等级的数量,例如冷、热两组,或者冷、温、热三组。也就是说,用户或系统可以预先确定至少两个热度等级,然后通过聚类方法确定每个热度等级对应的重用距离的范围。In an embodiment of the present application, a data set of multiple page reuse distances can be divided into multiple subsets by a clustering method, so that the difference in reuse distance of each subset is maximized. The user or the system can preset the number of subsets, that is, the number of heat levels, such as two groups of cold and hot, or three groups of cold, warm, and hot. In other words, the user or the system can predetermine at least two heat levels, and then determine the range of reuse distances corresponding to each heat level by a clustering method.
应理解,聚类得到的子集所对应的重用距离范围作为每个热度等级的划分依据。It should be understood that the reuse distance range corresponding to the subset obtained by clustering is used as the basis for dividing each heat level.
应理解,每个子集对应一个重用距离的范围,也对应一个热度等级。It should be understood that each subset corresponds to a range of reuse distances and also corresponds to a heat level.
示例性的,在第一时间段内,UBIFS文件系统进行了16000次写操作。对最近的16000次写入的页面的重用间隔聚类。对16000次写入的页面的重用距离进行聚类,当指定热度等级数量为3时,重用距离小于3500次的被划分为热页面;重用距离在3500次到11000次之间为温页面,重用距离大于11000次为冷页面。 Exemplarily, in the first time period, the UBIFS file system performs 16,000 write operations. The reuse intervals of the pages written the most recently for 16,000 times are clustered. The reuse distances of the pages written the most recently for 16,000 times are clustered. When the number of heat levels is specified as 3, the pages with a reuse distance less than 3,500 times are classified as hot pages; the pages with a reuse distance between 3,500 and 11,000 times are classified as warm pages, and the pages with a reuse distance greater than 11,000 times are classified as cold pages.
在本申请实施例中,聚类方法可以使用例如K均值聚类算法(K-Means)、自然断点法(natural breaks),本申请对聚类的方法不予限定。In the embodiments of the present application, the clustering method may use, for example, the K-means clustering algorithm (K-Means) and the natural breakpoint method (natural breaks). The present application does not limit the clustering method.
在一些实施例中,每间隔第一时间段,重新执行步骤S620。也就是说,本申请实施例可以定期更新每个热度等级对应的重用距离的范围。In some embodiments, step S620 is performed again at intervals of the first time period. That is, the embodiment of the present application can regularly update the range of reuse distances corresponding to each heat level.
在一些实施例中,系统和用户可以预设置每个热度等级对应的重用距离的范围。例如,用户可以根据经验或实验得到的结论,估计每个热度等级对应的重用距离的范围,示例性的,重用距离小于4000次的被划分为热页面;重用距离在4000次到10000次之间为温页面,重用距离大于10000次为冷页面。In some embodiments, the system and the user can preset the range of reuse distances corresponding to each heat level. For example, the user can estimate the range of reuse distances corresponding to each heat level based on experience or experimental conclusions. For example, pages with a reuse distance of less than 4,000 times are classified as hot pages; pages with a reuse distance between 4,000 and 10,000 times are classified as warm pages; and pages with a reuse distance greater than 10,000 times are classified as cold pages.
在一些实施例中,还可以通过其他方式划分热度等级,并确定数据页面所属的热度等级。In some embodiments, the heat levels may be divided in other ways, and the heat level to which the data page belongs may be determined.
在一种可能的实现方式中,还可以根据在单位时间内数据页面更新的次数,划分热度等级,以及确定数据页面的热度等级。In a possible implementation, the heat levels may be divided and the heat levels of the data pages may be determined according to the number of times the data pages are updated within a unit time.
示例性的,单位时间内更新的次数小于第一阈值的数据页面为冷页面;单位时间内更新的次数大于或等于第一阈值,且小于或等于第二阈值的数据页面为温页面;单位时间内更新的次数大于第二阈值的数据页面为热页面。Exemplarily, a data page whose number of updates per unit time is less than a first threshold is a cold page; a data page whose number of updates per unit time is greater than or equal to the first threshold and less than or equal to a second threshold is a warm page; and a data page whose number of updates per unit time is greater than the second threshold is a hot page.
在一种可能的实现方式中,还可以根据数据页面历史累计的访问(更新)频次,划分热度等级,以及确定数据页面的热度等级。In a possible implementation, the heat level may be divided and the heat level of the data page may be determined according to the historical accumulated access (update) frequency of the data page.
示例性的,历史累计的访问频次大于第一阈值的数据页面为热页面;历史累计的访问频次小于第一阈值的数据页面为冷页面。Exemplarily, a data page whose historical accumulated access frequency is greater than a first threshold is a hot page; and a data page whose historical accumulated access frequency is less than the first threshold is a cold page.
在一种可能的实现方式中,还可以根据文件系统最近的N次操作中,对数据页面进行写操作的次数,以及划分热度等级,以及确定数据页面的热度等级。In a possible implementation, the heat level of the data page may be determined according to the number of write operations performed on the data page in the most recent N operations of the file system.
示例性的,在文件系统最近的N次对数据页面进行的写操作中,对某页面进行了M次写操作,则该页面的热度为M/N。当热度大于第一阈值时,该页面为热页面;当热度小于第一阈值时,该页面为冷页面。Exemplarily, in the N most recent write operations on data pages of the file system, a certain page is written M times, and the heat of the page is M/N. When the heat is greater than a first threshold, the page is a hot page; when the heat is less than the first threshold, the page is a cold page.
S630,确定每个热度等级对应的擦除块集合。S630: Determine the erase block set corresponding to each thermal level.
在S630中,可以为至少两个热度等级中的每个热度等级分配其对应的擦除块集合。In S630, a corresponding erase block set may be allocated to each of the at least two thermal levels.
应理解,每个热度等级可以对应一个擦除块集合,每个擦除块集合可以包括一个或多个擦除块。It should be understood that each thermal level may correspond to an erase block set, and each erase block set may include one or more erase blocks.
在一些实施例中,可以根据在第一时间段内,每个热度等级的页面的数量的分布,确定每个热度等级对应的擦除块的数量。例如,在第一时间段内,第一热度等级的页面数量最多,则第一热度等级对应的擦除块的数量最多;第二热度等级的页面数量最少,则第二热度等级对应的擦除块的数量最少。In some embodiments, the number of erase blocks corresponding to each heat level can be determined based on the distribution of the number of pages of each heat level in the first time period. For example, in the first time period, the number of pages of the first heat level is the largest, so the number of erase blocks corresponding to the first heat level is the largest; the number of pages of the second heat level is the smallest, so the number of erase blocks corresponding to the second heat level is the smallest.
在一些实施例中,在确定第一热度等级对应的擦除块时,优先选择曾经对应除第一热度等级外的其他热度等级的擦除块。例如,第一擦除块曾经对应冷页面,则确定热页面对应的擦除块时,优先选择第一擦除块。In some embodiments, when determining the erase block corresponding to the first thermal level, the erase block that once corresponded to other thermal levels other than the first thermal level is preferentially selected. For example, if the first erase block once corresponded to a cold page, the first erase block is preferentially selected when determining the erase block corresponding to the hot page.
应理解,每个热度等级对应的擦除块集合中的擦除块用于存储该热度等级的页面。例如,第一热度等级对应的擦除块集合中的擦除块用于存储第一热度等级的页面。或者,热擦除块集合中的热擦除块用于存储热页面,冷擦除块集合中的冷擦除块用于存储冷页面。It should be understood that the erase blocks in the erase block set corresponding to each thermal level are used to store pages of the thermal level. For example, the erase blocks in the erase block set corresponding to the first thermal level are used to store pages of the first thermal level. Alternatively, the hot erase blocks in the hot erase block set are used to store hot pages, and the cold erase blocks in the cold erase block set are used to store cold pages.
图7是本申请实施例提供的方法700的示意性流程图。该方法700主要用于将写入的页面存储到对应热度等级的擦除块中。参考图7,该方法700可以包括以下步骤:FIG7 is a schematic flow chart of a method 700 provided in an embodiment of the present application. The method 700 is mainly used to store written pages into erase blocks of corresponding thermal levels. Referring to FIG7 , the method 700 may include the following steps:
S710,根据第二页面在第二时间段内的第一重用距离,预测第二页面的第二重用距离。S710 , predicting a second reuse distance of a second page according to a first reuse distance of the second page in a second time period.
在第二页面写入闪存之前,需要预测第二页面在未来可能的重用距离,以便于确定第二页面所属的热度等级。Before the second page is written into the flash memory, it is necessary to predict the possible reuse distance of the second page in the future, so as to determine the thermal level to which the second page belongs.
应理解,第二页面为任意一个需要写入或需要进行更新的页面。It should be understood that the second page is any page that needs to be written or updated.
应理解,第一重用距离为第二页面在第二时间段内的重用距离。在第二时间段内,第二页面可能进行了多次更新,也就是说,第一重用距离的数量可以为多个。It should be understood that the first reuse distance is the reuse distance of the second page in the second time period. In the second time period, the second page may be updated multiple times, that is, the number of the first reuse distances may be multiple.
应理解,第二重用距离为在当前时刻和第二页面下一次更新的时刻之间,文件系统对其他页面进行写操作的次数。It should be understood that the second reuse distance is the number of times the file system performs write operations on other pages between the current time and the time when the second page is next updated.
在预测第二页面的第二重用距离时,可以采用对第一时间段内的多个第一重用距离取加权平均,或者对时间序列预测,或者历史数据指数平滑方法等方法。When predicting the second reuse distance of the second page, a weighted average of multiple first reuse distances within the first time period, or time series prediction, or historical data exponential smoothing method and other methods may be adopted.
需要说明的是,时间序列预测,也可以称为时序预测,给定某一个指标的历史数值变化,就可以 预测其在未来一段时间内的数值。历史数据指数平滑方法与之类似,均是根据历史数据,预测该指标在未来一段时间内的数值。It should be noted that time series forecasting, also known as time series forecasting, is a process of predicting the historical value changes of a certain indicator. Predict its value in the future. The historical data exponential smoothing method is similar to it, both of which predict the value of the indicator in the future based on historical data.
S720,根据第二重用距离和每个热度等级对应的重用距离的范围,确定所述第二页面所属的热度等级。S720: Determine the heat level to which the second page belongs according to the second reuse distance and the range of the reuse distance corresponding to each heat level.
具体的,当第二重用距离位于某一热度等级对应的重用距离的范围内时,确定第二页面属于该热度等级。Specifically, when the second reuse distance is within a range of reuse distances corresponding to a certain heat level, it is determined that the second page belongs to the heat level.
示例性的,当第二重用距离小于或等于3500次时,确定第二页面为第一热度等级,或者确定第二页面为热页面。Exemplarily, when the second reuse distance is less than or equal to 3500 times, the second page is determined to be at the first heat level, or the second page is determined to be a hot page.
S730,将第二页面写入到第二页面所属的热度等级对应的擦除块中。S730, writing the second page into the erase block corresponding to the thermal level to which the second page belongs.
在S630中,为每个热度等级确定了其对应的擦除块集合,或为每个热度等级确定了其对应的擦除块。在S730中,在写入第二页面时,可以先查找第二页面所属的热度等级对应的擦除块中是否有足够的空间来存储第二页面,如果是,则在该擦除块中写入第二页面。In S630, a corresponding erase block set is determined for each thermal level, or a corresponding erase block is determined for each thermal level. In S730, when writing the second page, it is possible to first check whether there is enough space in the erase block corresponding to the thermal level to which the second page belongs to store the second page, and if so, write the second page in the erase block.
示例性的,第二页面属于第一热度等级,第一热度等级对应有第一擦除块集合,第一擦除块集合包括第一擦除块,当写入第二页面时,遍历第一擦除块集合中的擦除块,查找到第一擦除块具有足够的空间,则将第二页面写入第一擦除块。Exemplarily, the second page belongs to the first heat level, the first heat level corresponds to the first erase block set, the first erase block set includes the first erase block, and when writing the second page, the erase blocks in the first erase block set are traversed, and if it is found that the first erase block has sufficient space, the second page is written to the first erase block.
在一些实施例中,如果第二页面所述的热度等级对应的擦除块中均没有足够的空间,可以触发垃圾回收操作,对目标擦除块进行擦除,并将第二页面写入到目标擦除块中。In some embodiments, if there is insufficient space in the erase blocks corresponding to the thermal levels described in the second page, a garbage collection operation may be triggered to erase the target erase block and write the second page into the target erase block.
在一些实施例中,在将第二页面写入到目标擦除块时,将目标擦除块添加进第二页面所属的热度等级对应的擦除块集合中。In some embodiments, when the second page is written to the target erase block, the target erase block is added to the erase block set corresponding to the thermal level to which the second page belongs.
图8是本申请实施例提供的方法800的示意性流程图。该方法800主要用于确定垃圾回收的目标擦除块。参考图8,该方法800包括:FIG8 is a schematic flow chart of a method 800 provided in an embodiment of the present application. The method 800 is mainly used to determine a target erase block for garbage collection. Referring to FIG8 , the method 800 includes:
S810,根据第一擦除块中的垃圾页面的数量,以及第二擦除块中的垃圾页面的增速,得到第一分数。S810: Obtain a first score according to the number of garbage pages in the first erase block and the growth rate of garbage pages in the second erase block.
S820,根据第二擦除块中的垃圾页面的数量,以及第一擦除块中的垃圾页面的增速,得到第二分数。S820: Obtain a second score according to the number of garbage pages in the second erase block and the growth rate of garbage pages in the first erase block.
在进行垃圾回收时,可以通过以下方式确定垃圾回收的目标擦除块。假设闪存中存在q个擦除块,记总擦除块集合EB={EB1,EB2,EB3······EBq},总擦除块集合中的每个擦除块的垃圾页面的数量记为Garbage(EBi),每个擦除块的垃圾页面的增速记为V(EBi),对总擦除块集合中的每个擦除块按照下面的公式进行打分,对其中分数最大的擦除块进行垃圾回收。
Score(EBi)=max{Garbage(EBi)×(1+V(EBj))}
When performing garbage collection, the target erase block for garbage collection can be determined in the following manner. Assume that there are q erase blocks in the flash memory, record the total erase block set EB = {EB 1 , EB 2 , EB 3 ······EB q }, record the number of garbage pages of each erase block in the total erase block set as Garbage(EB i ), record the growth rate of garbage pages of each erase block as V(EB i ), score each erase block in the total erase block set according to the following formula, and perform garbage collection on the erase block with the largest score.
Score(EB i )=max{Garbage(EB i )×(1+V(EB j ))}
其中,Score(EBi)表示擦除块EBi的分数,Garbage(EBi)表示擦除块EBi的垃圾页面的数量,V(EBj)表示擦除块EBj的垃圾页面的增速,EBi∈EB,EBj∈EB,且EBj≠EBi,i≤q,j≤q。Wherein, Score(EB i ) represents the score of erase block EB i , Garbage(EB i ) represents the number of garbage pages of erase block EB i , V(EB j ) represents the growth rate of garbage pages of erase block EB j , EB i ∈EB, EB j ∈EB, and EB j ≠EB i , i≤q, j≤q.
在本申请实施例中,对于某一个擦除块,在文件系统最近N次的写操作中,该擦除块中的垃圾页面的增加的数量为P,则该擦除块中的垃圾页面的增速为P/N。In an embodiment of the present application, for a certain erase block, in the most recent N write operations of the file system, the increase in the number of garbage pages in the erase block is P, and the growth rate of the garbage pages in the erase block is P/N.
在一些实施例中,擦除块中的垃圾页面的增速为:单位时间内,该擦除块中的垃圾页面增加的数量。In some embodiments, the growth rate of garbage pages in an erase block is: the number of garbage pages added in the erase block per unit time.
示例性的,在闪存运行时,记录第一时刻时,擦除块中的垃圾页面的数量,再记录第二时刻时,该擦除块中的垃圾页面的数量,即可通过计算得到该擦除块中的垃圾页面的增速。Exemplarily, when the flash memory is running, the number of garbage pages in the erase block at a first moment is recorded, and then the number of garbage pages in the erase block at a second moment is recorded, and the growth rate of the garbage pages in the erase block can be calculated.
在一些实施例中,擦除块中的垃圾页面的增速为:在文件系统最近N次的写操作中,该擦除块中的垃圾页面的增加的数量。In some embodiments, the growth rate of garbage pages in an erase block is: the number of increased garbage pages in the erase block in the most recent N write operations of the file system.
示例性的,在闪存运行时,记录文件系统第一次(或者,第X次,X为大于或等于零的正整数)的写操作时,擦除块中的垃圾页面的数量,再记录文件系统第N(N为大于X的正整数)次的写操作时,该擦除块中的垃圾页面的数量,即可通过计算得到该擦除块中的垃圾页面的增速。Exemplarily, when the flash memory is running, the number of garbage pages in the erase block when the file system writes for the first time (or the Xth time, where X is a positive integer greater than or equal to zero) is recorded, and then the number of garbage pages in the erase block when the file system writes for the Nth time (N is a positive integer greater than X) is recorded, and the growth rate of the garbage pages in the erase block can be calculated.
在本申请实施例中,可以通过多次计算某一擦除块中的垃圾页面的增速,并通过取平均值、加权平均、历史数据指数平滑算法等方法作为该擦除块的真实的垃圾页面的增速。In an embodiment of the present application, the growth rate of garbage pages in a certain erase block can be calculated multiple times, and the average value, weighted average, historical data exponential smoothing algorithm, etc. can be used as the real growth rate of garbage pages in the erase block.
基于上述方案,垃圾页面的增速最大的擦除块将不一定被作为垃圾回收的对象,这样,在下一次垃圾回收时,该垃圾页面的增速最大的擦除块中可能积累了数量较多的垃圾页面,从而该擦除块被垃 圾回收时的效率较高,进而提升垃圾回收的效率。另一方面,垃圾回收的效率较高,写放大系数得以减小,闪存擦除次数得以减少,有利于提升闪存的使用寿命。Based on the above scheme, the erase block with the fastest growth rate of garbage pages will not necessarily be the object of garbage collection. In this way, during the next garbage collection, a large number of garbage pages may be accumulated in the erase block with the fastest growth rate of garbage pages, so that the erase block is garbage collected. The efficiency of garbage collection is higher, thereby improving the efficiency of garbage collection. On the other hand, the efficiency of garbage collection is higher, the write amplification factor is reduced, and the number of flash memory erases is reduced, which is beneficial to improving the service life of the flash memory.
在一些实施例中,假设存在K个热度等级,标号分别为{1,2,·····,K}。对于每个热度等级对应的擦除块集合,取出每个擦除块集合中垃圾页面的数量最大的擦除块,组成候选擦除块集合CEB={CEB1,CEB2,CEB3······CEBk},候选擦除块集合中的每个擦除块的垃圾页面的数量记为Garbage(CEBi),每个擦除块的垃圾页面的增速记为V(CEBi),对候选擦除块集合中的每个擦除块按照下面的公式进行打分,对其中分数最大的擦除块进行垃圾回收。
Score(CEBi)=max{Garbage(CEBi)×(1+V(CEBj))}
In some embodiments, it is assumed that there are K heat levels, which are numbered {1, 2, ·····, K}. For the erase block set corresponding to each heat level, the erase block with the largest number of garbage pages in each erase block set is taken out to form a candidate erase block set CEB={CEB 1 , CEB 2 , CEB 3 ······CEB k }, the number of garbage pages of each erase block in the candidate erase block set is recorded as Garbage(CEB i ), the growth rate of garbage pages of each erase block is recorded as V(CEB i ), each erase block in the candidate erase block set is scored according to the following formula, and the erase block with the largest score is garbage collected.
Score(CEB i )=max{Garbage(CEB i )×(1+V(CEB j ))}
其中,Score(CEBi)表示擦除块CEBi的分数,Garbage(CEBi)表示擦除块CEBi的垃圾页面的数量,V(CEBj)表示擦除块CEBj的垃圾页面的增速,CEBi∈CEB,CEBj∈CEB,且CEBj≠CEBi,i≤q,j≤q。Wherein, Score(CEB i ) represents the score of erase block CEB i , Garbage(CEB i ) represents the number of garbage pages of erase block CEB i , V(CEB j ) represents the growth rate of garbage pages of erase block CEB j , CEB i ∈CEB, CEB j ∈CEB, and CEB j ≠CEB i , i≤q, j≤q.
应理解,每个热度等级对应的擦除块中存储相应热度等级的页面。由于每个热度等级的页面更新的频次不同,每个热度等级对应的擦除块中的垃圾页面的增速也不相同,甚至可以具有明显区分。It should be understood that the erase blocks corresponding to each heat level store pages of the corresponding heat level. Since the pages of each heat level are updated at different frequencies, the growth rate of garbage pages in the erase blocks corresponding to each heat level is also different, and can even be clearly distinguished.
基于上述方案,垃圾页面的增速最大的擦除块将不一定被作为垃圾回收的对象,这样,在下一次垃圾回收时,该垃圾页面的增速最大的擦除块中可能积累了数量较多的垃圾页面,从而该擦除块被垃圾回收时的效率较高,进而提升垃圾回收的效率。另一方面,垃圾回收的效率较高,写放大系数得以减小,闪存擦除次数得以减少,有利于提升闪存的使用寿命。并且,由于对擦除块按照热度等级进行了分类,候选擦除块集合中的擦除块数量较少,确定垃圾回收的目标擦除块的速度较快,有利于提升垃圾回收的速度。Based on the above scheme, the erase block with the fastest growth rate of garbage pages will not necessarily be the object of garbage collection. In this way, during the next garbage collection, a large number of garbage pages may be accumulated in the erase block with the fastest growth rate of garbage pages, so that the efficiency of garbage collection of the erase block is higher, thereby improving the efficiency of garbage collection. On the other hand, the efficiency of garbage collection is higher, the write amplification factor is reduced, and the number of flash memory erases is reduced, which is beneficial to improving the service life of the flash memory. In addition, since the erase blocks are classified according to the heat level, the number of erase blocks in the candidate erase block set is small, and the speed of determining the target erase block for garbage collection is faster, which is beneficial to improving the speed of garbage collection.
S830,在第一分数大于第二分数的情况下,对第一擦除块进行垃圾回收。S830: When the first score is greater than the second score, garbage collection is performed on the first erase block.
可选的,在对第一擦除块进行垃圾回收时,可以先提取第一擦除块中的有效页面,并将有效页面写入到第三擦除块中,并擦除所述第一擦除块中的全部页面。Optionally, when performing garbage collection on the first erase block, valid pages in the first erase block may be extracted first, and the valid pages may be written into the third erase block, and all pages in the first erase block may be erased.
可选的,在对第一擦除块进行垃圾回收时,可以先提取第一擦除块中的有效页面,并将有效页面加载到其他存储空间中,并擦除所述第一擦除块中的全部页面。Optionally, when performing garbage collection on the first erase block, valid pages in the first erase block may be first extracted, and the valid pages may be loaded into other storage spaces, and all pages in the first erase block may be erased.
可选的,在对第一擦除块进行垃圾回收之后,还可以将需要写入或需要更新的第三页面写入到第一擦除块中,如果第三页面属于第三热度等级,则将第一擦除块添加到第三热度等级对应的擦除块集合中。Optionally, after garbage collection of the first erase block, the third page that needs to be written or updated may be written into the first erase block. If the third page belongs to the third heat level, the first erase block is added to the erase block set corresponding to the third heat level.
应理解,可以在任意时刻进行垃圾回收,而不必限定在闪存或擦除块中的空间不足时进行垃圾回收,例如当文件系统空闲时,也可以进行垃圾回收。It should be understood that garbage collection can be performed at any time, and is not limited to when there is insufficient space in the flash memory or the erase block. For example, garbage collection can also be performed when the file system is idle.
图9是本申请实施例提供的文件系统写入页面时的流程的示意图。FIG. 9 is a schematic diagram of the process of writing a page to a file system according to an embodiment of the present application.
S901,根据第四页面的索引,查找第四页面的元信息。S901, searching for meta information of the fourth page according to the index of the fourth page.
在写入第四页面时,文件系统首先根据索引寻找该页面的元信息。如果第四页面没有索引,则创建一个索引,并记录第四页面的写入序号,并将第四页面的未来重用距离重置为-1。When writing the fourth page, the file system first searches for the meta information of the page according to the index. If the fourth page has no index, an index is created, the write sequence number of the fourth page is recorded, and the future reuse distance of the fourth page is reset to -1.
应理解,第四页面可以为任意一个需要写入或需要更新的页面。It should be understood that the fourth page may be any page that needs to be written or updated.
S902,根据元信息中的重用距离相关的信息,预测第四页面的未来重用距离。S902: predicting the future reuse distance of the fourth page according to the information related to the reuse distance in the meta information.
步骤S902可以参考步骤S710的相关描述,为简洁,在此不再赘述。For step S902, reference may be made to the relevant description of step S710, which will not be repeated here for the sake of brevity.
S903,根据第四页面的未来重用距离,确定第四页面所属的热度等级。S903: Determine the popularity level of the fourth page according to the future reuse distance of the fourth page.
步骤S903可以参考步骤S720的相关描述,为简洁,在此不再赘述。For step S903, reference may be made to the relevant description of step S720, which will not be repeated here for the sake of brevity.
应理解,第四页面可以为任意热度等级的页面,本申请对第四页面的热度等级不予限定。It should be understood that the fourth page can be a page of any popularity level, and the present application does not limit the popularity level of the fourth page.
需要说明的是,如果第四页面的未来重用距离重置为-1,则该页面为一个冷页面。It should be noted that if the future reuse distance of the fourth page is reset to -1, the page is a cold page.
下面以第四页面为热页面为例进行说明。The following description will be made by taking the fourth page as a hot page as an example.
S904,判断热日志头对应的擦除块是否有足够的空间。S904, determining whether the erase block corresponding to the hot log header has sufficient space.
由于文件系统以日志结构的方式将页面写入闪存的擦除块中,并且第四页面为热页面,在写入第四页面时,首先判断热日志头对应的擦除块是否有足够的空间。Since the file system writes pages into the erase block of the flash memory in a log structured manner, and the fourth page is a hot page, when writing the fourth page, it is first determined whether the erase block corresponding to the hot log header has enough space.
S905,如果热日志头对应的擦除块有足够的空间,则将第四页面写入热日志头的写缓冲区,并将第四页面写入热日志头对应的擦除块中。S905: If the erase block corresponding to the hot log header has enough space, write the fourth page into the write buffer of the hot log header, and write the fourth page into the erase block corresponding to the hot log header.
S906,更新第四页面的元信息中的第四页面的物理地址。S906 , updating the physical address of the fourth page in the meta-information of the fourth page.
具体的,在将第四页面成功写入热日志头对应的擦除块中后,在文件系统页面索引结构中记录数 据页面逻辑地址到物理位置的映射关系。也就是说,将第四页面的的文件指针指向步骤S905写入的擦除块中。Specifically, after the fourth page is successfully written into the erase block corresponding to the hot log header, the number is recorded in the file system page index structure. According to the mapping relationship between the page logical address and the physical position, that is, the file pointer of the fourth page is pointed to the erase block written in step S905.
S907,如果热日志头对应的擦除块没有足够的空间,则判断热擦除块集合中是否有足够空间的热擦除块。S907: If the erase block corresponding to the hot log header does not have enough space, determine whether there is a hot erase block with enough space in the hot erase block set.
S908,如果热擦除块集合中有具有足够空间的热擦除块,则将热日志头切换到新的有足够空间的热擦除块。S908: If there is a hot erase block with sufficient space in the hot erase block set, the hot log head is switched to a new hot erase block with sufficient space.
需要说明的是,在步骤S907和步骤S908之后,返回执行步骤S904。It should be noted that after step S907 and step S908, the process returns to step S904.
S909,如果热擦除块集合中没有具有足够空间的热擦除块,则触发垃圾回收,擦除目标擦除块的全部数据页面,并将热日志头切换到目标擦除块。S909: If there is no hot erase block with sufficient space in the hot erase block set, garbage collection is triggered to erase all data pages of the target erase block and switch the hot log header to the target erase block.
具体的,可以使用本申请实施例提供的垃圾回收的方法,进行垃圾回收。例如,可以选择每个热度等级对应的擦除块集合中垃圾页面数量最大的擦除块,组成候选擦除块集合,然后对候选擦除块中的每个擦除块进行打分,选择分数最高的擦除块为目标擦除块,并进行垃圾回收。在目标擦除块的全部数据页面被擦除后,将热日志头对应的擦除块切换到目标擦除块。Specifically, the garbage collection method provided in the embodiment of the present application can be used to perform garbage collection. For example, the erase block with the largest number of garbage pages in the erase block set corresponding to each heat level can be selected to form a candidate erase block set, and then each erase block in the candidate erase block is scored, and the erase block with the highest score is selected as the target erase block, and garbage collection is performed. After all data pages of the target erase block are erased, the erase block corresponding to the hot log header is switched to the target erase block.
需要说明的是,在步骤S907和步骤S909之后,返回执行步骤S904。It should be noted that after step S907 and step S909, the process returns to step S904.
图10是本申请实施例提供的写入页面的流程的示意图。参考图10,当第五页面需写入或者需要更新时,记录第五页面本次更新的时刻与上一次更新的时刻之间的重用距离,并传递给热度等级划分模块。Fig. 10 is a schematic diagram of the process of writing pages provided by an embodiment of the present application. Referring to Fig. 10, when the fifth page needs to be written or updated, the reuse distance between the time of the fifth page being updated this time and the time of the last update is recorded and transmitted to the heat level classification module.
热度等级划分模块可以周期性的划分热度等级,确定每个热度等级对应的重用距离的范围。例如,热度等级划分模块每间隔第一时间段,对第一时间段内的多个写入的页面的重用距离进行聚类,以得到至少两组重用距离的范围,每组重用距离的范围对应一个热度等级。The heat level division module can periodically divide the heat levels and determine the range of reuse distances corresponding to each heat level. For example, the heat level division module clusters the reuse distances of multiple pages written in the first time period every first time period to obtain at least two groups of reuse distance ranges, and each group of reuse distance ranges corresponds to a heat level.
重用距离预测模块可以根据第五页面的一个或多个历史重用距离,预测第五页面的未来重用距离,即预测第五页面本次更新与下一次更新之间,文件系统可能进行多少次写操作。The reuse distance prediction module can predict the future reuse distance of the fifth page according to one or more historical reuse distances of the fifth page, that is, predict how many write operations the file system may perform between the current update and the next update of the fifth page.
根据第五页面的未来重用距离和每个热度等级对应重用距离的范围,即可确定第五页面的热度等级,并将第五页面写入对应热度等级的擦除块集合中有足够的空间的擦除块中。例如,第五页面为冷页面,则将第五页面写入到冷擦除块中。According to the future reuse distance of the fifth page and the range of the reuse distance corresponding to each heat level, the heat level of the fifth page can be determined, and the fifth page is written into an erase block with sufficient space in the erase block set of the corresponding heat level. For example, if the fifth page is a cold page, the fifth page is written into a cold erase block.
如果对应热度等级的擦除块集合中,任意一个擦除块均没有足够空间,则目标擦除块选择模块将会选择目标擦除块进行垃圾回收操作。在进行垃圾回收操作时,可以通过图8所示实施例的方法选择目标擦除块。为简洁,在此不再赘述。在对目标擦除块进行垃圾回收后,将第五页面写入到目标擦除块中。If any erase block in the erase block set corresponding to the heat level does not have enough space, the target erase block selection module will select the target erase block for garbage collection operation. When performing garbage collection operation, the target erase block can be selected by the method of the embodiment shown in Figure 8. For brevity, it will not be repeated here. After garbage collection is performed on the target erase block, the fifth page is written into the target erase block.
可选的,在将第五页面写入到目标擦除块中后,将目标擦除块添加到第五页面所属的热度等级对应的擦除块集合中。Optionally, after the fifth page is written into the target erase block, the target erase block is added to an erase block set corresponding to the thermal level to which the fifth page belongs.
图11是本申请实施例提供的不同策略下垃圾回收的效果的示意图。图12是本申请实施例提供的另一不同策略下垃圾回收的效果的示意图。图11和图12分别显示了在64MB和128MB空间大小的UBIFS文件系统上的只写测试结果。其中,本申请实施例提供的方案为填充黑色图案;填充白色图案的为没有划分热度等级,且为垃圾回收的策略为贪心策略,即总是选择垃圾页面数量最多的擦除块进行垃圾回收;填充左斜线的图案的为划分热度等级,且为垃圾回收的策略为贪心策略;填充右斜线图案的为划分热度等级,且垃圾回收的策略为权衡策略。FIG11 is a schematic diagram of the effect of garbage collection under different strategies provided in an embodiment of the present application. FIG12 is a schematic diagram of the effect of garbage collection under another different strategy provided in an embodiment of the present application. FIG11 and FIG12 respectively show the results of write-only tests on UBIFS file systems of 64MB and 128MB space sizes. Among them, the solution provided in the embodiment of the present application is to fill in black patterns; to fill in white patterns means that there is no heat level division, and the garbage collection strategy is a greedy strategy, that is, the erase block with the largest number of garbage pages is always selected for garbage collection; to fill in left-slash patterns means that heat levels are divided, and the garbage collection strategy is a greedy strategy; to fill in right-slash patterns means that heat levels are divided, and the garbage collection strategy is a trade-off strategy.
相比之下,在本申请实施例提供的方案中,写放大系数减少了9%~16%,垃圾回收效率提升了10%~19%,闪存擦除次数减少了10%~17%。In contrast, in the solution provided in the embodiment of the present application, the write amplification factor is reduced by 9% to 16%, the garbage collection efficiency is improved by 10% to 19%, and the number of flash memory erase times is reduced by 10% to 17%.
图13是本申请实施例提供的不同空间利用率下垃圾回收的效果的示意图。其中,本申请的方案和传统的方案是在UBIFS文件系统上的实现,如图13所示,使用本申请的方案(图中的虚线)与传统的方案(图中的实线)相比具有不同程度的性能优化。随着空间利用率的增加,两个文件系统的写放大均变得更加严重,垃圾回收的效率均降低,擦除次数均升高,但是可以看出本申请的方案在不同文件系统空间利用率下相较于传统的方案都具有优化作用。FIG13 is a schematic diagram of the effect of garbage collection under different space utilizations provided by an embodiment of the present application. Among them, the solution of the present application and the traditional solution are implemented on the UBIFS file system. As shown in FIG13 , the solution of the present application (dashed line in the figure) has different degrees of performance optimization compared with the traditional solution (solid line in the figure). As the space utilization increases, the write amplification of the two file systems becomes more serious, the efficiency of garbage collection decreases, and the number of erasures increases. However, it can be seen that the solution of the present application has an optimization effect compared with the traditional solution under different file system space utilizations.
本文中描述的各个实施例可以为独立的方案,也可以根据内在逻辑进行组合,这些方案都落入本申请的保护范围中。例如,方法600、方法700、方法800可以结合使用,也可以独立使用。例如,采用方法600、方法700实现热度等级的划分、闪存数据的分类存储,采用其他方式确定垃圾回收的对象 (目标擦除块);或者,采用其他方式实现热度等级的划分、闪存数据的分类存储,采用方法800确定垃圾回收的对象(目标擦除块);或者,采用方法600、方法700实现热度等级的划分、闪存数据的分类存储,采用方法800确定垃圾回收的对象(目标擦除块)。The various embodiments described herein may be independent solutions or may be combined according to internal logic, and these solutions all fall within the scope of protection of this application. For example, method 600, method 700, and method 800 may be used in combination or independently. For example, method 600 and method 700 may be used to implement the classification of heat levels and the classified storage of flash memory data, and other methods may be used to determine the objects for garbage collection. (target erase block); or, using other methods to implement the division of thermal levels and classified storage of flash memory data, and using method 800 to determine the object of garbage collection (target erase block); or, using method 600 or method 700 to implement the division of thermal levels and classified storage of flash memory data, and using method 800 to determine the object of garbage collection (target erase block).
以上,结合图5至图13详细说明了本申请实施例提供的方法。以下,结合图14详细说明本申请实施例提供的装置。应理解,装置实施例的描述与方法实施例的描述相互对应,因此,未详细描述的内容可以参见上文方法实施例,为了简洁,这里不再赘述。The method provided by the embodiment of the present application is described in detail above in conjunction with Figures 5 to 13. The device provided by the embodiment of the present application is described in detail below in conjunction with Figure 14. It should be understood that the description of the device embodiment corresponds to the description of the method embodiment. Therefore, the content not described in detail can be referred to the method embodiment above, and for the sake of brevity, it will not be repeated here.
图14是本申请实施例提供的装置1400的硬件结构示意图。图14所示的装置1400(该装置1400具体可以是一种电子设备)包括存储器1410、处理器1420、通信接口1430以及总线1440。其中,存储器1410、处理器1420、通信接口1430通过总线1440实现彼此之间的通信连接。FIG14 is a schematic diagram of the hardware structure of the device 1400 provided in an embodiment of the present application. The device 1400 shown in FIG14 (the device 1400 may be an electronic device) includes a memory 1410, a processor 1420, a communication interface 1430, and a bus 1440. The memory 1410, the processor 1420, and the communication interface 1430 are connected to each other through the bus 1440.
存储器1410可以是ROM,静态存储设备,动态存储设备或者RAM。存储器1410可以存储程序,当存储器1410中存储的程序被处理器1420执行时,处理器1420用于执行本申请实施例的垃圾回收的方法、页面存储的方法的各个步骤。The memory 1410 may be a ROM, a static storage device, a dynamic storage device or a RAM. The memory 1410 may store a program. When the program stored in the memory 1410 is executed by the processor 1420, the processor 1420 is used to execute the various steps of the garbage collection method and the page storage method of the embodiment of the present application.
处理器1420可以采用通用的CPU,微处理器,ASIC,GPU或者一个或多个集成电路,用于执行相关程序,以实现本申请实施例的装置1400中的单元所需执行的功能,或者执行本申请方法实施例的垃圾回收的方法、页面存储的方法。Processor 1420 can adopt a general-purpose CPU, microprocessor, ASIC, GPU or one or more integrated circuits to execute relevant programs to implement the functions required to be performed by the units in the device 1400 of the embodiment of the present application, or to execute the garbage collection method and page storage method of the method embodiment of the present application.
处理器1420还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,本申请的垃圾回收的方法、页面存储的方法的各个步骤可以通过处理器1420中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器1420还可以是通用处理器、DSP、ASIC、FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1410,处理器1420读取存储器1410中的信息,结合其硬件完成本申请实施例的装置1400中包括的单元所需执行的功能,或者执行本申请方法实施例的垃圾回收的方法、页面存储的方法。The processor 1420 may also be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the garbage collection method and the page storage method of the present application may be completed by an integrated logic circuit of hardware or software instructions in the processor 1420. The above-mentioned processor 1420 may also be a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in a decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1410, and the processor 1420 reads the information in the memory 1410, and combines its hardware to complete the functions required to be performed by the units included in the device 1400 of the embodiment of the present application, or executes the garbage collection method and page storage method of the method embodiment of the present application.
通信接口1430使用例如但不限于收发器一类的收发装置,来实现装置1400与其他设备或通信网络之间的通信。The communication interface 1430 uses a transceiver device such as but not limited to a transceiver to implement communication between the apparatus 1400 and other devices or a communication network.
总线1440可包括在装置1400各个部件(例如,存储器1410、处理器1420、通信接口1430)之间传送信息的通路。The bus 1440 may include a path for transmitting information between the various components of the device 1400 (eg, the memory 1410 , the processor 1420 , and the communication interface 1430 ).
应注意,尽管图14所示的装置1400仅仅示出了存储器、处理器、通信接口,但是在具体实现过程中,本领域的技术人员应当理解,装置1400还包括实现正常运行所必须的其他器件。同时,根据具体需要,本领域的技术人员应当理解,装置1400还可包括实现其他附加功能的硬件器件。此外,本领域的技术人员应当理解,装置1400也可仅仅包括实现本申请实施例所必须的器件,而不必包括图14中所示的全部器件。It should be noted that although the device 1400 shown in FIG. 14 only shows a memory, a processor, and a communication interface, in the specific implementation process, those skilled in the art should understand that the device 1400 also includes other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the device 1400 may also include hardware devices for implementing other additional functions. In addition, those skilled in the art should understand that the device 1400 may also only include the devices necessary for implementing the embodiments of the present application, and does not necessarily include all the devices shown in FIG. 14.
本申请实施例还提供一种芯片,所述芯片包括处理器和通信接口,所述通信接口用于接收信号,并将所述信号传输至所述处理器,所述处理器处理所述信号,使得如前文中任一种可能的实现方式中所述的垃圾回收的方法、页面存储的方法被执行。An embodiment of the present application also provides a chip, which includes a processor and a communication interface, wherein the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the garbage collection method and the page storage method described in any possible implementation method in the foregoing text are executed.
本实施例还提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机指令,当该计算机指令在计算机上运行时,使得上述实施例中的垃圾回收的方法、页面存储的方法被执行。This embodiment further provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on a computer, the garbage collection method and the page storage method in the above embodiments are executed.
本实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,使得上述实施例中的垃圾回收的方法、页面存储的方法被执行。This embodiment also provides a computer program product. When the computer program product runs on a computer, it enables the computer to execute the above-mentioned related steps, so that the garbage collection method and the page storage method in the above-mentioned embodiment are executed.
以上各个实施例可以单独使用,也可以相互结合使用,以实现不同的技术效果。The above embodiments may be used alone or in combination with each other to achieve different technical effects.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
本实施例可以根据上述方法示例对电子设备进行功能模块的划分,例如,可以对应各个功能划分 各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块可以采用硬件的形式实现。需要说明的是,本实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In this embodiment, the electronic device can be divided into functional modules according to the above method example. For example, each functional module can be divided into Each functional module may also integrate two or more functions into one processing module. The above integrated modules may be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。 The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims (23)

  1. 一种垃圾回收的方法,其特征在于,所述方法包括:A method for garbage collection, characterized in that the method comprises:
    根据第一擦除块中的垃圾页面的数量,以及第二擦除块中的垃圾页面的增速,得到第一分数;Obtaining a first score according to the number of garbage pages in the first erase block and the growth rate of garbage pages in the second erase block;
    根据所述第二擦除块中的垃圾页面的数量,以及所述第一擦除块中的垃圾页面的增速,得到第二分数;Obtaining a second score according to the number of garbage pages in the second erase block and the growth rate of garbage pages in the first erase block;
    在所述第一分数大于所述第二分数的情况下,对所述第一擦除块进行垃圾回收。When the first score is greater than the second score, garbage collection is performed on the first erase block.
  2. 根据权利要求1所述的方法,其特征在于,所述第一擦除块属于第一擦除块集合,所述第一擦除块为所述第一擦除块集合中垃圾页面的数量最大的擦除块,所述第一擦除块集合中的擦除块用于存储第一热度等级的页面,The method according to claim 1, characterized in that the first erase block belongs to a first erase block set, the first erase block is an erase block with the largest number of junk pages in the first erase block set, and the erase blocks in the first erase block set are used to store pages of a first heat level,
    所述第二擦除块属于第二擦除块集合,所述第二擦除块为所述第二擦除块集合中垃圾页面的数量最大的擦除块,所述第二擦除块集合中的擦除块用于存储第二热度等级的页面,所述第一热度等级的页面更新的频次与所述第二热度等级的页面更新的频次不同。The second erase block belongs to a second erase block set, the second erase block is the erase block with the largest number of garbage pages in the second erase block set, the erase blocks in the second erase block set are used to store pages of a second heat level, and the frequency of updating pages of the first heat level is different from the frequency of updating pages of the second heat level.
  3. 根据权利要求2所述的方法,其特征在于,所述方法还包括:The method according to claim 2, characterized in that the method further comprises:
    确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,所述重用距离为在第一页面相邻两次更新的时刻之间,对除所述第一页面外的其他页面进行的写操作的次数,所述至少两个热度等级包括所述第一热度等级和所述第二热度等级;Determine at least two heat levels and a range of reuse distances corresponding to each of the at least two heat levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent update moments of the first page, the at least two heat levels including the first heat level and the second heat level;
    确定所述每个热度等级对应的擦除块集合。Determine the erase block set corresponding to each thermal level.
  4. 根据权利要求3所述的方法,其特征在于,所述确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,包括:The method according to claim 3, characterized in that the determining of at least two heat levels and a range of reuse distances corresponding to each of the at least two heat levels comprises:
    获取在第一时间段内写入的多个页面的重用距离;Obtaining reuse distances of a plurality of pages written in a first time period;
    通过对所述多个页面的重用距离进行聚类,确定所述每个热度等级对应的重用距离的范围。The reuse distance range corresponding to each heat level is determined by clustering the reuse distances of the multiple pages.
  5. 根据权利要求3或4所述的方法,其特征在于,所述方法还包括:The method according to claim 3 or 4, characterized in that the method further comprises:
    根据第二页面在第二时间段内的一个或多个第一重用距离,预测所述第二页面的第二重用距离,所述第二重用距离用于指示所述第二页面在当前时刻和下一次更新的时刻之间,对除第二页面之外的其他页面进行写操作的次数;Predicting a second reuse distance of the second page according to one or more first reuse distances of the second page in a second time period, the second reuse distance being used to indicate the number of write operations performed by the second page on pages other than the second page between a current moment and a next update moment;
    根据所述第二重用距离和所述每个热度等级对应的重用距离的范围,确定所述第二页面所属的热度等级;Determining the heat level to which the second page belongs according to the second reuse distance and the range of the reuse distances corresponding to each heat level;
    将所述第二页面写入所述第二页面所属的热度等级对应的擦除块集合中的擦除块。The second page is written into an erase block in an erase block set corresponding to a thermal level to which the second page belongs.
  6. 根据权利要求1-5中任一项所述的方法,其特征在于,所述对所述第一擦除块进行垃圾回收,包括:The method according to any one of claims 1 to 5, characterized in that the garbage collection of the first erase block comprises:
    提取所述第一擦除块中的有效页面;extracting valid pages in the first erase block;
    将所述有效页面写入到第三擦除块中;Writing the valid page into a third erase block;
    擦除所述第一擦除块中的全部页面。All pages in the first erase block are erased.
  7. 根据权利要求1-6中任一项所述的方法,其特征在于,在对所述第一擦除块进行垃圾回收之后,所述方法还包括:The method according to any one of claims 1 to 6, characterized in that after performing garbage collection on the first erase block, the method further comprises:
    将第三页面写入到所述第一擦除块中,所述第三页面属于第三热度等级;writing a third page into the first erase block, the third page belonging to a third thermal level;
    将所述第一擦除块添加到所述第三热度等级对应的擦除块集合中。The first erase block is added to an erase block set corresponding to the third thermal level.
  8. 一种页面存储的方法,其特征在于,所述方法包括:A method for storing a page, characterized in that the method comprises:
    确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,所述重用距离为在第一页面相邻两次更新的时刻之间,对除所述第一页面外的其他页面进行的写操作的次数;Determine at least two heat levels and a range of reuse distances corresponding to each of the at least two heat levels, wherein the reuse distance is the number of write operations performed on pages other than the first page between two adjacent update moments of the first page;
    确定所述每个热度等级对应的擦除块集合,所述擦除块集合包括第一擦除块集合,所述至少两个热度等级包括第一热度等级,所述第一擦除块集合中的擦除块用于存储所述第一热度等级的页面。An erase block set corresponding to each thermal level is determined, the erase block set includes a first erase block set, the at least two thermal levels include a first thermal level, and the erase blocks in the first erase block set are used to store pages of the first thermal level.
  9. 根据权利要求8所述的方法,其特征在于,所述确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,包括: The method according to claim 8, characterized in that the determining of at least two heat levels and a range of reuse distances corresponding to each of the at least two heat levels comprises:
    获取在第一时间段内写入的多个页面的重用距离;Obtaining reuse distances of a plurality of pages written in a first time period;
    通过对所述多个页面的重用距离进行聚类,确定所述每个热度等级对应的重用距离的范围。The reuse distance range corresponding to each heat level is determined by clustering the reuse distances of the multiple pages.
  10. 根据权利要求8或9所述的方法,其特征在于,所述方法还包括:The method according to claim 8 or 9, characterized in that the method further comprises:
    根据第二页面在第一时间段内的第一重用距离,预测所述第二页面的第二重用距离,所述第二重用距离用于指示所述第二页面在当前时刻和下一次更新的时刻之间,对第二页面之外的其他页面进行写操作的次数;Predicting a second reuse distance of the second page according to a first reuse distance of the second page in the first time period, wherein the second reuse distance is used to indicate the number of write operations performed by the second page on pages other than the second page between a current moment and a next update moment;
    根据所述第二重用距离和所述每个热度等级对应的重用距离的范围,确定所述第二页面属于第一热度等级;Determining, according to the second reuse distance and a range of reuse distances corresponding to each heat level, that the second page belongs to the first heat level;
    将所述第二页面写入所述第一擦除块集合中的擦除块。The second page is written to an erase block in the first set of erase blocks.
  11. 一种电子设备,其特征在于,所述电子设备包括:An electronic device, characterized in that the electronic device comprises:
    一个或多个处理器;one or more processors;
    一个或多个存储器;one or more memories;
    所述一个或多个存储器存储有一个或多个计算机程序,所述一个或多个计算机程序包括指令,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The one or more memories store one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by the one or more processors, the electronic device performs the following steps:
    根据第一擦除块中的垃圾页面的数量,以及第二擦除块中的垃圾页面的增速,得到第一分数;Obtaining a first score according to the number of garbage pages in the first erase block and the growth rate of garbage pages in the second erase block;
    根据所述第二擦除块中的垃圾页面的数量,以及所述第一擦除块中的垃圾页面的增速,得到第二分数;Obtaining a second score according to the number of garbage pages in the second erase block and the growth rate of garbage pages in the first erase block;
    在所述第一分数大于所述第二分数的情况下,对所述第一擦除块进行垃圾回收。When the first score is greater than the second score, garbage collection is performed on the first erase block.
  12. 根据权利要求11所述的电子设备,其特征在于,所述第一擦除块属于第一擦除块集合,所述第一擦除块为所述第一擦除块集合中垃圾页面的数量最大的擦除块,所述第一擦除块集合中的擦除块用于存储第一热度等级的页面,The electronic device according to claim 11, characterized in that the first erase block belongs to a first erase block set, the first erase block is an erase block with the largest number of junk pages in the first erase block set, and the erase blocks in the first erase block set are used to store pages of a first heat level,
    所述第二擦除块属于第二擦除块集合,所述第二擦除块为所述第二擦除块集合中垃圾页面的数量最大的擦除块,所述第二擦除块集合中的擦除块用于存储第二热度等级的页面,所述第一热度等级的页面更新的频次与所述第二热度等级的页面更新的频次不同。The second erase block belongs to a second erase block set, the second erase block is the erase block with the largest number of garbage pages in the second erase block set, the erase blocks in the second erase block set are used to store pages of a second heat level, and the frequency of updating pages of the first heat level is different from the frequency of updating pages of the second heat level.
  13. 根据权利要求12所述的电子设备,其特征在于,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The electronic device according to claim 12, characterized in that when the instruction is executed by the one or more processors, the electronic device performs the following steps:
    确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,所述重用距离为在第一页面相邻两次更新的时刻之间,对除所述第一页面外的其他页面进行的写操作的次数,所述至少两个热度等级包括所述第一热度等级和所述第二热度等级;Determine at least two heat levels and a range of reuse distances corresponding to each of the at least two heat levels, the reuse distance being the number of write operations performed on pages other than the first page between two adjacent update moments of the first page, the at least two heat levels including the first heat level and the second heat level;
    确定所述每个热度等级对应的擦除块集合。Determine the erase block set corresponding to each thermal level.
  14. 根据权利要求13所述的电子设备,其特征在于,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The electronic device according to claim 13, characterized in that when the instruction is executed by the one or more processors, the electronic device performs the following steps:
    获取在第一时间段内写入的多个页面的重用距离;Obtaining reuse distances of a plurality of pages written in a first time period;
    通过对所述多个页面的重用距离进行聚类,确定所述每个热度等级对应的重用距离的范围。The reuse distance range corresponding to each heat level is determined by clustering the reuse distances of the multiple pages.
  15. 根据权利要求13或14所述的电子设备,其特征在于,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The electronic device according to claim 13 or 14, characterized in that when the instruction is executed by the one or more processors, the electronic device performs the following steps:
    根据第二页面在第二时间段内的一个或多个第一重用距离,预测所述第二页面的第二重用距离,所述第二重用距离用于指示所述第二页面在当前时刻和下一次更新的时刻之间,对除第二页面之外的其他页面进行写操作的次数;Predicting a second reuse distance of the second page according to one or more first reuse distances of the second page in a second time period, the second reuse distance being used to indicate the number of write operations performed by the second page on pages other than the second page between a current moment and a next update moment;
    根据所述第二重用距离和所述每个热度等级对应的重用距离的范围,确定所述第二页面所属的热度等级;Determining the heat level to which the second page belongs according to the second reuse distance and the range of the reuse distances corresponding to each heat level;
    将所述第二页面写入所述第二页面所属的热度等级对应的擦除块集合中的擦除块。The second page is written into an erase block in an erase block set corresponding to a thermal level to which the second page belongs.
  16. 根据权利要求11-15中任一项所述的电子设备,其特征在于,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The electronic device according to any one of claims 11 to 15, characterized in that when the instruction is executed by the one or more processors, the electronic device performs the following steps:
    提取所述第一擦除块中的有效页面;extracting valid pages in the first erase block;
    将所述有效页面写入到第三擦除块中;Writing the valid page into a third erase block;
    擦除所述第一擦除块中的全部页面。 All pages in the first erase block are erased.
  17. 根据权利要求11-16中任一项所述的电子设备,其特征在于,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The electronic device according to any one of claims 11 to 16, characterized in that when the instruction is executed by the one or more processors, the electronic device performs the following steps:
    将第三页面写入到所述第一擦除块中,所述第三页面属于第三热度等级;writing a third page into the first erase block, the third page belonging to a third thermal level;
    将所述第一擦除块添加到所述第三热度等级对应的擦除块集合中。The first erase block is added to an erase block set corresponding to the third thermal level.
  18. 一种电子设备,其特征在于,所述电子设备包括:An electronic device, characterized in that the electronic device comprises:
    一个或多个处理器;one or more processors;
    一个或多个存储器;one or more memories;
    所述一个或多个存储器存储有一个或多个计算机程序,所述一个或多个计算机程序包括指令,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The one or more memories store one or more computer programs, and the one or more computer programs include instructions. When the instructions are executed by the one or more processors, the electronic device performs the following steps:
    确定至少两个热度等级,以及所述至少两个热度等级中的每个热度等级对应的重用距离的范围,所述重用距离为在第一页面相邻两次更新的时刻之间,对除所述第一页面外的其他页面进行的写操作的次数;Determine at least two heat levels and a range of reuse distances corresponding to each of the at least two heat levels, wherein the reuse distance is the number of write operations performed on pages other than the first page between two adjacent update moments of the first page;
    确定所述每个热度等级对应的擦除块集合,所述擦除块集合包括第一擦除块集合,所述至少两个热度等级包括第一热度等级,所述第一擦除块集合中的擦除块用于存储所述第一热度等级的页面。An erase block set corresponding to each thermal level is determined, the erase block set includes a first erase block set, the at least two thermal levels include a first thermal level, and the erase blocks in the first erase block set are used to store pages of the first thermal level.
  19. 根据权利要求18所述的电子设备,其特征在于,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The electronic device according to claim 18, wherein when the instruction is executed by the one or more processors, the electronic device performs the following steps:
    获取在第一时间段内写入的多个页面的重用距离;Obtaining reuse distances of a plurality of pages written in a first time period;
    通过对所述多个页面的重用距离进行聚类,确定所述每个热度等级对应的重用距离的范围。The reuse distance range corresponding to each heat level is determined by clustering the reuse distances of the multiple pages.
  20. 根据权利要求18或19所述的电子设备,其特征在于,当所述指令被所述一个或多个处理器执行时,使得所述电子设备执行以下步骤:The electronic device according to claim 18 or 19, characterized in that when the instruction is executed by the one or more processors, the electronic device performs the following steps:
    根据第二页面在第一时间段内的第一重用距离,预测所述第二页面的第二重用距离,所述第二重用距离用于指示所述第二页面在当前时刻和下一次更新的时刻之间,对第二页面之外的其他页面进行写操作的次数;Predicting a second reuse distance of the second page according to a first reuse distance of the second page in the first time period, wherein the second reuse distance is used to indicate the number of write operations performed by the second page on pages other than the second page between a current moment and a next update moment;
    根据所述第二重用距离和所述每个热度等级对应的重用距离的范围,确定所述第二页面属于第一热度等级;Determining, according to the second reuse distance and a range of reuse distances corresponding to each heat level, that the second page belongs to the first heat level;
    将所述第二页面写入所述第一擦除块集合中的擦除块。The second page is written to an erase block in the first set of erase blocks.
  21. 一种芯片,其特征在于,所述芯片包括处理器和通信接口,所述通信接口用于接收信号,并将所述信号传输至所述处理器,所述处理器处理所述信号,使得如权利要求1至10中任一项所述的方法被执行。A chip, characterized in that the chip includes a processor and a communication interface, the communication interface is used to receive a signal and transmit the signal to the processor, and the processor processes the signal so that the method as described in any one of claims 1 to 10 is executed.
  22. 一种计算机可读存储介质,其特征在于,包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1至10中任一项所述的方法。A computer-readable storage medium, characterized in that it includes computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method as claimed in any one of claims 1 to 10.
  23. 一种计算机程序产品,其特征在于,所述计算机程序产品包括:计算机程序代码,当所述计算机程序代码被运行时,实现如权利要求1至10中任一项所述的方法。 A computer program product, characterized in that the computer program product comprises: a computer program code, and when the computer program code is executed, the method according to any one of claims 1 to 10 is implemented.
PCT/CN2023/105033 2022-10-28 2023-06-30 Garbage collection method, page storage method, and electronic device WO2024087724A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211337526.X 2022-10-28
CN202211337526.XA CN117369712A (en) 2022-10-28 2022-10-28 Garbage recycling method, page storage method and electronic equipment

Publications (1)

Publication Number Publication Date
WO2024087724A1 true WO2024087724A1 (en) 2024-05-02

Family

ID=89401041

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/105033 WO2024087724A1 (en) 2022-10-28 2023-06-30 Garbage collection method, page storage method, and electronic device

Country Status (2)

Country Link
CN (1) CN117369712A (en)
WO (1) WO2024087724A1 (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016192025A (en) * 2015-03-31 2016-11-10 日本電気株式会社 Ssd storage system, and writing response deterioration prevention control method and program thereof
CN110618792A (en) * 2019-09-17 2019-12-27 深圳忆联信息系统有限公司 Internal task optimization method and device based on solid state disk and computer equipment
CN111459710A (en) * 2020-03-27 2020-07-28 华中科技大学 Erasure code memory recovery method, device and memory system capable of sensing heat degree and risk
CN112835811A (en) * 2019-11-25 2021-05-25 爱思开海力士有限公司 Memory system and operating method thereof
CN113010091A (en) * 2019-12-20 2021-06-22 华为技术有限公司 Method for writing data into solid state disk, and method and device for garbage collection
CN114138189A (en) * 2021-11-17 2022-03-04 厦门大学 Method for accelerating sub-block erasure in 3D NAND flash memory

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9645924B2 (en) * 2013-12-16 2017-05-09 International Business Machines Corporation Garbage collection scaling
CN110347612A (en) * 2019-06-04 2019-10-18 华南理工大学 A kind of dynamic adjustment rubbish recovering method suitable for solid-state disk
CN112463057A (en) * 2020-11-28 2021-03-09 济南华芯算古信息科技有限公司 Intelligent garbage recycling method and device compatible with NVMe solid state disk

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016192025A (en) * 2015-03-31 2016-11-10 日本電気株式会社 Ssd storage system, and writing response deterioration prevention control method and program thereof
CN110618792A (en) * 2019-09-17 2019-12-27 深圳忆联信息系统有限公司 Internal task optimization method and device based on solid state disk and computer equipment
CN112835811A (en) * 2019-11-25 2021-05-25 爱思开海力士有限公司 Memory system and operating method thereof
CN113010091A (en) * 2019-12-20 2021-06-22 华为技术有限公司 Method for writing data into solid state disk, and method and device for garbage collection
CN111459710A (en) * 2020-03-27 2020-07-28 华中科技大学 Erasure code memory recovery method, device and memory system capable of sensing heat degree and risk
CN114138189A (en) * 2021-11-17 2022-03-04 厦门大学 Method for accelerating sub-block erasure in 3D NAND flash memory

Also Published As

Publication number Publication date
CN117369712A (en) 2024-01-09

Similar Documents

Publication Publication Date Title
CN111506262B (en) Storage system, file storage and reading method and terminal equipment
CN110554999B (en) Cold and hot attribute identification and separation method and device based on log file system and flash memory device and related products
WO2022262530A1 (en) Memory management method and electronic device
WO2021036370A1 (en) Method and device for pre-reading file page, and terminal device
CN114185494B (en) Memory anonymous page processing method, electronic device and readable storage medium
CN113132526B (en) Page drawing method and related device
WO2022194190A1 (en) Method and apparatus for adjusting numerical range of recognition parameter of touch gesture
WO2021218370A1 (en) Memory management method and terminal device
CN114968836A (en) Garbage recycling method and electronic equipment
WO2024087724A1 (en) Garbage collection method, page storage method, and electronic device
EP2973008A1 (en) Grouping files for optimized file operations
CN116701298A (en) File system management method and electronic equipment
CN114077529A (en) Log uploading method and device, electronic equipment and computer readable storage medium
CN111459462B (en) Decentralized relock demotion
CN114579954A (en) Method for safely starting verification and electronic equipment
CN114968546A (en) Load processing method and related device
CN115794361A (en) Method for managing memory and electronic equipment
CN113485969A (en) Storage fragmentation method and device, terminal and computer storage medium
CN116049021B (en) Storage space management method, electronic device, and computer-readable storage medium
WO2019091322A1 (en) Virtual machine snapshot processing method, apparatus and system
CN116089109B (en) Step counting data transmission method and related device
CN115016714B (en) Electronic device control method, system, electronic device and storage medium
WO2023045695A1 (en) Display driving method based on frame data, and electronic device and storage medium
CN116089368B (en) File searching method and related device
CN116662222A (en) Cache management method and related equipment