WO2023065915A1 - 存储方法、装置、设备及存储介质 - Google Patents

存储方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2023065915A1
WO2023065915A1 PCT/CN2022/119444 CN2022119444W WO2023065915A1 WO 2023065915 A1 WO2023065915 A1 WO 2023065915A1 CN 2022119444 W CN2022119444 W CN 2022119444W WO 2023065915 A1 WO2023065915 A1 WO 2023065915A1
Authority
WO
WIPO (PCT)
Prior art keywords
cache
capacity
space
storage device
file
Prior art date
Application number
PCT/CN2022/119444
Other languages
English (en)
French (fr)
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 WO2023065915A1 publication Critical patent/WO2023065915A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0877Cache access modes
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the embodiments of the present application relate to the field of electronic equipment, and in particular, to a storage method, device, device, and storage medium.
  • Solid state flash storage device solid state disk, SSD
  • solid state disk solid state hard drive
  • the storage density of SSD is gradually increasing.
  • the usage mode of the storage unit of SSD has gradually increased from single-level cell (SLC) mode to double-level cell (multi-level cell, MLC) mode, triple-level cell (triple-level cell, TLC) mode, Four-level cell (quad-level cell, QLC) mode, etc.
  • SLC single-level cell
  • MLC multi-level cell
  • TLC triple-level cell
  • QLC quad-level cell
  • the increase in the storage density of SSD can make the capacity of SSD larger and the cost lower, but the input and output (IO) performance (that is, read and write performance) of SSD will drop significantly.
  • IO input and output
  • Hybrid SSDs may include: hybrid SSDs with static SLC capacity and hybrid SSDs with dynamic SLC capacity.
  • the storage space of a hybrid SSD with static SLC capacity may include: a QLC area and a static SLC area, and the size of the static SLC area is fixed.
  • the storage space of the hybrid SSD with dynamic SLC capacity can include: QLC area, dynamic SLC area, and static SLC area.
  • the size of the static SLC area is also fixed, and the overall space usage of the hybrid SSD with dynamic SLC capacity gradually increases. , some areas in the dynamic SLC area can be switched to work in the multi-layer cell mode, and the dynamic SLC area will gradually decrease.
  • Embodiments of the present application provide a storage method, device, device, and storage medium, wherein the method can adjust the size of the maximum available cache space of the storage device according to the overall space usage rate of the storage device.
  • the method can adjust the size of the maximum available cache space of the storage device according to the overall space usage rate of the storage device.
  • the overall space usage of the storage device can be reduced, the size of the available single-level unit cache space in the storage device can be maintained, and the read and write performance of the storage device can be improved.
  • the embodiment of the present application provides a storage method, the method including: obtaining the overall space usage rate of the storage device; ;
  • the overall space usage rate is determined according to the size of the storage space of the storage device and the size of the used area in the storage space of the storage device.
  • adjust the size of the maximum available cache space of the storage device is the maximum storage space allowed to be occupied by the cached data when storing the cached data in the storage device.
  • the size of the dynamic single-layer unit area is the fourth capacity, and the adjusted maximum available cache space is the first value; when the overall space utilization rate is the second overall space In terms of utilization, the size of the dynamic single-layer unit area is the fifth capacity, and the adjusted maximum available cache space is the second value; the second overall space utilization is greater than the first overall space utilization, and the fifth capacity is smaller than the fourth Capacity, the second value is less than the first value.
  • the storage method by controlling the maximum available cache space, the overall space usage of the storage device can be reduced, the size of the available SLC cache space can be maintained, and the IO performance of the storage device can be improved.
  • the size of the maximum available cache space is equal to the first capacity
  • the first capacity is less than or equal to the maximum single-level unit capacity of the storage device and greater than the storage
  • the capacity of the static single-level unit area of the device; the maximum single-level unit capacity is the sum of the capacity of the dynamic single-level unit area and the static single-level unit area when the dynamic single-level unit area of the storage device is the largest.
  • the size of the maximum available cache space decreases as the overall space usage rate increases; the second threshold is greater than the first threshold.
  • the size of the maximum available cache space is equal to the second capacity, and the second capacity is less than or equal to the third capacity;
  • the third capacity is the capacity of the static single-layer unit area of the storage device, or , the capacity of the remaining available storage space of the storage device, or the smaller value of the capacity of the static single-layer unit area of the storage device and the capacity of the remaining available storage space;
  • the remaining available storage space of the storage device refers to the The remaining space after the space occupied by data, regular data includes data generated by local users of the electronic device where the storage device is located.
  • the first threshold is equal to the maximum overall space usage rate corresponding to the maximum single-layer unit capacity of the storage device; the second threshold is equal to the minimum overall space usage rate corresponding to the minimum single-layer unit capacity of the storage device.
  • the first threshold is less than or greater than the maximum overall space usage rate corresponding to the maximum single-level unit capacity of the storage device; the second threshold is less than or greater than the minimum overall space usage rate corresponding to the minimum single-level unit capacity of the storage device. space usage.
  • the adjusting the size of the maximum available cache space of the storage device according to the overall space usage includes: when the overall space usage is greater than the first threshold and smaller than the second threshold, the overall space When the usage rate changes to the third threshold, the size of the maximum available cache space of the storage device is adjusted according to the overall space usage rate.
  • the third threshold as 5% as an example, when the overall space usage is greater than the first threshold and smaller than the second threshold, when the overall space usage increases by 5%, the maximum availability of the storage device according to the overall space usage The size of the cache space is adjusted.
  • the method further includes: receiving a file request from a first application program, where the file request is used to request a first file; the first application program is an application program in the internal memory of the electronic device where the storage device is located ; When neither the cache space of the memory nor the cache space of the storage device caches the first file, obtain the first file from the server and cache it in the cache space of the memory; The second file is deleted from the storage device; the second file is cached in the cache space of the storage device; the storage space occupied by the cached data stored in the cache space of the storage device does not exceed the maximum available cache space.
  • the method further includes: when the first file is cached in the cache space of the memory, reading the first file from the cache space of the memory and returning it to the first application program; When the first file is cached, the first file is read from the cache space of the storage device and returned to the first application program.
  • the method further includes: dynamically adjusting the conditions for storing the cached files in the storage device according to the overall space usage rate.
  • the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third value, and/or, the cache file is less than or equal to the fourth value; when the overall space usage rate is the fourth overall space usage rate, the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the fourth value Five values, and/or, the size of the cache file is less than or equal to the sixth value; the fourth overall space utilization rate is greater than the third overall space utilization rate, the fifth value is greater than the third value, and the sixth value is less than the fourth value.
  • the method dynamically adjusts the condition that the cache file can be stored in the cache space of the storage device, can control the file writing to the storage device, and maintain the IO performance of the storage device in a good state.
  • the adjusted condition when the overall space usage rate is less than or equal to the first threshold, includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the first threshold number, and/or, the size of the cache file is less than or equal to the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the second number, and/or , the size of the cache file is less than or equal to the second byte; the second threshold is greater than the first threshold; the second number is greater than the first number, and the second byte is smaller than the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third number of times, and/or, the cache file The size is less than or equal to the third byte; the third degree is greater than the second degree, and the third byte is less than the second byte.
  • the second number increases as the overall space usage increases, and/or the second byte decreases as the overall space usage increases.
  • the method further includes: receiving a file request from a first application program, where the file request is used to request a first file; the first application program is an application program in the internal memory of the electronic device where the storage device is located ; When neither the cache space of the memory nor the cache space of the storage device caches the first file, obtain the first file from the server and cache it in the cache space of the memory; excluding the second file; when the second file meets the adjusted condition, cache the second file into the cache space of the storage device.
  • an embodiment of the present application provides a storage device, which can be applied to an electronic device, so that the electronic device implements the storage method described in the first aspect and any possible implementation manner of the first aspect.
  • the functions of the device can be realized by hardware, and can also be realized by executing corresponding software by hardware.
  • the hardware or software includes one or more modules or units corresponding to the first aspect and the steps in the storage method described in any possible implementation manner of the first aspect.
  • the apparatus may include: an acquisition unit, a processing unit, and the like.
  • the acquisition unit and the processing unit can cooperate to implement the first aspect and the storage method in any possible implementation manner of the first aspect.
  • the acquisition unit can be used to obtain the overall space usage rate of the storage device;
  • the storage device includes working in the multi-layer unit area, the dynamic single-level unit area, and the static single-level unit area;
  • the overall space usage rate is based on the storage device's storage The size of the space and the size of the used area in the storage space of the storage device.
  • the processing unit can be used to adjust the size of the maximum available cache space of the storage device according to the overall space utilization rate; the maximum available cache space is the maximum storage space allowed to be occupied by the cached data when storing the cached data in the storage device.
  • the size of the dynamic single-layer unit area is the fourth capacity, and the adjusted maximum available cache space is the first value; when the overall space utilization rate is the second overall space In terms of utilization, the size of the dynamic single-layer unit area is the fifth capacity, and the adjusted maximum available cache space is the second value; the second overall space utilization is greater than the first overall space utilization, and the fifth capacity is smaller than the fourth Capacity, the second value is less than the first value.
  • the size of the maximum available cache space is equal to the first capacity
  • the first capacity is less than or equal to the maximum single-level unit capacity of the storage device and greater than the storage
  • the capacity of the static single-level unit area of the device; the maximum single-level unit capacity is the sum of the capacity of the dynamic single-level unit area and the static single-level unit area when the dynamic single-level unit area of the storage device is the largest.
  • the size of the maximum available cache space decreases as the overall space usage rate increases; the second threshold is greater than the first threshold.
  • the size of the maximum available cache space is equal to the second capacity, and the second capacity is less than or equal to the third capacity;
  • the third capacity is the capacity of the static single-layer unit area of the storage device, or , the capacity of the remaining available storage space of the storage device, or the smaller value of the capacity of the static single-layer unit area of the storage device and the capacity of the remaining available storage space;
  • the remaining available storage space of the storage device refers to the The remaining space after the space occupied by data, regular data includes data generated by local users of the electronic device where the storage device is located.
  • the first threshold is equal to the maximum overall space usage rate corresponding to the maximum single-layer unit capacity of the storage device; the second threshold is equal to the minimum overall space usage rate corresponding to the minimum single-layer unit capacity of the storage device.
  • the first threshold is less than or greater than the maximum overall space usage rate corresponding to the maximum single-level unit capacity of the storage device; the second threshold is less than or greater than the minimum overall space usage rate corresponding to the minimum single-level unit capacity of the storage device. space usage.
  • the processing unit is specifically configured to, when the overall space usage rate is greater than a first threshold and smaller than a second threshold, and when the overall space usage rate changes by a third threshold, according to the overall space usage rate, Adjust the size of the maximum available cache space.
  • the processing unit is further configured to receive a file request from a first application program, where the file request is used to request a first file;
  • the first application program is an application program in the memory of the electronic device where the storage device is located ;
  • the second file is deleted from the storage device;
  • the second file is cached in the cache space of the storage device; the storage space occupied by the cached data stored in the cache space of the storage device does not exceed the maximum available cache space.
  • the processing unit is further configured to, when the first file is cached in the cache space of the memory, read the first file from the cache space of the memory and return it to the first application program; When the first file is cached, the first file is read from the cache space of the storage device and returned to the first application program.
  • the processing unit is further configured to dynamically adjust the conditions for storing the cached files in the storage device according to the overall space utilization rate.
  • the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third value, and/or, the cache file is less than or equal to the fourth value; when the overall space usage rate is the fourth overall space usage rate, the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the fourth value Five values, and/or, the size of the cache file is less than or equal to the sixth value; the fourth overall space utilization rate is greater than the third overall space utilization rate, the fifth value is greater than the third value, and the sixth value is less than the fourth value.
  • the adjusted condition when the overall space usage rate is less than or equal to the first threshold, includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the first threshold number, and/or, the size of the cache file is less than or equal to the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the second number, and/or , the size of the cache file is less than or equal to the second byte; the second threshold is greater than the first threshold; the second number is greater than the first number, and the second byte is smaller than the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third number of times, and/or, the cache file The size is less than or equal to the third byte; the third degree is greater than the second degree, and the third byte is less than the second byte.
  • the second number increases as the overall space usage increases, and/or the second byte decreases as the overall space usage increases.
  • the processing unit is further configured to receive a file request from a first application program, where the file request is used to request a first file;
  • the first application program is an application program in the memory of the electronic device where the storage device is located ;
  • the acquisition unit and the processing unit can cooperate to realize the functions corresponding to all the steps of the storage method described in the first aspect and any possible implementation manner of the first aspect, which will not be repeated here.
  • the embodiment of the present application provides an electronic device, and the electronic device may include a storage device.
  • the electronic device includes: a processor, a memory for storing processor-executable instructions; when the processor is configured to execute the instructions, the electronic device implements the first aspect and any possible implementation manner of the first aspect. storage method described above.
  • an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored; when the computer program instructions are executed by an electronic device, the electronic device realizes the first aspect and the first aspect.
  • the embodiment of the present application provides a computer program product, including computer readable code, or a non-volatile computer readable storage medium bearing computer readable code, when the computer readable code is stored in an electronic device During operation, the processor in the electronic device implements the storage method according to the first aspect and any possible implementation manner of the first aspect.
  • the embodiment of the present application provides a storage method, the method comprising: obtaining the overall space usage rate of the storage device; ;
  • the overall space usage rate is determined according to the size of the storage space of the storage device and the size of the used area in the storage space of the storage device. According to the overall space usage, the conditions for storing cached files in the storage device are dynamically adjusted.
  • the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third value, and/or, the size of the cache file is less than or equal to the fourth value; when the overall space utilization rate is the fourth overall space utilization rate, the size of the dynamic single-layer unit area is the fifth capacity, and the adjusted The conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the fifth value, and/or, the size of the cache file is less than or equal to the sixth value; the fourth overall space usage rate is greater than the fifth value; Three overall space utilization ratios, the fifth capacity is less than the fourth capacity, the fifth value is greater than the third value, and the sixth value is less than the fourth value.
  • the method dynamically adjusts the condition that the cache file can be stored in the cache space of the storage device, can control the file writing to the storage device, and maintain the IO performance of the storage device in a good state.
  • the adjusted condition when the overall space usage rate is less than or equal to the first threshold, includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the first threshold number, and/or, the size of the cache file is less than or equal to the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the second number, and/or , the size of the cache file is less than or equal to the second byte; the second threshold is greater than the first threshold; the second number is greater than the first number, and the second byte is smaller than the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third number of times, and/or, the cache file The size is less than or equal to the third byte; the third degree is greater than the second degree, and the third byte is less than the second byte.
  • the first threshold is equal to the maximum overall space usage rate corresponding to the maximum single-layer unit capacity of the storage device; the second threshold is equal to the minimum overall space usage rate corresponding to the minimum single-layer unit capacity of the storage device.
  • the first threshold is less than or greater than the maximum overall space usage rate corresponding to the maximum single-level unit capacity of the storage device; the second threshold is less than or greater than the minimum overall space usage rate corresponding to the minimum single-level unit capacity of the storage device. space usage.
  • the second number increases as the overall space usage increases, and/or the second byte decreases as the overall space usage increases.
  • the method further includes: receiving a file request from a first application program, where the file request is used to request a first file; the first application program is an application program in the internal memory of the electronic device where the storage device is located ; When neither the cache space of the memory nor the cache space of the storage device caches the first file, obtain the first file from the server and cache it in the cache space of the memory; excluding the second file; when the second file meets the adjusted condition, cache the second file into the cache space of the storage device.
  • the method further includes: when the first file is cached in the cache space of the memory, reading the first file from the cache space of the memory and returning it to the first application program; When the first file is cached, the first file is read from the cache space of the storage device and returned to the first application program.
  • an embodiment of the present application provides a storage device, which can be applied to an electronic device, so that the electronic device implements the storage method described in the sixth aspect and any possible implementation manner of the sixth aspect.
  • the functions of the device can be realized by hardware, and can also be realized by executing corresponding software by hardware.
  • the hardware or software includes one or more modules or units corresponding to the sixth aspect and the steps in the storage method described in any possible implementation manner of the sixth aspect.
  • the apparatus may include: an acquisition unit, a processing unit, and the like.
  • the acquisition unit and the processing unit can cooperate to implement the storage method according to the sixth aspect and any possible implementation manner of the sixth aspect.
  • acquisition unit which can be used to obtain the overall space usage of the storage device
  • the storage device includes working in the multi-layer unit area, the dynamic single-layer unit area, and the static single-layer unit area
  • the overall space usage is based on the storage of the storage device
  • the processing unit can be used to dynamically adjust the conditions for storing the cached files in the storage device according to the overall space utilization rate.
  • the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third value, and/or, the size of the cache file is less than or equal to the fourth value; when the overall space utilization rate is the fourth overall space utilization rate, the size of the dynamic single-layer unit area is the fifth capacity, and the adjusted The conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the fifth value, and/or, the size of the cache file is less than or equal to the sixth value; the fourth overall space usage rate is greater than the fifth value; Three overall space utilization ratios, the fifth capacity is less than the fourth capacity, the fifth value is greater than the third value, and the sixth value is less than the fourth value.
  • the adjusted condition when the overall space usage rate is less than or equal to the first threshold, includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the first threshold number, and/or, the size of the cache file is less than or equal to the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the second number, and/or , the size of the cache file is less than or equal to the second byte; the second threshold is greater than the first threshold; the second number is greater than the first number, and the second byte is smaller than the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third number of times, and/or, the cache file The size is less than or equal to the third byte; the third degree is greater than the second degree, and the third byte is less than the second byte.
  • the first threshold is equal to the maximum overall space usage rate corresponding to the maximum single-layer unit capacity of the storage device; the second threshold is equal to the minimum overall space usage rate corresponding to the minimum single-layer unit capacity of the storage device.
  • the first threshold is less than or greater than the maximum overall space usage rate corresponding to the maximum single-level unit capacity of the storage device; the second threshold is less than or greater than the minimum overall space usage rate corresponding to the minimum single-level unit capacity of the storage device. space usage.
  • the second number increases as the overall space usage increases, and/or the second byte decreases as the overall space usage increases.
  • the processing unit is further configured to receive a file request from a first application program, where the file request is used to request a first file;
  • the first application program is an application program in the memory of the electronic device where the storage device is located ;
  • the processing unit is further configured to, when the first file is cached in the cache space of the memory, read the first file from the cache space of the memory and return it to the first application program; When the first file is cached, the first file is read from the cache space of the storage device and returned to the first application program.
  • the acquisition unit and the processing unit can cooperate to realize the functions corresponding to all the steps of the storage method described in the sixth aspect and any possible implementation manner of the sixth aspect, which will not be repeated here.
  • the embodiment of the present application provides an electronic device, and the electronic device may include a storage device.
  • the electronic device includes: a processor, a memory for storing processor-executable instructions; when the processor is configured to execute the instructions, the electronic device implements the sixth aspect and any possible implementation manner of the sixth aspect. storage method described above.
  • the embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored; when the computer program instructions are executed by the electronic device, the electronic device realizes the sixth aspect and the sixth aspect.
  • the embodiment of the present application provides a computer program product, including computer readable code, or a non-volatile computer readable storage medium carrying computer readable code, when the computer readable code is stored in an electronic device During operation, the processor in the electronic device implements the storage method according to the sixth aspect and any possible implementation manner of the sixth aspect.
  • FIG. 1 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
  • FIG. 2 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
  • FIG. 3 is a schematic flow diagram of a storage method provided in an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a storage space of a hybrid SSD with a dynamic SLC capacity provided by an embodiment of the present application
  • Fig. 5 is a schematic diagram of the relationship between the SLC capacity and the overall space utilization ratio provided by the embodiment of the present application;
  • FIG. 6 is a schematic composition diagram of a storage device of an electronic device provided by an embodiment of the present application.
  • FIG. 7 is another schematic flowchart of a storage method provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of a storage device provided by an embodiment of the present application.
  • FIG. 9 is another schematic structural diagram of a storage device provided by an embodiment of the present application.
  • references to "one embodiment” or “some embodiments” or the like in this specification means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application.
  • appearances of the phrases “in one embodiment,” “in some embodiments,” “in other embodiments,” “in other embodiments,” etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean “one or more but not all embodiments” unless specifically stated otherwise.
  • the terms “including”, “comprising”, “having” and variations thereof mean “including but not limited to”, unless specifically stated otherwise.
  • the term “connected” includes both direct and indirect connections, unless otherwise stated.
  • first and second are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of indicated technical features. Thus, a feature defined as “first” and “second” may explicitly or implicitly include one or more of these features.
  • Solid state flash storage device solid state disk, SSD
  • solid state disk solid state hard drive
  • the storage density of SSD is gradually increasing.
  • the usage mode of the storage unit of SSD has gradually increased from single-level cell (SLC) mode to double-level cell (multi-level cell, MLC) mode, triple-level cell (triple-level cell, TLC) mode, Four-level cell (quad-level cell, QLC) mode, etc.
  • each storage unit of SSD in SLC mode can store one bit of data
  • each storage unit of SSD in MLC mode can store two bits of data
  • each storage unit of SSD in TLC mode can store three bits of data
  • each memory cell of an SSD can store four bits of data.
  • the method of mixing high-speed media and low-speed media in the SSD can optimize the IO performance of the SSD.
  • Using mixed high-speed media and low-speed media in SSD means that SSD can include high-speed media and low-speed media, and SSDs use high-speed media to meet read and write requirements.
  • high-speed media can be storage media using SLC mode
  • low-speed media can be used Storage media in multi-layer cell mode such as MLC, TLC, and QLC. That is, the storage space of the SSD using mixed high-speed media and low-speed media may include a multi-level cell area and an SLC area.
  • the foregoing SSD using mixed high-speed media and low-speed media may be called a hybrid SSD.
  • the hybrid SSD may include: a hybrid SSD with a static SLC capacity, and a hybrid SSD with a dynamic SLC capacity.
  • a hybrid SSD with a static SLC capacity a hybrid SSD with a dynamic SLC capacity
  • FIG. 1 is a schematic diagram of the composition of a storage space of a hybrid SSD. Wherein, (a) in FIG. 1 shows a hybrid SSD with a static SLC capacity, and (b) in FIG. 1 shows a hybrid SSD with a dynamic SLC capacity.
  • the storage space of a hybrid SSD with a static SLC capacity may include: a QLC area 101 and a static SLC area 102 .
  • the size of the static SLC area 102 is fixed, and the static SLC area 102 can be used as a read-write buffer area of the hybrid SSD with the entire static SLC capacity.
  • the storage space of the hybrid SSD with dynamic SLC capacity may include: a QLC area 103 , a dynamic SLC area 104 , and a static SLC area 105 .
  • the flash memory blocks in the dynamic SLC area 104 originally work in the QLC mode, but these flash memory blocks can be converted to the SLC mode, so the area formed by this part of the flash memory blocks after being converted to the SLC mode can be called the dynamic SLC area 104 .
  • the hybrid SSD with static SLC capacity shown in (a) in FIG. 1 in the hybrid SSD with dynamic SLC capacity shown in (b) in FIG.
  • the size of the static SLC area 105 is also fixed, However, the size of the dynamic SLC region 104 is variable. As the overall space usage rate of the hybrid SSD with dynamic SLC capacity gradually increases, some areas in the dynamic SLC area 104 will switch to work in QLC mode (that is, they will be converted into QLC area 103), and the dynamic SLC area 104 will gradually decrease. . As the overall space usage rate of the hybrid SSD with dynamic SLC capacity gradually decreases, some areas in the dynamic SLC area 104 switched to QLC mode will switch back to the SLC area, and the dynamic SLC area 104 will gradually increase.
  • the overall space usage rate of the hybrid SSD with dynamic SLC capacity may be: the ratio of the storage space of the hybrid SSD with dynamic SLC capacity between the used area and all areas (including the used area and the unused area).
  • the dynamic SLC area 104 and the static SLC area 105 can be used as read and write buffer areas of the hybrid SSD with the entire dynamic SLC capacity.
  • hybrid SSDs with dynamic SLC capacity have a larger read and write buffer area and better IO performance.
  • the embodiment of the present application provides a storage method, which can dynamically adjust the maximum available cache space of the hybrid SSD with dynamic SLC capacity according to the overall space usage rate of the hybrid SSD with dynamic SLC capacity , optimize the IO performance of the hybrid SSD with dynamic SLC capacity.
  • the overall space usage rate of the hybrid SSD with dynamic SLC capacity can be represented by the ratio of the used area to the total area in the storage space of the hybrid SSD with dynamic SLC capacity.
  • the used area in the storage space of the hybrid SSD with dynamic SLC capacity refers to: the area storing regular data and the area storing cached data in the storage space of the hybrid SSD with dynamic SLC capacity.
  • the maximum available cache space refers to the maximum storage space allowed for cache data when storing cache data in a hybrid SSD with dynamic SLC capacity.
  • a hybrid SSD with a dynamic SLC capacity can be used as a storage device of an electronic device (such as a mobile phone).
  • Regular data can include: data generated by a local user of the electronic device, and cached data can include: the electronic device requests data in order to improve performance and store remote data locally.
  • the operating system of the mobile phone can run various networked applications, such as chat software, network video players, etc. These networked applications often need to request data files from the network end (that is, the remote end), and
  • the memory space of mobile phones is usually small, and it is difficult to meet the file caching requirements of all applications. If each file request of an application passes through the network, it will cause unbearable performance degradation. Therefore, the mobile phone can improve data request performance by storing data files as cached data in the local SSD.
  • the method may be applied to the above-mentioned electronic device using a hybrid SSD with dynamic SLC capacity as a storage device.
  • the electronic device may include: a terminal device, a server, or a virtual machine (virtual machine, VM), etc.
  • Terminal devices can be mobile phones, tablet computers, desktops, laptops, handheld computers, notebook computers, ultra-mobile personal computers (ultra-mobile personal computers, UMPCs), netbooks, and cellular phones, personal digital assistants (personal digital assistants, PDA), augmented reality (augmented reality, AR) ⁇ virtual reality (virtual reality, VR) equipment and other equipment, the embodiment of the present application does not make special restrictions on the specific form of the electronic equipment.
  • FIG. 2 is a schematic structural diagram of the electronic device provided by the embodiment of the present application.
  • the electronic device may include: a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (universal serial bus, USB) interface 230, a charging management module 240, a power management module 241, and a battery 242 , antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, audio module 270, speaker 270A, receiver 270B, microphone 270C, earphone jack 270D, sensor module 280, button 290, motor 291, indicator 292, camera 293 , a display screen 294, and a subscriber identification module (subscriber identification module, SIM) card interface 295, etc.
  • SIM subscriber identification module
  • the processor 210 may include one or more processing units, for example: the processor 210 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU) wait. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processing unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller memory
  • video codec digital signal processor
  • DSP digital signal processor
  • baseband processor baseband processor
  • neural network processor neural-network processing unit, NPU
  • the controller may be the nerve center and command center of the electronic equipment.
  • the controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.
  • a memory may also be provided in the processor 210 for storing instructions and data.
  • the memory in processor 210 is a cache memory.
  • the memory may hold instructions or data that the processor 210 has just used or recycled.
  • processor 210 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transmitter (universal asynchronous receiver/transmitter, UART) interface, mobile industry processor interface (mobile industry processor interface, MIPI), general-purpose input and output (general-purpose input/output, GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and /or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input and output
  • subscriber identity module subscriber identity module
  • SIM subscriber identity module
  • USB universal serial bus
  • the interface connection relationship among the modules shown in this embodiment is only a schematic illustration, and does not constitute a structural limitation of the electronic device.
  • the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
  • the charging management module 240 is configured to receive charging input from the charger. While the charging management module 240 is charging the battery 242 , it can also supply power to the electronic device through the power management module 241 .
  • the power management module 241 is used for connecting the battery 242 , the charging management module 240 and the processor 210 .
  • the power management module 241 receives the input from the battery 242 and/or the charging management module 240 to provide power for the processor 210 , internal memory 221 , external memory, display screen 294 , camera 293 , and wireless communication module 260 .
  • the power management module 241 can also be used to monitor parameters such as battery capacity, battery cycle times, and battery health status (leakage, impedance).
  • the power management module 241 can also be set in the processor 210 .
  • the power management module 241 and the charging management module 240 may also be set in the same device.
  • the wireless communication function of the electronic device can be realized by the antenna 1, the antenna 2, the mobile communication module 250, the wireless communication module 260, the modem processor and the baseband processor.
  • the mobile communication module 250 can provide wireless communication solutions including 2G/3G/4G/5G applied to electronic devices.
  • the mobile communication module 250 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA) and the like.
  • the mobile communication module 250 can receive electromagnetic waves through the antenna 1, filter and amplify the received electromagnetic waves, and send them to the modem processor for demodulation.
  • the mobile communication module 250 can also amplify the signal modulated by the modem processor, convert it into electromagnetic wave and radiate it through the antenna 1 .
  • at least part of the functional modules of the mobile communication module 250 may be set in the processor 210 .
  • at least part of the functional modules of the mobile communication module 250 and at least part of the modules of the processor 210 may be set in the same device.
  • a modem processor may include a modulator and a demodulator.
  • the modem processor may be a stand-alone device.
  • the modem processor may be independent of the processor 210, and be set in the same device as the mobile communication module 250 or other functional modules.
  • the wireless communication module 260 can provide wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (Wi-Fi) network), bluetooth (bluetooth, BT), global navigation satellite system, etc. (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions.
  • the wireless communication module 260 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 260 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 210 .
  • the wireless communication module 260 can also receive the signal to be sent from the processor 210 , frequency-modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 to radiate out.
  • the antenna 1 of the electronic device is coupled to the mobile communication module 250, and the antenna 2 is coupled to the wireless communication module 260, so that the electronic device can communicate with the network and other devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), broadband Code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC , FM, and/or IR techniques, etc.
  • GSM global system for mobile communications
  • GPRS general packet radio service
  • code division multiple access code division multiple access
  • CDMA broadband Code division multiple access
  • WCDMA wideband code division multiple access
  • time division code division multiple access time-division code division multiple access
  • TD-SCDMA time-division code division multiple access
  • LTE
  • the GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (global navigation satellite system, GLONASS), a Beidou navigation satellite system (beidou navigation satellite system, BDS), a quasi-zenith satellite system (quasi -zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • Beidou navigation satellite system beidou navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the electronic device can use the wireless communication module 260 to interact with the network terminals of some networking applications through wireless communication technology.
  • the electronic device realizes the display function through the GPU, the display screen 294, and the application processor.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 294 and the application processor.
  • Processor 210 may include one or more GPUs that execute program instructions to generate or change display information.
  • the display screen 294 is used to display images, videos and the like.
  • Display 294 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), etc.
  • the electronic device may include 1 or N display screens 294, where N is a positive integer greater than 1.
  • the electronic device can realize the shooting function through ISP, camera 293 , video codec, GPU, display screen 294 and application processor.
  • the external memory interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device.
  • the external memory card communicates with the processor 210 through the external memory interface 220 to implement a data storage function. Such as saving music, video and other files in the external memory card.
  • the internal memory 221 may be used to store computer-executable program codes including instructions.
  • the processor 210 executes various functional applications and data processing of the electronic device by executing instructions stored in the internal memory 221 .
  • the processor 210 may implement the storage method provided in the embodiment of the present application by executing instructions stored in the internal memory 221 .
  • the internal memory 221 may include an area for storing programs and an area for storing data.
  • the stored program area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.) and the like.
  • the storage data area can store data (such as audio data, phone book, etc.) created during the use of the electronic device.
  • the internal memory 221 may include a high-speed random access memory, and may also include a non-volatile memory, such as a hybrid SSD with a dynamic SLC capacity, a flash memory device, and a universal flash storage (universal flash storage, UFS), etc.
  • a non-volatile memory such as a hybrid SSD with a dynamic SLC capacity, a flash memory device, and a universal flash storage (universal flash storage, UFS), etc.
  • the electronic device can realize the audio function through the audio module 270, the speaker 270A, the receiver 270B, the microphone 270C, the earphone interface 270D, and the application processor. Such as calls, music playback, recording, etc.
  • the sensor module 280 may include a pressure sensor 280A, a gyro sensor 280B, an air pressure sensor 280C, a magnetic sensor 280D, an acceleration sensor 280E, a distance sensor 280F, a proximity light sensor 280G, a fingerprint sensor 280H, a temperature sensor 280J, a touch sensor 280K, an ambient light sensor 280L, bone conduction sensor 280M, etc.
  • the structure shown in FIG. 2 does not constitute a specific limitation on the electronic device.
  • the electronic device when the electronic device is a tablet computer, a desktop, a laptop, a handheld computer, a notebook computer, a UMPC, a netbook, and other devices such as a cellular phone, a PDA, an AR ⁇ VR device, etc., the electronic device may include More or fewer components than shown in Figure 2, or certain components combined, or some components separated, or different component arrangements.
  • the components shown in Fig. 2 can be implemented in hardware, software or a combination of software and hardware.
  • the embodiment of the present application does not limit the specific structure of the electronic device.
  • FIG. 3 is a schematic flowchart of a storage method provided in an embodiment of the present application. As shown in Figure 3, the method may include:
  • FIG. 4 is a schematic diagram of a storage space of a hybrid SSD with a dynamic SLC capacity provided by an embodiment of the present application.
  • the storage space of the hybrid SSD with dynamic SLC capacity may include: regular data storage space, cache data storage space, and free space.
  • the regular data storage space stores regular data, such as: data generated by local users of electronic devices.
  • the cache data storage space stores cache data, such as remote data stored locally by electronic devices to improve data request performance.
  • Free space is storage space that does not store data.
  • the overall space utilization rate of the hybrid SSD with dynamic SLC capacity can be: the sum of the size of the conventional data storage space and the size of the cache data storage space, and the ratio of the storage space of the hybrid SSD with dynamic SLC capacity.
  • the area composed of the regular data storage space and the cache data storage space is the used area in the storage space of the hybrid SSD with dynamic SLC capacity.
  • the area formed by the regular data storage space and the cache data storage space may also be referred to as the overall usage space.
  • the size of the dynamic SLC area is related to the overall space usage. For example, when the overall space utilization rate is the first overall space utilization rate, the size of the dynamic SLC area is the fourth capacity; when the overall space utilization rate is the second overall space utilization rate, the size of the dynamic SLC area is the fifth capacity; When the second overall space usage rate is greater than the first overall space usage rate, the fifth capacity is smaller than the fourth capacity.
  • the second overall space utilization rate and the first overall space utilization rate are both greater than the maximum overall space utilization rate corresponding to the maximum SLC capacity of the hybrid SSD with the dynamic SLC capacity, and smaller than the maximum SLC capacity of the hybrid SSD with the dynamic SLC capacity. Hours correspond to the minimum overall space usage.
  • S302 may include: when the overall space usage rate is less than or equal to the first threshold, adjusting the maximum available cache space of the hybrid SSD with dynamic SLC capacity, so that the size of the maximum available cache space is equal to the first capacity, the first The capacity is less than or equal to the maximum SLC capacity of the hybrid SSD with dynamic SLC capacity, and greater than the capacity of the static SLC area of the hybrid SSD with dynamic SLC capacity; when the overall space usage rate is greater than the first threshold and less than the second threshold, the first The second threshold is greater than the first threshold, adjust the maximum available cache space of the hybrid SSD with dynamic SLC capacity, so that the size of the maximum available cache space decreases with the increase of the overall space usage; when the overall space usage is greater than or equal to the first When the second threshold is used, adjust the maximum available cache space of the hybrid SSD with dynamic SLC capacity, so that the size of the maximum available cache space is equal to the second capacity, and the second capacity is less than or equal to the capacity of the static SLC area of the hybrid SSD with dynamic SLC capacity
  • the maximum SLC capacity refers to the sum of the capacity of the dynamic SLC area and the static SLC area when all multi-layer unit areas that can be converted to SLC mode in the hybrid SSD with dynamic SLC capacity work in SLC mode.
  • the first threshold may be the maximum overall space usage rate corresponding to the maximum SLC capacity of the hybrid SSD with dynamic SLC capacity; the second threshold may be the minimum SLC capacity of the hybrid SSD with dynamic SLC capacity The corresponding minimum overall space usage.
  • the hybrid SSD with dynamic SLC capacity has the largest SLC capacity.
  • the dynamic SLC area will start to decrease, and the overall space usage at this time is the maximum overall space usage corresponding to the maximum SLC capacity Rate.
  • the SLC capacity of the hybrid SSD with dynamic SLC capacity becomes the minimum (that is, static SLC area capacity)
  • the overall space utilization rate at this time is the minimum overall space utilization rate corresponding to the minimum SLC capacity.
  • FIG. 5 is a schematic diagram of a relationship between the SLC capacity and the overall space utilization rate provided by the embodiment of the present application.
  • the horizontal and vertical axes represent the overall space utilization rate of the hybrid SSD with dynamic SLC capacity, and the vertical axis represents the SLC capacity corresponding to the current overall space utilization rate.
  • SLC capacity max indicates the maximum SLC capacity of the hybrid SSD with dynamic SLC capacity, that is, when all multi-layer unit areas that can be converted to SLC mode in the hybrid SSD with dynamic SLC capacity work in SLC mode, the dynamic SLC area and The sum of the capacity of the static SLC area.
  • SLC capacity min indicates the minimum SLC capacity of the hybrid SSD with dynamic SLC capacity, that is, the capacity of the static SLC area.
  • the SLC capacity of the hybrid SSD of dynamic SLC capacity is SLC capacity max ; when the overall space utilization rate is greater than m1, and When it is smaller than m2 (m2 is greater than m1 and less than 100%), the SLC capacity of the hybrid SSD with dynamic SLC capacity decreases as the overall space usage increases; when the overall space usage is equal to m2, the dynamic SLC capacity
  • the SLC capacity of the hybrid SSD is the SLC capacity min .
  • m1 is the maximum overall space utilization rate corresponding to the maximum SLC capacity
  • m2 is the minimum overall space utilization rate corresponding to the minimum SLC capacity.
  • the magnitude of the first threshold may be equal to m1
  • the magnitude of the second threshold may be equal to m2.
  • the maximum available cache space of the hybrid SSD with dynamic SLC capacity can be adjusted so that the maximum available cache space is equal to the first capacity, and the first capacity is less than or equal to SLC Capacity max ;
  • the maximum available cache space of the hybrid SSD with dynamic SLC capacity can be adjusted so that the maximum available cache space decreases with the increase of the overall space usage ;
  • the maximum available cache space of the hybrid SSD with dynamic SLC capacity can be adjusted so that the size of the maximum available cache space is equal to the second capacity, and the second capacity can be less than or equal to the SLC capacity min .
  • the hybrid SSD with dynamic SLC capacity can be divided into: the overall space usage rate is less than or equal to the first threshold, and the overall space usage rate is greater than the first threshold and less than the second threshold. Threshold, and the overall space usage rate is greater than or equal to the second threshold and other three stages.
  • the stage in which the overall space usage rate is less than or equal to the first threshold may be called an idle stage
  • the stage in which the overall space usage rate is greater than the first threshold and smaller than the second threshold may be called a moderate stage
  • the overall space usage rate is greater than Or the stage equal to the second threshold can be called severe stage.
  • the present application may set the size of the maximum available cache space as the first capacity, and the first capacity may be less than or equal to the maximum SLC capacity.
  • the moderate stage some multi-layer unit areas in the hybrid SSD with dynamic SLC capacity that can be converted to SLC mode work in SLC mode, and the SLC capacity is in a downward trend. This application can adjust the maximum available cache space according to the overall space utilization rate. Size so that it decreases as overall space usage increases.
  • the SLC capacity of the hybrid SSD with dynamic SLC capacity is the capacity of the static SLC area.
  • the application may set the size of the maximum available cache space as the second capacity, and the second capacity may be less than or equal to the capacity of the static SLC area.
  • the The following formula (1) adjusts the maximum available cache space of the hybrid SSD with dynamic SLC capacity, so that the size of the maximum available cache space decreases as the overall space usage increases.
  • Y represents the size of the maximum available cache space
  • X represents the overall space utilization rate
  • k represents a coefficient
  • c is a constant
  • the values of k and c can be determined by the first capacity and the first threshold, as well as the second capacity and The second threshold is calculated by substituting formula (1).
  • the maximum available cache space of the hybrid SSD with dynamic SLC capacity can be adjusted according to the above formula (1) according to the overall space utilization rate, so that the maximum available cache space increases with the overall space decrease with increasing usage.
  • the above formula ( 1) Adjust the maximum available cache space of the hybrid SSD with dynamic SLC capacity according to the overall space utilization rate.
  • the third threshold may be 5%, 6%, 8%, etc., and there is no limitation on the size of the third threshold.
  • the rate adjusts the size of the maximum available cache space of the hybrid SSD with dynamic SLC capacity.
  • every interval of the third threshold may be used as a dynamic adjustment point to adjust the maximum available cache space of the hybrid SSD with dynamic SLC capacity.
  • the change of the maximum available cache space may not be continuous, and the size of the maximum available cache space may be updated once when the overall space usage rate changes by the third threshold.
  • the first threshold is the maximum overall space usage rate corresponding to the maximum SLC capacity of the hybrid SSD with dynamic SLC capacity
  • the second threshold is the minimum overall space corresponding to the minimum SLC capacity of the hybrid SSD with dynamic SLC capacity. usage rate.
  • the first threshold may also be less than or greater than the maximum overall space usage rate corresponding to the maximum SLC capacity of the hybrid SSD with the dynamic SLC capacity, for example: the first threshold may be less than or greater than The above m1; the second threshold may also be less than or greater than the minimum overall space usage rate corresponding to the minimum SLC capacity of the hybrid SSD with the dynamic SLC capacity, for example, the second threshold may be less than or greater than the above m2.
  • the present application does not limit the specific sizes of the first threshold and the second threshold.
  • the first threshold may be greater than or equal to the maximum overall space usage rate corresponding to the maximum SLC capacity of the hybrid SSD with dynamic SLC capacity
  • the second threshold may be less than or equal to the hybrid SSD with dynamic SLC capacity The minimum overall space utilization rate corresponding to the minimum SLC capacity.
  • the first threshold may be less than or equal to the maximum overall space usage rate corresponding to the maximum SLC capacity of the hybrid SSD with the dynamic SLC capacity
  • the second threshold may be greater than or equal to the hybrid SSD with the dynamic SLC capacity The minimum overall space usage rate corresponding to the minimum SLC capacity of the SSD.
  • the first threshold can be 0, and the second threshold can be 100%, that is, the dynamic SLC capacity can be mixed according to the overall space usage SSD is divided into stages as a whole.
  • the first threshold may be less than or equal to the maximum overall space usage rate corresponding to the maximum SLC capacity of the hybrid SSD with the dynamic SLC capacity
  • the second threshold may be less than or equal to the hybrid SSD with the dynamic SLC capacity The minimum overall space usage rate corresponding to the minimum SLC capacity of the SSD.
  • the first threshold can be 0, and the second threshold can be smaller than the above m2, that is, the dynamic SLC capacity can be mixed according to the overall space usage SSD is divided into two stages: the overall space usage rate is greater than the first threshold and less than the second threshold, and the overall space usage rate is greater than or equal to the second threshold and other two stages (the overall space usage rate is equal to 0 can be divided in the overall space usage rate In extreme cases greater than the first threshold and less than the second threshold).
  • the first threshold may be greater than or equal to the maximum overall space usage rate corresponding to the maximum SLC capacity of the hybrid SSD with the dynamic SLC capacity
  • the second threshold may be greater than or equal to the hybrid SSD with the dynamic SLC capacity The minimum overall space usage rate corresponding to the minimum SLC capacity of the SSD.
  • the first threshold may be the above m1
  • the second threshold may be 100%
  • the dynamic SLC capacity may be mixed according to the overall space usage Type SSD is divided into two stages: the overall space usage rate is less than or equal to the first threshold, and the overall space usage rate is greater than the first threshold and other two stages (the overall space usage rate is equal to the second threshold (i.e. 100%) can be divided into the overall space In extreme cases where the usage rate is greater than the first threshold).
  • the hybrid SSD with dynamic SLC capacity is divided into a whole stage, or two or three stages through a number of different examples. , and adjust the size of the maximum available cache space at each stage.
  • the hybrid SSD with dynamic SLC capacity can also be divided into more stages according to the overall space utilization rate, and the size of the maximum available cache space can be calculated separately in each stage Adjustment.
  • the hybrid SSD with dynamic SLC capacity can be divided into an idle stage, a moderate stage, and a severe stage according to the manner described in the foregoing embodiments, wherein the moderate stage can be further divided into multiple substages, such as:
  • the moderate stage can be divided into S (S is an integer greater than 1) sub-stages according to the size of the overall space utilization rate, and each sub-stage can be used in different ways (not limited to the above formula (1)).
  • the size of the available cache space is adjusted so that the size of the maximum available cache space decreases with the increase of the overall space usage, for example: the size of the maximum available cache space decreases linearly with the increase of the overall space usage or non-linear reduction.
  • the maximum value of the maximum available cache space is less than or equal to the maximum SLC capacity, and the size of the maximum available cache space tends to decrease as the overall space usage increases.
  • the adjusted maximum available cache space is the first value
  • the adjusted maximum available cache is the second value
  • the adjusted maximum available cache The size of the space is a second value
  • the second overall space usage rate is greater than the first overall space usage rate
  • the second value is smaller than the first value
  • the second overall space usage rate and the first overall space usage rate may be Overall space usage of a hybrid SSD with dynamic SLC capacity in two different stages.
  • the second overall space usage rate and the first overall space usage rate may also be a hybrid of dynamic SLC capacity in the same stage The overall space usage of the SSD.
  • the division of stages reference may be made to the foregoing embodiments.
  • every interval of the third threshold is used as a dynamic adjustment point to adjust the maximum available cache space of the hybrid SSD with dynamic SLC capacity.
  • the overall space utilization rate is less than or equal to the first threshold, the overall space utilization rate is greater than the first threshold and less than the second threshold, and the overall space utilization rate is greater than or equal to the second threshold, etc. How to size the maximum available cache space.
  • the overall space utilization rate is greater than or equal to the second threshold, adjust the maximum available cache space of the hybrid SSD with dynamic SLC capacity, so that the size of the maximum available cache space is equal to the second capacity, and the second capacity is less than or equal to the dynamic SLC capacity
  • the second capacity may also be less than or equal to the capacity of the remaining available storage space of the hybrid SSD with dynamic SLC capacity, or the second capacity may also be less than or equal to the hybrid SSD with dynamic SLC capacity The smaller value between the capacity of the remaining available storage space and the capacity of the static SLC area.
  • the third capacity is the hybrid SSD with dynamic SLC capacity
  • the remaining available storage space of the hybrid SSD with dynamic SLC capacity refers to the remaining space after the space occupied by conventional data is removed from the storage space of the hybrid SSD with dynamic SLC capacity.
  • the remaining available storage space of the hybrid SSD with dynamic SLC capacity may include: cache data storage space and free space.
  • the storage method provided by the embodiment of the present application by controlling the maximum available cache space, the overall space usage of the hybrid SSD with dynamic SLC capacity can be reduced, the size of the available SLC cache space can be maintained, and the hybrid SSD with dynamic SLC capacity can be improved. SSD I/O performance.
  • FIG. 6 is a schematic composition diagram of a storage device of an electronic device provided in an embodiment of the present application.
  • the electronic device may include a memory 601 and a hybrid SSD 602 with dynamic SLC capacity.
  • the memory 601 may include: one or more application programs, a cache system (or called a cache management system), and a memory cache storage space (memory cache for short).
  • the application program may include: various networking application programs such as chat software and network video player.
  • the hybrid SSD 602 with dynamic SLC capacity may include: regular data storage space, flash cache storage space (that is, cache data storage space, referred to as flash cache), and free space.
  • the application program in the memory 601 makes a network file request (or called a file request), such as: the first application program can make a network file request, and the network file request can be used to request the first file, and the cache system in the memory 601
  • the network file request can be intercepted, and it can be judged whether the network file requested by the network file request (i.e. first file); when the network file requested by the network file request is cached in the memory cache, the memory cache can return the corresponding network file to the application program.
  • the flash cache may return the corresponding network file to the application program.
  • the electronic device can request to cache the network file from the remote end (such as the server corresponding to the application program, the server and the server) through the network, and cache it in in memory cache.
  • the remote end such as the server corresponding to the application program, the server and the server
  • the cache system can remove files from the memory cache according to the removal strategy (such as removing the second file).
  • This application does not limit the removal strategy.
  • Files culled from memory cache can be cached into flash cache.
  • the cache system can adjust the maximum available cache space of the hybrid SSD 602 with dynamic SLC capacity according to the storage method provided in the embodiment of the present application according to the overall space usage rate of the hybrid SSD 602 with dynamic SLC capacity.
  • the cache system can delete the cache files (that is, cache data) in the flash cache according to the removal strategy, so that the space occupied by the cache files stored in the flash cache does not exceed Maximum available cache space.
  • a cache space management module may be included in the cache system, and the cache space management module may be used to realize the overall space utilization rate of the hybrid SSD 602 according to the dynamic SLC capacity, and the hybrid SSD 602 with the dynamic SLC capacity The function of adjusting the maximum available cache space.
  • the elimination strategy can be followed.
  • the cache files in the flash cache are removed, so that the space occupied by the cache files stored in the flash cache does not exceed the updated maximum available cache space.
  • the overall space usage rate of the hybrid SSD 602 with dynamic SLC capacity reaches 100%, if the conventional data storage space needs to continue to grow, the maximum available cache space can be compressed, and the flash memory cache can be removed. cache files to make room for regular data.
  • the above embodiments have introduced the process of adjusting the maximum available cache space of the hybrid SSD with dynamic SLC capacity according to the overall space utilization rate in the storage method provided by the embodiments of the present application.
  • the cache file in the storage method provided by the embodiment of the present application, can also be stored in the hybrid SSD with dynamic SLC capacity according to the overall space usage rate of the hybrid SSD with dynamic SLC capacity
  • the conditions of the cache data storage space (hereinafter referred to as flash cache) are dynamically adjusted.
  • the electronic device can determine whether the cache file should be stored in the flash cache according to the condition that the cache file can be stored in the flash cache of the hybrid SSD with dynamic SLC capacity.
  • these cache files may be files that are evicted from memory cache.
  • the method dynamically adjusts the condition that the cache file can be stored in the flash cache of the hybrid SSD with dynamic SLC capacity, and can control the files stored in the hybrid SSD with dynamic SLC capacity. For writing, the IO performance of hybrid SSDs that maintain dynamic SLC capacity is in a good state.
  • FIG. 7 is another schematic flowchart of the storage method provided by the embodiment of the present application. As shown in Figure 7, the method may include:
  • the cache system of the electronic device may use a least frequently used (LFU) policy as a file management policy for the flash memory cache.
  • S702 may include: when the overall space usage rate is less than or equal to the first threshold, the condition for adjusting the cache file to be stored in the flash memory cache of the hybrid SSD of the dynamic SLC capacity is: the cache file is hit by a file operation (such as a read and write operation) in the memory The number of times is greater than or equal to the first number (the first number is an integer greater than 0), that is, when the number of file operation hits in the cache file in memory is greater than or equal to the first number, the cache file can be stored in the dynamic The flash cache of the hybrid SSD with SLC capacity; when the overall space usage is greater than the first threshold and less than the second threshold, the second threshold is greater than the first threshold, and the cache file is stored in the flash cache of the hybrid SSD with dynamic SLC capacity
  • the condition is: the number of file operation hits of the cache file in memory is greater than or equal to the second number (the
  • the magnitudes of the first threshold and the second threshold may refer to the foregoing embodiments, and details are not repeated here.
  • the first number is less than the second number
  • the second number is less than the third number
  • the overall space usage rate is from the stage that is less than or equal to the first threshold to the bulk space usage rate that is greater than the first threshold and less than the second threshold.
  • the second number can be an integer multiple of the first number, such as: the first number can be L times, and the second number can be 2*L times ("*" means multiplying ).
  • the third number of times may be an integer multiple of the second number of times, for example, the third number of times may be 4*L times.
  • the second number may not be an integer multiple of the first number, for example, the first number may be L times, and the second number may be L+L1 times.
  • the third number of times may not be an integral multiple of the second number of times, for example, the third number of times may be L+L1+L2 times.
  • the present application does not limit the specific size of the first number, the second number, and the third number.
  • the file management strategy of the cache system of the electronic device for the flash memory cache may be a file size-based management strategy.
  • S702 may include: when the overall space usage rate is less than or equal to the first threshold, the condition for adjusting the cache file to be stored in the flash cache of the hybrid SSD of the dynamic SLC capacity is: the size of the cache file is less than or equal to the first byte (first byte is a value greater than 0), that is, when the size of the cache file is less than or equal to the first byte, the cache file can be stored in the flash cache of the hybrid SSD with dynamic SLC capacity; when the overall space usage is greater than the first Threshold and when less than the second threshold, the second threshold is greater than the first threshold, and the condition for adjusting the cache file to be stored in the flash cache of the hybrid SSD of the dynamic SLC capacity is: the size of the cache file is less than or equal to the second byte (second byte is a value greater than 0), the second byte is smaller than the first byte, that
  • the magnitudes of the first threshold and the second threshold may refer to the foregoing embodiments, and details are not repeated here.
  • the third byte is smaller than the second byte
  • the second byte is smaller than the first byte
  • the overall space usage rate is less than or equal to the first threshold
  • the bulk space usage rate is greater than the first threshold
  • the cache files that can meet the conditions for storing in the flash cache of the hybrid SSD with dynamic SLC capacity are getting smaller and smaller, which can be The IO performance of hybrid SSDs maintaining dynamic SLC capacity is in a better state.
  • the first byte may be an integer multiple of the second byte
  • the second byte may be an integer multiple of the third byte
  • the first byte may be B bytes
  • the second byte can be B/2 bytes ("/" means divide by)
  • the third byte can be B/4 bytes.
  • the relationship between the first byte, the second byte, and the third byte may not be an integer multiple, such as: the first byte may be a B byte, and the second byte may be is B-B1 byte, and the third byte can be B-B1-B2 byte.
  • the above embodiment shows that the overall space usage is less than or equal to the first threshold, the overall space usage is greater than the first threshold and smaller than the second threshold, and the overall space usage is greater than or equal to the second threshold.
  • the conditions for storing the cache files in the flash cache of the hybrid SSD with dynamic SLC capacity are dynamically adjusted.
  • the conditions for storing cached files in the flash cache of the hybrid SSD with dynamic SLC capacity are always the same.
  • the conditions for storing the cache files in the flash cache of the hybrid SSD with dynamic SLC capacity so that the cache files are stored in The conditions for flash cache of hybrid SSDs with dynamic SLC capacity become more and more stringent as the overall space usage increases.
  • the hybrid method of storing cache files into the dynamic SLC capacity can be adjusted.
  • the condition of the flash cache of the SSD is: the number of file operation hits of the cache file in the memory is greater than or equal to the second number, and the second number increases with the increase of the overall space usage.
  • the cache file can be stored dynamically.
  • the conditions for the flash cache of the hybrid SSD with SLC capacity are: the size of the cache file is less than or equal to the second byte, and the second byte decreases with the increase of the overall space usage.
  • the hybrid SSD with dynamic SLC capacity can also be divided into more stages according to the overall space utilization rate, and the cache files are stored in the dynamic SLC capacity in each stage
  • the condition of the hybrid SSD's flash cache is adjusted.
  • the hybrid SSD with dynamic SLC capacity can be divided into an idle stage, a moderate stage, and a severe stage according to the manner described in the foregoing embodiments, wherein the moderate stage can be further divided into multiple substages, such as:
  • the moderate phase can be divided into S (S is an integer greater than 1) sub-phases according to the size of the overall space usage rate, and each sub-phase can store the cache files in different ways in a hybrid mode of dynamic SLC capacity.
  • the increase of the utilization rate increases linearly or non-linearly, or the second byte decreases linearly or non-linearly with the increase of the overall space utilization rate.
  • the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the hybrid SSD with dynamic SLC capacity is located is greater than or equal to the third value , and/or, the size of the cache file is less than or equal to the fourth value; when the overall space usage rate is the fourth overall space usage rate, the adjusted conditions include: the electronic device where the cache file is located in a hybrid SSD with a dynamic SLC capacity The number of file operation hits in memory is greater than or equal to the fifth value, and/or, the size of the cache file is less than or equal to the sixth value; when the fourth overall space usage is greater than the third overall space usage, the fifth value is greater than the sixth Three values, the sixth value is less than the fourth value.
  • the third overall space usage rate and the fourth The overall space usage rate may be the overall space usage rate of the hybrid SSD with dynamic SLC capacity in the same stage.
  • the third overall space usage rate and the fourth overall space usage rate may be in different stages Overall space usage of hybrid SSDs with dynamic SLC capacity. For the division of stages, reference may be made to the foregoing embodiments.
  • the storage method provided by the embodiment of the present application, by dynamically adjusting the conditions for storing the cached files in the flash cache of the hybrid SSD with dynamic SLC capacity, the number of caches of invalid cached files can be reduced, and the impact on the dynamic SLC capacity can be reduced.
  • the writing of hybrid SSD optimizes the IO performance of hybrid SSD with dynamic SLC capacity.
  • the cache system removes the cache files in the memory cache according to the elimination strategy (or called the cache management strategy), and the cache system can store the dynamically adjusted cache files in the flash memory of the hybrid SSD with dynamic SLC capacity according to the storage method provided by the embodiment of the present application. Cache conditions, judging whether the cache files removed from the memory cache can be cached in the flash cache of the hybrid SSD 602 with dynamic SLC capacity.
  • the cache file removed from the memory cache meets the conditions of being stored in the flash cache of the hybrid SSD of the dynamic SLC capacity, the cache file removed from the memory cache can be stored in the flash cache;
  • the cache files removed from the memory cache do not meet the conditions for being stored in the flash cache of a hybrid SSD with dynamic SLC capacity, you can delete or refuse to store the cache files removed from the memory cache into the flash cache.
  • a cache file screening module may be included in the cache system, and the cache file screening module may be used to implement the above-mentioned conditions for storing cache files in the flash memory cache of a hybrid SSD with dynamic SLC capacity according to the overall space utilization rate.
  • an interface for managing the cache space may be provided in the cache system, and the interface may be used to access different cache management algorithms, and the cache management algorithm may be used to manage memory cache and flash cache,
  • the present application does not limit the cache management policies of memory cache and flash cache.
  • the cache system of the above-mentioned electronic device can simultaneously use the LFU policy and the management policy based on the file size as the file management policy of the flash cache.
  • the aforementioned embodiments about the LFU policy and the embodiments about the management policy based on the file size It can be the relationship between and, that is, the conditions for storing the cache file in the flash memory cache of the hybrid SSD with dynamic SLC capacity can include: the number of times the cache file is hit by the file operation in the memory and the size of the cache file, provided in the embodiment of the present application
  • the method can simultaneously adjust the number of file operation hits of the cache file in the memory and the size of the cache file in the condition of storing the cache file in the flash memory cache of the hybrid SSD with dynamic SLC capacity, and the adjustment method is as described in the foregoing embodiments.
  • the hybrid SSD with dynamic SLC capacity is used as an example to describe the storage method provided in the embodiment of the present application.
  • the storage method provided by the embodiment of this application can also be applied to other storage devices that can use mixed high-speed media and low-speed media.
  • the storage space of the storage device can include: multi-layer unit area, dynamic SLC area, and static SLC area. The present application does not limit specific types of storage devices.
  • the aforementioned embodiment shown in FIG. 7 may be implemented as a single embodiment, or may be implemented together with the embodiment shown in FIG. 3 as an integrated embodiment, which is not limited here.
  • FIG. 8 is a schematic structural diagram of a storage device provided in an embodiment of the present application.
  • the apparatus may include: an acquiring unit 801, a processing unit 802, and the like.
  • the acquiring unit 801 and the processing unit 802 may cooperate to implement the storage method as described in the foregoing embodiments.
  • acquisition unit 801 which can be used for acquisition unit 801, can be used to acquire the overall space utilization rate of storage devices; storage devices include working in multi-layer unit areas, dynamic single-level unit areas, and static single-level unit areas; overall space The usage rate is determined according to the size of the storage space of the storage device and the size of the used area in the storage space of the storage device.
  • the processing unit 802 can be configured to adjust the size of the maximum available cache space of the storage device according to the overall space utilization rate; the maximum available cache space is the maximum storage space allowed to be occupied by the cached data when storing the cached data in the storage device.
  • the size of the dynamic single-layer unit area is the fourth capacity, and the adjusted maximum available cache space is the first value; when the overall space utilization rate is the second overall space In terms of utilization, the size of the dynamic single-layer unit area is the fifth capacity, and the adjusted maximum available cache space is the second value; the second overall space utilization is greater than the first overall space utilization, and the fifth capacity is smaller than the fourth capacity, the second value is less than the first value.
  • the size of the maximum available cache space is equal to the first capacity
  • the first capacity is less than or equal to the maximum single-level unit capacity of the storage device and greater than the storage
  • the capacity of the static single-level unit area of the device; the maximum single-level unit capacity is the sum of the capacity of the dynamic single-level unit area and the static single-level unit area when the dynamic single-level unit area of the storage device is the largest.
  • the size of the maximum available cache space decreases as the overall space usage rate increases; the second threshold is greater than the first threshold.
  • the size of the maximum available cache space is equal to the second capacity, and the second capacity is less than or equal to the third capacity;
  • the third capacity is the capacity of the static single-layer unit area of the storage device, or , the capacity of the remaining available storage space of the storage device, or the smaller value of the capacity of the static single-layer unit area of the storage device and the capacity of the remaining available storage space;
  • the remaining available storage space of the storage device refers to the The remaining space after the space occupied by data, regular data includes data generated by local users of the electronic device where the storage device is located.
  • the first threshold is equal to the maximum overall space usage rate corresponding to the maximum single-layer unit capacity of the storage device; the second threshold is equal to the minimum overall space usage rate corresponding to the minimum single-layer unit capacity of the storage device.
  • the first threshold is less than or greater than the maximum overall space usage rate corresponding to the maximum single-level unit capacity of the storage device; the second threshold is less than or greater than the minimum overall space usage rate corresponding to the minimum single-level unit capacity of the storage device. space usage.
  • the processing unit 802 is specifically configured to: when the overall space usage rate is greater than the first threshold and smaller than the second threshold, and the overall space usage rate changes by a third threshold, according to the overall space usage rate, the storage The size of the device's maximum available cache space is adjusted.
  • the processing unit 802 is further configured to receive a file request from a first application program, where the file request is used to request a first file;
  • the first application program is an application in the memory of the electronic device where the storage device is located. program; when neither the cache space of the memory nor the cache space of the storage device caches the first file, obtain the first file from the server and cache it in the cache space of the memory; Delete the second file from the space; cache the second file in the cache space of the storage device; the storage space occupied by the cached data stored in the cache space of the storage device does not exceed the maximum available cache space.
  • processing unit 802 is further configured to, when the first file is cached in the cache space of the memory, read the first file from the cache space of the memory and return it to the first application program; When the first file is cached in the storage device, the first file is read from the cache space of the storage device and returned to the first application program.
  • processing unit 802 is further configured to dynamically adjust the conditions for storing the cached files in the storage device according to the overall space usage rate.
  • the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third value, and/or, the cache file is less than or equal to the fourth value; when the overall space usage rate is the fourth overall space usage rate, the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the fourth value Five values, and/or, the size of the cache file is less than or equal to the sixth value; the fourth overall space utilization rate is greater than the third overall space utilization rate, the fifth value is greater than the third value, and the sixth value is less than the fourth value.
  • the adjusted condition when the overall space usage rate is less than or equal to the first threshold, includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the first threshold number, and/or, the size of the cache file is less than or equal to the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the second number, and/or , the size of the cache file is less than or equal to the second byte; the second threshold is greater than the first threshold; the second number is greater than the first number, and the second byte is smaller than the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third number of times, and/or, the cache file The size is less than or equal to the third byte; the third degree is greater than the second degree, and the third byte is less than the second byte.
  • the second number increases as the overall space usage increases, and/or the second byte decreases as the overall space usage increases.
  • the processing unit 802 is further configured to receive a file request from a first application program, where the file request is used to request a first file;
  • the first application program is an application in the memory of the electronic device where the storage device is located. program; when neither the cache space of the memory nor the cache space of the storage device caches the first file, obtain the first file from the server and cache it in the cache space of the memory; Delete the second file from the space; when the second file meets the adjusted condition, cache the second file into the cache space of the storage device.
  • the acquisition unit 801 and the processing unit 802 can cooperate to realize the functions corresponding to all the steps of the storage method described in the foregoing embodiments, which will not be repeated here.
  • FIG. 9 is another schematic structural diagram of a storage device provided by an embodiment of the present application.
  • the apparatus may include: an acquiring unit 901, a processing unit 902, and the like.
  • the acquisition unit 901 can be used to acquire the overall space utilization rate of the storage device; the storage device includes working in a multi-layer unit area, a dynamic single-level unit area, and a static single-level unit area; the overall space utilization rate is based on the storage space of the storage device and the size of the used area in the storage space of the storage device.
  • the processing unit 902 may be configured to dynamically adjust the conditions for storing the cached files in the storage device according to the overall space usage rate.
  • the adjusted conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third value, and/or, the size of the cache file is less than or equal to the fourth value; when the overall space utilization rate is the fourth overall space utilization rate, the size of the dynamic single-layer unit area is the fifth capacity, and the adjusted The conditions include: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the fifth value, and/or, the size of the cache file is less than or equal to the sixth value; the fourth overall space usage rate is greater than the fifth value; Three overall space utilization ratios, the fifth capacity is less than the fourth capacity, the fifth value is greater than the third value, and the sixth value is less than the fourth value.
  • the adjusted condition when the overall space usage rate is less than or equal to the first threshold, includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the first threshold number, and/or, the size of the cache file is less than or equal to the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the second number, and/or , the size of the cache file is less than or equal to the second byte; the second threshold is greater than the first threshold; the second number is greater than the first number, and the second byte is smaller than the first byte.
  • the adjusted condition includes: the number of file operation hits of the cache file in the memory of the electronic device where the storage device is located is greater than or equal to the third number of times, and/or, the cache file The size is less than or equal to the third byte; the third degree is greater than the second degree, and the third byte is less than the second byte.
  • the first threshold is equal to the maximum overall space usage rate corresponding to the maximum single-layer unit capacity of the storage device; the second threshold is equal to the minimum overall space usage rate corresponding to the minimum single-layer unit capacity of the storage device.
  • the first threshold is less than or greater than the maximum overall space usage rate corresponding to the maximum single-level unit capacity of the storage device; the second threshold is less than or greater than the minimum overall space usage rate corresponding to the minimum single-level unit capacity of the storage device. space usage.
  • the second number increases as the overall space usage increases, and/or the second byte decreases as the overall space usage increases.
  • the processing unit 902 is further configured to receive a file request from a first application program, where the file request is used to request a first file;
  • the first application program is an application in the internal memory of the electronic device where the storage device is located. program; when neither the cache space of the memory nor the cache space of the storage device caches the first file, obtain the first file from the server and cache it in the cache space of the memory; Delete the second file from the space; when the second file meets the adjusted condition, cache the second file into the cache space of the storage device.
  • processing unit 902 is further configured to, when the first file is cached in the cache space of the memory, read the first file from the cache space of the memory and return it to the first application program; when the cache space of the storage device When the first file is cached in the storage device, the first file is read from the cache space of the storage device and returned to the first application program.
  • the division of modules (or called units) in the above device is only a division of logical functions, and may be fully or partially integrated into a physical entity or physically separated during actual implementation.
  • the units in the device can all be implemented in the form of software called by the processing element; they can also be implemented in the form of hardware; some units can also be implemented in the form of software called by the processing element, and some units can be implemented in the form of hardware.
  • each unit can be a separate processing element, or it can be integrated in a certain chip of the device. In addition, it can also be stored in the memory in the form of a program, which is called and executed by a certain processing element of the device. Function. In addition, all or part of these units can be integrated together, or implemented independently.
  • the processing element described here may also be referred to as a processor, and may be an integrated circuit with a signal processing capability. In the process of implementation, each step of the above method or each unit above may be implemented by an integrated logic circuit of hardware in the processor element or implemented in the form of software called by the processing element.
  • the units in the above device may be one or more integrated circuits configured to implement the above method, for example: one or more application specific integrated circuits (ASIC), or, one or more A digital signal processor (DSP), or, one or more field programmable gate arrays (FPGA), or a combination of at least two of these integrated circuit forms.
  • ASIC application specific integrated circuits
  • DSP digital signal processor
  • FPGA field programmable gate arrays
  • the processing element can be a general-purpose processor, such as a central processing unit (central processing unit, CPU) or other processors that can call programs.
  • CPU central processing unit
  • these units can be integrated together and implemented in the form of a system-on-a-chip (SOC).
  • the units of the above apparatus for implementing each corresponding step in the above method may be implemented in the form of a processing element scheduler.
  • the device may include a processing element and a storage element, and the processing element invokes a program stored in the storage element to execute the storage method described in the above method embodiments.
  • the storage element may be a storage element on the same chip as the processing element, that is, an on-chip storage element.
  • the program for executing the above method may be stored in a storage element on a different chip from the processing element, that is, an off-chip storage element.
  • the processing element invokes or loads a program from the off-chip storage element on the on-chip storage element, so as to invoke and execute the storage method described in the above method embodiments.
  • the embodiment of the present application also provides an electronic device.
  • the electronic device may be the above-mentioned electronic device.
  • the electronic device includes: a processor, a memory configured to store instructions executable by the processor; when the processor is configured to execute the instructions, the electronic device implements the storage method as described in the foregoing embodiments.
  • the memory can be located inside the electronic device or outside the electronic device.
  • the processor includes one or more.
  • the electronic device may be a terminal device, a server, or a virtual machine (virtual machine, VM).
  • Terminal devices can be mobile phones, tablet computers, desktops, laptops, handheld computers, notebook computers, ultra-mobile personal computers (ultra-mobile personal computers, UMPCs), netbooks, and cellular phones, personal digital assistants (personal digital assistants, PDA), augmented reality (augmented reality, AR) ⁇ virtual reality (virtual reality, VR) equipment and other equipment, the embodiment of the present application does not make special restrictions on the specific form of the electronic equipment.
  • the unit of the electronic device that implements each step in the above method may be configured as one or more processing elements, where the processing elements may be integrated circuits, for example: one or more ASICs, or one Or multiple DSPs, or, one or more FPGAs, or a combination of these types of integrated circuits. These integrated circuits can be integrated together to form a chip.
  • an embodiment of the present application further provides a chip, and the chip can be applied to the above-mentioned electronic device.
  • the chip includes one or more interface circuits and one or more processors; the interface circuits and processors are interconnected through lines; the processor receives and executes computer instructions from the memory of the electronic device through the interface circuits, so as to realize the storage method.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
  • the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a readable storage medium.
  • the software product is stored in a program product, such as a computer-readable storage medium, and includes several instructions to make a device (which may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all of the methods described in various embodiments of the present application. or partial steps.
  • the aforementioned storage medium includes: various media capable of storing program codes such as U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk.
  • an embodiment of the present application further provides a computer-readable storage medium on which computer program instructions are stored; when the computer program instructions are executed by an electronic device, the electronic device implements the storage method as described in the embodiment.
  • an embodiment of the present application further provides a computer program product, including: computer readable codes, or a non-volatile computer readable storage medium bearing computer readable codes, when the computer readable codes are stored in the electronic device
  • the processor in the electronic device implements the storage method as described in the foregoing embodiments.

Landscapes

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

Abstract

本申请提供一种存储方法、装置、设备及存储介质,涉及电子设备领域。其中,该方法可以根据存储设备的总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整。通过控制存储设备的最大可用缓存空间,可以减少存储设备的总体空间使用量,保持存储设备中可用单层单元缓存空间的大小,提高存储设备的读写性能。

Description

存储方法、装置、设备及存储介质
本申请要求于2021年10月22日提交国家知识产权局、申请号为202111236363.1、申请名称为“存储方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及电子设备领域,尤其涉及一种存储方法、装置、设备及存储介质。
背景技术
固态闪存存储设备(solid state disk,SSD)也称固态磁盘、固态硬盘等。随着闪存存储技术的快速进步和存储需求的日益增加,SSD的存储密度也逐渐增大。例如,SSD的存储单元的使用模式单层单元(single-level cell,SLC)模式逐渐增加到了双层单元(multi-level cell,MLC)模式、三层单元(triple-level cell,TLC)模式、四层单元(quad-level cell,QLC)模式等。SSD的存储密度增大,可以使SSD的容量更大、成本更低,但SSD的输入输出(input and output,IO)性能(即读写性能)会出现大幅度的下降。
目前,在SSD中采用混合高速介质和低速介质的方式,可以优化SSD的IO性能。采用混合高速介质和低速介质的SSD可以被称为混合式SSD。混合式SSD可以包括:静态SLC容量的混合式SSD、动态SLC容量的混合式SSD。静态SLC容量的混合式SSD的存储空间可以包括:QLC区域和静态SLC区域,静态SLC区域的大小固定。动态SLC容量的混合式SSD的存储空间可以包括:QLC区域、动态SLC区域、以及静态SLC区域,静态SLC区域的大小也是固定的,随着动态SLC容量的混合式SSD的总体空间使用率逐渐增加,动态SLC区域中的部分区域可以切换到多层单元模式下工作,动态SLC区域会逐渐减小。
对于动态SLC容量的混合式SSD而言,动态SLC区域中的部分区域切换到多层单元模式下工作时,动态SLC容量的混合式SSD的容量会增大,但动态SLC容量的混合式SSD的IO性能会下降。
发明内容
本申请实施例提供一种存储方法、装置、设备及存储介质,其中,该方法可以根据存储设备的总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整。通过控制存储设备的最大可用缓存空间,可以减少存储设备的总体空间使用量,保持存储设备中可用单层单元缓存空间的大小,提高存储设备的读写性能。
第一方面,本申请实施例提供一种存储方法,所述方法包括:获取存储设备的总体空间使用率;存储设备包括工作在多层单元区域、动态单层单元区域、以及静态单层单元区域;总体空间使用率是根据存储设备的存储空间的大小、以及存储设备的存储空间中被使用区域的大小所确定的。根据总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整;最大可用缓存空间是向存储设备中存储缓存数据时,允许 缓存数据占用的最大存储空间。
当总体空间使用率为第一总体空间使用率时,动态单层单元区域的大小为第四容量,调整后的最大可用缓存空间的大小为第一值;当总体空间使用率为第二总体空间使用率时,动态单层单元区域的大小为第五容量,调整后的最大可用缓存空间的大小为第二值;第二总体空间使用率大于第一总体空间使用率,第五容量小于第四容量,第二值小于第一值。
该存储方法中,通过控制最大可用缓存空间的方法,可以减少存储设备的总体空间使用量,保持可用SLC缓存空间的大小,提高存储设备的IO性能。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,最大可用缓存空间的大小等于第一容量,第一容量小于或等于存储设备的最大单层单元容量、且大于存储设备的静态单层单元区域的容量;最大单层单元容量是存储设备的动态单层单元区域最大时动态单层单元区域和静态单层单元区域的容量之和。
当总体空间使用率大于第一阈值、且小于第二阈值时,最大可用缓存空间的大小随着总体空间使用率的增大而减小;第二阈值大于第一阈值。
当总体空间使用率大于或等于第二阈值时,最大可用缓存空间的大小等于第二容量,第二容量小于或等于第三容量;第三容量为存储设备的静态单层单元区域的容量,或者,存储设备的剩余可用存储空间的容量,又或者存储设备的静态单层单元区域的容量和剩余可用存储空间的容量中较小值;存储设备的剩余可用存储空间是指存储设备的存储除去常规数据所占用的空间后剩余的空间,常规数据包括存储设备所在的电子设备的本地用户产生的数据。
一种可能的示例中,第一阈值等于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值等于存储设备的单层单元容量最小时对应的最小总体空间使用率。
另一种可能的示例中,第一阈值小于或大于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值小于或大于存储设备的单层单元容量最小时对应的最小总体空间使用率。
一种可能的实现方式中,所述根据总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整,包括:当总体空间使用率大于第一阈值、且小于第二阈值时,总体空间使用率变化第三阈值时,根据总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整。
以第三阈值为5%为例,当总体空间使用率大于第一阈值、且小于第二阈值时,可以在总体空间使用率每增加5%时,根据总体空间使用率对存储设备的最大可用缓存空间的大小进行调整。
一种可能的实现方式中,所述方法还包括:接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;将第二文件缓存到存储设备的缓存空间中;存储设备的缓存空间中存储的缓存数据所占用的存储空间不超过最大可用缓存空间。
可选地,所述方法还包括:当内存的缓存空间中缓存了第一文件时,从内存的缓存空间中读取第一文件,并返回给第一应用程序;当存储设备的缓存空间中缓存了第一文件时,从存储设备的缓存空间中读取第一文件,并返回给第一应用程序。
可选地,所述方法还包括:根据总体空间使用率,对缓存文件存入存储设备的条件进行动态调整。
当总体空间使用率为第三总体空间使用率时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三值,和/或,缓存文件的大小小于或等于第四值;当总体空间使用率为第四总体空间使用率时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第五值,和/或,缓存文件的大小小于或等于第六值;第四总体空间使用率大于第三总体空间使用率,第五值大于第三值,第六值小于第四值。
该方法根据存储设备的总体空间使用率,对缓存文件可以存入存储设备的缓存空间的条件进行动态调整,可以控制对存储设备的文件写入,维持存储设备的IO性能处于较好的状态。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第一次数,和/或,缓存文件的大小小于或等于第一字节。
当总体空间使用率大于第一阈值、且小于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第二次数,和/或,缓存文件的大小小于或等于第二字节;第二阈值大于第一阈值;第二次数大于第一次数,第二字节小于第一字节。
当总体空间使用率大于或等于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三次数,和/或,缓存文件的大小小于或等于第三字节;第三次数大于第二次数,第三字节小于第二字节。
可选地,第二次数随着总体空间使用率的增大而增大,和/或,第二字节随着总体空间使用率的增加而减小。
一种可能的实现方式中,所述方法还包括:接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;当第二文件符合调整后的条件时,将第二文件缓存到存储设备的缓存空间中。
第二方面,本申请实施例提供一种存储装置,该装置可以应用于电子设备,以使电子设备实现如第一方面及第一方面的任意一种可能的实现方式所述的存储方法。该装置的功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与第一方面及第一方面的任意一种可能的实现方式所述的存储方法中的步骤相对应的模块或单元。
例如,该装置可以包括:获取单元、处理单元等。获取单元和处理单元可以配合实现如第一方面及第一方面的任意一种可能的实现方式的存储方法。如:获取单元, 可以用于获取存储设备的总体空间使用率;存储设备包括工作在多层单元区域、动态单层单元区域、以及静态单层单元区域;总体空间使用率是根据存储设备的存储空间的大小、以及存储设备的存储空间中被使用区域的大小所确定的。
处理单元,可以用于根据总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整;最大可用缓存空间是向存储设备中存储缓存数据时,允许缓存数据占用的最大存储空间。
当总体空间使用率为第一总体空间使用率时,动态单层单元区域的大小为第四容量,调整后的最大可用缓存空间的大小为第一值;当总体空间使用率为第二总体空间使用率时,动态单层单元区域的大小为第五容量,调整后的最大可用缓存空间的大小为第二值;第二总体空间使用率大于第一总体空间使用率,第五容量小于第四容量,第二值小于第一值。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,最大可用缓存空间的大小等于第一容量,第一容量小于或等于存储设备的最大单层单元容量、且大于存储设备的静态单层单元区域的容量;最大单层单元容量是存储设备的动态单层单元区域最大时动态单层单元区域和静态单层单元区域的容量之和。
当总体空间使用率大于第一阈值、且小于第二阈值时,最大可用缓存空间的大小随着总体空间使用率的增大而减小;第二阈值大于第一阈值。
当总体空间使用率大于或等于第二阈值时,最大可用缓存空间的大小等于第二容量,第二容量小于或等于第三容量;第三容量为存储设备的静态单层单元区域的容量,或者,存储设备的剩余可用存储空间的容量,又或者存储设备的静态单层单元区域的容量和剩余可用存储空间的容量中较小值;存储设备的剩余可用存储空间是指存储设备的存储除去常规数据所占用的空间后剩余的空间,常规数据包括存储设备所在的电子设备的本地用户产生的数据。
一种可能的示例中,第一阈值等于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值等于存储设备的单层单元容量最小时对应的最小总体空间使用率。
另一种可能的示例中,第一阈值小于或大于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值小于或大于存储设备的单层单元容量最小时对应的最小总体空间使用率。
一种可能的实现方式中,处理单元,具体用于当总体空间使用率大于第一阈值、且小于第二阈值时,总体空间使用率变化第三阈值时,根据总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整。
一种可能的实现方式中,处理单元还用于,接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;将第二文件缓存到存储设备的缓存空间中;存储设备的缓存空间中存储的缓存数据所占用的存储空间不超过最大可用缓存空间。
可选地,处理单元还用于,当内存的缓存空间中缓存了第一文件时,从内存的缓 存空间中读取第一文件,并返回给第一应用程序;当存储设备的缓存空间中缓存了第一文件时,从存储设备的缓存空间中读取第一文件,并返回给第一应用程序。
可选地,处理单元还用于,根据总体空间使用率,对缓存文件存入存储设备的条件进行动态调整。
当总体空间使用率为第三总体空间使用率时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三值,和/或,缓存文件的大小小于或等于第四值;当总体空间使用率为第四总体空间使用率时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第五值,和/或,缓存文件的大小小于或等于第六值;第四总体空间使用率大于第三总体空间使用率,第五值大于第三值,第六值小于第四值。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第一次数,和/或,缓存文件的大小小于或等于第一字节。
当总体空间使用率大于第一阈值、且小于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第二次数,和/或,缓存文件的大小小于或等于第二字节;第二阈值大于第一阈值;第二次数大于第一次数,第二字节小于第一字节。
当总体空间使用率大于或等于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三次数,和/或,缓存文件的大小小于或等于第三字节;第三次数大于第二次数,第三字节小于第二字节。
可选地,第二次数随着总体空间使用率的增大而增大,和/或,第二字节随着总体空间使用率的增加而减小。
一种可能的实现方式中,处理单元还用于,接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;当第二文件符合调整后的条件时,将第二文件缓存到存储设备的缓存空间中。
类似地,获取单元和处理单元可以配合实现如第一方面及第一方面的任意一种可能的实现方式所述的存储方法的全部步骤对应的功能,在此不再一一赘述。
第三方面,本申请实施例提供一种电子设备,电子设备可以包括存储设备。电子设备包括:处理器,用于存储处理器可执行指令的存储器;处理器被配置为执行所述指令时,使得电子设备实现如第一方面及第一方面的任意一种可能的实现方式所述的存储方法。
第四方面,本申请实施例提供一种计算机可读存储介质,其上存储有计算机程序指令;当所述计算机程序指令被电子设备执行时,使得电子设备实现如第一方面及第一方面的任意一种可能的实现方式所述的存储方法。
第五方面,本申请实施例提供一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电 子设备中运行时,所述电子设备中的处理器实现如第一方面及第一方面的任意一种可能的实现方式所述的存储方法。
上述第二方面至第五方面所具备的有益效果,可参考第一方面中所述,在此不再赘述。
第六方面,本申请实施例提供一种存储方法,所述方法包括:获取存储设备的总体空间使用率;存储设备包括工作在多层单元区域、动态单层单元区域、以及静态单层单元区域;总体空间使用率是根据存储设备的存储空间的大小、以及存储设备的存储空间中被使用区域的大小所确定的。根据总体空间使用率,对缓存文件存入存储设备的条件进行动态调整。
当总体空间使用率为第三总体空间使用率时,动态单层单元区域的大小为第四容量,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三值,和/或,缓存文件的大小小于或等于第四值;当总体空间使用率为第四总体空间使用率时,动态单层单元区域的大小为第五容量,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第五值,和/或,缓存文件的大小小于或等于第六值;第四总体空间使用率大于第三总体空间使用率,第五容量小于第四容量,第五值大于第三值,第六值小于第四值。
该方法根据存储设备的总体空间使用率,对缓存文件可以存入存储设备的缓存空间的条件进行动态调整,可以控制对存储设备的文件写入,维持存储设备的IO性能处于较好的状态。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第一次数,和/或,缓存文件的大小小于或等于第一字节。
当总体空间使用率大于第一阈值、且小于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第二次数,和/或,缓存文件的大小小于或等于第二字节;第二阈值大于第一阈值;第二次数大于第一次数,第二字节小于第一字节。
当总体空间使用率大于或等于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三次数,和/或,缓存文件的大小小于或等于第三字节;第三次数大于第二次数,第三字节小于第二字节。
一种可能的示例中,第一阈值等于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值等于存储设备的单层单元容量最小时对应的最小总体空间使用率。
另一种可能的示例中,第一阈值小于或大于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值小于或大于存储设备的单层单元容量最小时对应的最小总体空间使用率。
可选地,第二次数随着总体空间使用率的增大而增大,和/或,第二字节随着总体空间使用率的增加而减小。
一种可能的实现方式中,所述方法还包括:接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应 用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;当第二文件符合调整后的条件时,将第二文件缓存到存储设备的缓存空间中。
可选地,所述方法还包括:当内存的缓存空间中缓存了第一文件时,从内存的缓存空间中读取第一文件,并返回给第一应用程序;当存储设备的缓存空间中缓存了第一文件时,从存储设备的缓存空间中读取第一文件,并返回给第一应用程序。
第七方面,本申请实施例提供一种存储装置,该装置可以应用于电子设备,以使电子设备实现如第六方面及第六方面的任意一种可能的实现方式所述的存储方法。该装置的功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与第六方面及第六方面的任意一种可能的实现方式所述的存储方法中的步骤相对应的模块或单元。
例如,该装置可以包括:获取单元、处理单元等。获取单元和处理单元可以配合实现如第六方面及第六方面的任意一种可能的实现方式所述的存储方法。如:获取单元,可以用于获取存储设备的总体空间使用率;存储设备包括工作在多层单元区域、动态单层单元区域、以及静态单层单元区域;总体空间使用率是根据存储设备的存储空间的大小、以及存储设备的存储空间中被使用区域的大小所确定的。处理单元,可以用于根据总体空间使用率,对缓存文件存入存储设备的条件进行动态调整。
当总体空间使用率为第三总体空间使用率时,动态单层单元区域的大小为第四容量,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三值,和/或,缓存文件的大小小于或等于第四值;当总体空间使用率为第四总体空间使用率时,动态单层单元区域的大小为第五容量,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第五值,和/或,缓存文件的大小小于或等于第六值;第四总体空间使用率大于第三总体空间使用率,第五容量小于第四容量,第五值大于第三值,第六值小于第四值。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第一次数,和/或,缓存文件的大小小于或等于第一字节。
当总体空间使用率大于第一阈值、且小于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第二次数,和/或,缓存文件的大小小于或等于第二字节;第二阈值大于第一阈值;第二次数大于第一次数,第二字节小于第一字节。
当总体空间使用率大于或等于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三次数,和/或,缓存文件的大小小于或等于第三字节;第三次数大于第二次数,第三字节小于第二字节。
一种可能的示例中,第一阈值等于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值等于存储设备的单层单元容量最小时对应的最小总体空间使用率。
另一种可能的示例中,第一阈值小于或大于存储设备的单层单元容量最大时对应 的最大总体空间使用率;第二阈值小于或大于存储设备的单层单元容量最小时对应的最小总体空间使用率。
可选地,第二次数随着总体空间使用率的增大而增大,和/或,第二字节随着总体空间使用率的增加而减小。
一种可能的实现方式中,处理单元还用于,接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;当第二文件符合调整后的条件时,将第二文件缓存到存储设备的缓存空间中。
可选地,处理单元还用于,当内存的缓存空间中缓存了第一文件时,从内存的缓存空间中读取第一文件,并返回给第一应用程序;当存储设备的缓存空间中缓存了第一文件时,从存储设备的缓存空间中读取第一文件,并返回给第一应用程序。
类似地,获取单元和处理单元可以配合实现如第六方面及第六方面的任意一种可能的实现方式所述的存储方法的全部步骤对应的功能,在此不再一一赘述。
第八方面,本申请实施例提供一种电子设备,电子设备可以包括存储设备。电子设备包括:处理器,用于存储处理器可执行指令的存储器;处理器被配置为执行所述指令时,使得电子设备实现如第六方面及第六方面的任意一种可能的实现方式所述的存储方法。
第九方面,本申请实施例提供一种计算机可读存储介质,其上存储有计算机程序指令;当所述计算机程序指令被电子设备执行时,使得电子设备实现如第六方面及第六方面的任意一种可能的实现方式所述的存储方法。
第十方面,本申请实施例提供一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器实现如第六方面及第六方面的任意一种可能的实现方式所述的存储方法。
上述第七方面至第十方面所具备的有益效果,可参考第六方面中所述,在此不再赘述。
应当理解的是,本申请中对技术特征、技术方案、有益效果或类似语言的描述并不是暗示在任意的单个实施例中可以实现所有的特点和优点。相反,可以理解的是对于特征或有益效果的描述意味着在至少一个实施例中包括特定的技术特征、技术方案或有益效果。因此,本说明书中对于技术特征、技术方案或有益效果的描述并不一定是指相同的实施例。进而,还可以任何适当的方式组合本实施例中所描述的技术特征、技术方案和有益效果。本领域技术人员将会理解,无需特定实施例的一个或多个特定的技术特征、技术方案或有益效果即可实现实施例。在其他实施例中,还可在没有体现所有实施例的特定实施例中识别出额外的技术特征和有益效果。
附图说明
图1为本申请实施例提供的电子设备的结构示意图;
图2为本申请实施例提供的电子设备的结构示意图;
图3为本申请实施例提供的存储方法的流程示意图;
图4为本申请实施例提供的动态SLC容量的混合式SSD的存储空间的示意图;
图5为本申请实施例提供的SLC容量与总体空间使用率的一种关系示意图;
图6为本申请实施例提供的电子设备的存储设备的组成示意图;
图7为本申请实施例提供的存储方法的另一流程示意图;
图8为本申请实施例提供的存储装置的结构示意图;
图9为本申请实施例提供的存储装置的另一结构示意图。
具体实施方式
以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请以下各实施例中,“至少一个”、“一个或多个”是指一个或两个以上(包含两个)。字符“/”一般表示前后关联对象是一种“或”的关系。
在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。术语“连接”包括直接连接和间接连接,除非另外说明。
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。
在本申请实施例中,“示例性地”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性地”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性地”或者“例如”等词旨在以具体方式呈现相关概念。
固态闪存存储设备(solid state disk,SSD)也称固态磁盘、固态硬盘等。随着闪存存储技术的快速进步和存储需求的日益增加,SSD的存储密度也逐渐增大。例如,SSD的存储单元的使用模式单层单元(single-level cell,SLC)模式逐渐增加到了双层单元(multi-level cell,MLC)模式、三层单元(triple-level cell,TLC)模式、四层单元(quad-level cell,QLC)模式等。其中,SLC模式下SSD的每个存储单元可以存储一比特数据,MLC模式下SSD的每个存储单元可以存储两比特数据,TLC模式下SSD的每个存储单元可以存储三比特数据,QLC模式下SSD的每个存储单元可以存储四比特数据。
SSD的存储密度增大,可以使SSD的容量更大、成本更低,但SSD的输入输出(input and output,IO)性能(即读写性能)会出现大幅度的下降。目前,在SSD中采用混合高速介质和低速介质的方式,可以优化SSD的IO性能。在SSD中采用混合 高速介质和低速介质是指:SSD可以包括高速介质和低速介质,SSD优先使用高速介质满足读写要求,如:高速介质可以是使用SLC模式的存储介质、低速介质可以是使用MLC、TLC、QLC等多层单元模式的存储介质。也即,采用混合高速介质和低速介质的SSD的存储空间可以包括多层单元区域和SLC区域。前述采用混合高速介质和低速介质的SSD可以被称为混合式SSD。
目前,混合式SSD可以包括:静态SLC容量的混合式SSD、动态SLC容量的混合式SSD。以混合式SSD的存储空间包括QLC区域(QLC区域也可以是MLC区域、TLC区域等)和SLC区域为例,图1为混合式SSD的存储空间的组成示意图。其中,图1中的(a)示出了静态SLC容量的混合式SSD,图1中的(b)示出了动态SLC容量的混合式SSD。
如图1中的(a)所示,静态SLC容量的混合式SSD的存储空间可以包括:QLC区域101和静态SLC区域102。其中,静态SLC区域102的大小固定,静态SLC区域102可以作为整个静态SLC容量的混合式SSD的读写缓冲区域。
如图1中的(b)所示,动态SLC容量的混合式SSD的存储空间可以包括:QLC区域103、动态SLC区域104、以及静态SLC区域105。其中,动态SLC区域104的闪存块原本工作在QLC模式下,但这部分闪存块可以转换为SLC模式,所以,转换为SLC模式后的这部分闪存块组成的区域可以被称为动态SLC区域104。与图1中的(a)所示的静态SLC容量的混合式SSD相比,图1中的(b)所示的动态SLC容量的混合式SSD中,静态SLC区域105的大小也是固定的,但动态SLC区域104的大小是变化的。随着动态SLC容量的混合式SSD的总体空间使用率逐渐增加,动态SLC区域104中的部分区域会切换到QLC模式下工作(即会转换为QLC区域103),动态SLC区域104会逐渐减小。随着动态SLC容量的混合式SSD的总体空间使用率逐渐减小,动态SLC区域104中切换到QLC模式下工作的部分区域会切换回SLC区域,动态SLC区域104会逐渐增加。其中,动态SLC容量的混合式SSD的总体空间使用率可以是:动态SLC容量的混合式SSD的存储空间被使用的区域与全部区域(包括被使用的区域和未使用的区域)的比值。动态SLC区域104和静态SLC区域105可以作为整个动态SLC容量的混合式SSD的读写缓冲区域。相较于静态SLC容量的混合式SSD而言,动态SLC容量的混合式SSD的读写缓冲区域更大,IO性能更好。
对于动态SLC容量的混合式SSD而言,动态SLC区域中的部分区域切换到多层单元模式下工作时,动态SLC容量的混合式SSD的容量会增大,但动态SLC容量的混合式SSD的IO性能会下降。
在此背景技术下,本申请实施例提供了一种存储方法,该方法可以根据动态SLC容量的混合式SSD的总体空间使用率,对动态SLC容量的混合式SSD的最大可用缓存空间进行动态调整,优化动态SLC容量的混合式SSD的IO性能。
其中,动态SLC容量的混合式SSD的总体空间使用率,可以用动态SLC容量的混合式SSD的存储空间中被使用区域占全部区域的比值来表示。动态SLC容量的混合式SSD的存储空间中的被使用区域是指:动态SLC容量的混合式SSD的存储空间中存储了常规数据的区域、以及存储了缓存数据的区域。最大可用缓存空间是指:向动态SLC容量的混合式SSD中存储缓存数据时,允许缓存数据占用的最大存储空间。
示例性地,动态SLC容量的混合式SSD可以作为某个电子设备(如手机)的存储设备,常规数据可以包括:电子设备的本地用户产生的数据,缓存数据可以包括:电子设备为了提升数据请求性能而存储在本地的远端数据。
以电子设备为手机为例,手机的操作系统中可以运行各类联网应用程序,如聊天软件、网络视频播放器等,这些联网应用程序经常需要向网络端(即远端)请求数据文件,而手机的内存空间通常较小,难以满足所有应用的文件缓存需求,应用的每次文件请求如果都经过网络,会带来难以忍受的性能下降。所以,手机可以通过将数据文件作为缓存数据存储到本地SSD的方式,提升数据请求性能。
示例性地,该方法可以应用于上述使用动态SLC容量的混合式SSD作为存储设备的电子设备。
一些实施例中,电子设备可以包括:终端设备、服务器或虚拟机(virtual machine,VM)等。终端设备可以是手机、平板电脑、桌面型、膝上型、手持计算机、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本,以及蜂窝电话、个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)\虚拟现实(virtual reality,VR)设备等设备,本申请实施例对电子设备的具体形态不作特殊限制。
示例性地,以电子设备为手机为例,图2为本申请实施例提供的电子设备的结构示意图。如图2所示,电子设备可以包括:处理器210,外部存储器接口220,内部存储器221,通用串行总线(universal serial bus,USB)接口230,充电管理模块240,电源管理模块241,电池242,天线1,天线2,移动通信模块250,无线通信模块260,音频模块270,扬声器270A,受话器270B,麦克风270C,耳机接口270D,传感器模块280,按键290,马达291,指示器292,摄像头293,显示屏294,以及用户标识模块(subscriber identification module,SIM)卡接口295等。
处理器210可以包括一个或多个处理单元,例如:处理器210可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
其中,控制器可以是电子设备的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器210中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器210中的存储器为高速缓冲存储器。该存储器可以保存处理器210刚用过或循环使用的指令或数据。
在一些实施例中,处理器210可以包括一个或多个接口。接口可以包括集成电路(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)接口等。
可以理解的是,本实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备的结构限定。在另一些实施例中,电子设备也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
充电管理模块240用于从充电器接收充电输入。充电管理模块240为电池242充电的同时,还可以通过电源管理模块241为电子设备供电。
电源管理模块241用于连接电池242,充电管理模块240与处理器210。电源管理模块241接收电池242和/或充电管理模块240的输入,为处理器210,内部存储器221,外部存储器,显示屏294,摄像头293,和无线通信模块260等供电。电源管理模块241还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块241也可以设置于处理器210中。在另一些实施例中,电源管理模块241和充电管理模块240也可以设置于同一个器件中。
电子设备的无线通信功能可以通过天线1,天线2,移动通信模块250,无线通信模块260,调制解调处理器以及基带处理器等实现。
天线1和天线2用于发射和接收电磁波信号。移动通信模块250可以提供应用在电子设备上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块250可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块250可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块250还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块250的至少部分功能模块可以被设置于处理器210中。在一些实施例中,移动通信模块250的至少部分功能模块可以与处理器210的至少部分模块被设置在同一个器件中。
调制解调处理器可以包括调制器和解调器。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器210,与移动通信模块250或其他功能模块设置在同一个器件中。
无线通信模块260可以提供应用在电子设备上的包括无线局域网(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)等无线通信的解决方案。无线通信模块260可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块260经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器210。无线通信模块260还可以从处理器210接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。
在一些实施例中,电子设备的天线1和移动通信模块250耦合,天线2和无线通信模块260耦合,使得电子设备可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code  division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。例如,在本申请实施例中,电子设备可以利用无线通信模块260,通过无线通信技术与一些联网应用程序的网络端进行交互。
电子设备通过GPU,显示屏294,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏294和应用处理器。处理器210可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏294用于显示图像,视频等。显示屏294包括显示面板。显示面板可以采用液晶显示屏(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)等。在一些实施例中,电子设备可以包括1个或N个显示屏294,N为大于1的正整数。
电子设备可以通过ISP,摄像头293,视频编解码器,GPU,显示屏294以及应用处理器等实现拍摄功能。
外部存储器接口220可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备的存储能力。外部存储卡通过外部存储器接口220与处理器210通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。
内部存储器221可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。处理器210通过运行存储在内部存储器221的指令,从而执行电子设备的各种功能应用以及数据处理。例如,在本申请实施例中,处理器210可以通过执行存储在内部存储器221中的指令,实现本申请实施例提供的存储方法。内部存储器221可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器221可以包括高速随机存取存储器,还可以包括非易失性存储器,例如动态SLC容量的混合式SSD,闪存器件,通用闪存存储器(universal flash storage,UFS)等。
电子设备可以通过音频模块270,扬声器270A,受话器270B,麦克风270C,耳机接口270D,以及应用处理器等实现音频功能。例如通话,音乐播放,录音等。
传感器模块280可以包括压力传感器280A,陀螺仪传感器280B,气压传感器280C,磁传感器280D,加速度传感器280E,距离传感器280F,接近光传感器280G,指纹传感器280H,温度传感器280J,触摸传感器280K,环境光传感器280L,骨传导传感器280M等。
可以理解的是,图2所示的结构并不构成对电子设备的具体限定。在另一些实施例中,当电子设备是平板电脑、桌面型、膝上型、手持计算机、笔记本电脑、UMPC、上网本,以及蜂窝电话、PDA、AR\VR设备等其他设备时,电子设备可以包括比图2所示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图2所示的部件可以以硬件,软件或软件和硬件的组合实现。本申请实施例对电子设备的具体结构不作限制。
下面结合具体的示例对本申请实施例提供的存储方法进行说明。
示例性地,图3为本申请实施例提供的存储方法的流程示意图。如图3所示,该方法可以包括:
S301、获取动态SLC容量的混合式SSD的总体空间使用率。
例如,图4为本申请实施例提供的动态SLC容量的混合式SSD的存储空间的示意图。如图4所示,动态SLC容量的混合式SSD的存储空间可以包括:常规数据存储空间、缓存数据存储空间、空闲空间。
其中,常规数据存储空间存储了常规数据,如:电子设备的本地用户产生的数据。缓存数据存储空间存储了缓存数据,如:电子设备为了提升数据请求性能而存储在本地的远端数据。空闲空间为没有存储数据的存储空间。
动态SLC容量的混合式SSD的总体空间使用率可以是:常规数据存储空间的大小与缓存数据存储空间的大小相加后的和,与动态SLC容量的混合式SSD的存储空间的大小的比值。常规数据存储空间与缓存数据存储空间所组成的区域即动态SLC容量的混合式SSD的存储空间中的被使用区域。常规数据存储空间与缓存数据存储空间所组成的区域也可以称为总体使用空间。
可以理解的,动态SLC容量的混合式SSD中,动态SLC区域的大小与总体空间使用率相关。例如,当总体空间使用率为第一总体空间使用率时,动态SLC区域的大小为第四容量;当总体空间使用率为第二总体空间使用率时,动态SLC区域的大小为第五容量;第二总体空间使用率大于第一总体空间使用率时,第五容量小于第四容量。其中,第二总体空间使用率和第一总体空间使用率均大于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率、且小于动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率。
S302、根据总体空间使用率,对动态SLC容量的混合式SSD的最大可用缓存空间进行调整。
一些实施例中,S302可以包括:当总体空间使用率小于或等于第一阈值时,调整动态SLC容量的混合式SSD的最大可用缓存空间,使最大可用缓存空间的大小等于第一容量,第一容量小于或等于动态SLC容量的混合式SSD的最大SLC容量、且大于动态SLC容量的混合式SSD的静态SLC区域的容量;当总体空间使用率大于第一阈值、且小于第二阈值时,第二阈值大于第一阈值,调整动态SLC容量的混合式SSD的最大可用缓存空间,使最大可用缓存空间的大小随着总体空间使用率的增大而减小;当总体空间使用率大于或等于第二阈值时,调整动态SLC容量的混合式SSD的最大可用缓存空间,使最大可用缓存空间的大小等于第二容量,第二容量小于或等于动态SLC容量的混合式SSD的静态SLC区域的容量。可以理解的,第二容量小于第一容 量。
其中,最大SLC容量是指动态SLC容量的混合式SSD中所有能够转换为SLC模式的多层单元区域全部工作在SLC模式下时,动态SLC区域和静态SLC区域的容量之和。
一种可能的实现方式中,第一阈值可以是动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率;第二阈值可以是动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率。
例如,当动态SLC容量的混合式SSD中所有能够转换为SLC模式的多层单元区域全部工作在SLC模式下时,动态SLC容量的混合式SSD的SLC容量最大。随着总体空间使用率的增大,当总体空间使用率增大到某个值时,动态SLC区域会开始减小,此时的总体空间使用率即为SLC容量最大时对应的最大总体空间使用率。随着总体空间使用率的继续增大,当总体空间使用率增大到另外某个值时,动态SLC区域减小至0,动态SLC容量的混合式SSD的SLC容量变为最小(即静态SLC区域的容量),此时的总体空间使用率即为SLC容量最小时对应的最小总体空间使用率。
示例性地,图5为本申请实施例提供的SLC容量与总体空间使用率的一种关系示意图。其中,横纵表轴表示动态SLC容量的混合式SSD的总体空间使用率,纵坐标轴表示当前总体空间使用率对应的SLC容量。SLC容量 max表示动态SLC容量的混合式SSD的最大SLC容量,即:当动态SLC容量的混合式SSD中所有能够转换为SLC模式的多层单元区域全部工作在SLC模式下时,动态SLC区域和静态SLC区域的容量之和。SLC容量 min表示动态SLC容量的混合式SSD的最小SLC容量,即:静态SLC区域的容量。
如图5所示,当总体空间使用率小于或等于m1(m1大于0,且小于m2)时,动态SLC容量的混合式SSD的SLC容量为SLC容量 max;当总体空间使用率大于m1、且小于m2(m2大于m1,且小于100%)时,动态SLC容量的混合式SSD的SLC容量随着总体空间使用率的增大而减小;当总体空间使用率等于m2时,动态SLC容量的混合式SSD的SLC容量为SLC容量 min
m1即为SLC容量最大时对应的最大总体空间使用率,m2即为SLC容量最小时对应的最小总体空间使用率。第一阈值的大小可以等于m1,第二阈值的大小可以等于m2。
本实现方式中,当总体空间使用率小于或等于m1时,可以调整动态SLC容量的混合式SSD的最大可用缓存空间,使最大可用缓存空间的大小等于第一容量,第一容量小于或等于SLC容量 max;当总体空间使用率大于m1、且小于m2时,可以调整动态SLC容量的混合式SSD的最大可用缓存空间,使最大可用缓存空间的大小随着总体空间使用率的增大而减小;当总体空间使用率大于或等于m2时,可以调整动态SLC容量的混合式SSD的最大可用缓存空间,使最大可用缓存空间的大小等于第二容量,第二容量可以小于或等于SLC容量 min
也即,本实现方式中,可以根据总体空间使用率,将动态SLC容量的混合式SSD划分为:总体空间使用率小于或等于第一阈值,总体空间使用率大于第一阈值、且小于第二阈值,以及总体空间使用率大于或等于第二阈值等三个阶段。示例性地,总体 空间使用率小于或等于第一阈值的阶段可以称为空闲阶段,总体空间使用率大于第一阈值、且小于第二阈值的阶段可以称为中度阶段,总体空间使用率大于或等于第二阈值的阶段可以称为重度阶段。空闲阶段中,动态SLC容量的混合式SSD中所有能够转换为SLC模式的多层单元区域全部工作在SLC模式下,SLC容量处于最大值,动态SLC容量的混合式SSD的整体性能处于较佳状态,本申请可以将最大可用缓存空间的大小设置为第一容量,第一容量可以小于或等于最大SLC容量。中度阶段中,动态SLC容量的混合式SSD中能够转换为SLC模式的多层单元区域部分工作在SLC模式下,SLC容量处于下降趋势,本申请可以根据总体空间使用率调整最大可用缓存空间的大小,使其随着总体空间使用率的增大而减小。重度阶段中,动态SLC容量的混合式SSD中所有能够转换为SLC模式的多层单元区域全部工作在多层单元模式下,动态SLC容量的混合式SSD的SLC容量即静态SLC区域的容量,本申请可以将最大可用缓存空间的大小设置为第二容量,第二容量可以小于或等于静态SLC区域的容量。
以上述第一容量等于最大SLC容量,上述第二容量等于静态SLC区域的容量为例,在一种可能的示例中,当总体空间使用率大于第一阈值、且小于第二阈值时,可以按照下述公式(1)调整动态SLC容量的混合式SSD的最大可用缓存空间,使最大可用缓存空间的大小随着总体空间使用率的增大而减小。
Y=kX+c         公式(1)
公式(1)中,Y表示最大可用缓存空间的大小,X表示总体空间使用率,k表示系数,c为常数,k和c的值可以由第一容量和第一阈值、以及第二容量和第二阈值代入公式(1)计算得到。
示例性地,以第一容量为n1(最大SLC容量),第一阈值为上述m1,第二容量为n2(静态SLC区域的容量)为例,将n1和m1,以及n2和n2代入上述公式(1),可以得到下述方程组(1)。
Figure PCTCN2022119444-appb-000001
对方程组(1)求解,可以得到k和c的值分别如下。
Figure PCTCN2022119444-appb-000002
c=n1-km1=n2-km2
在得到k和c的值后,即可按照上述公式(1),根据总体空间使用率对动态SLC容量的混合式SSD的最大可用缓存空间进行调整,使最大可用缓存空间的大小随着总体空间使用率的增大而减小。
可以理解的,当按照上述公式(1),根据总体空间使用率对动态SLC容量的混合式SSD的最大可用缓存空间进行调整时,最大可用缓存空间的大小可以随着总体空间使用率的增大而线性减小。另外,本示例仅以公式(1)作为调整最大可用缓存空间的大小随着总体空间使用率的增大而减小的一种方式,并不用于限制。其他一些示例中,也可以采用其他方式调整最大可用缓存空间的大小随着总体空间使用率的增大而减小。
可选地,一些实施例中,当总体空间使用率大于第一阈值、且小于第二阈值时,可以在总体空间使用率每变化(如增加或减小)第三阈值时,按照上述公式(1),根 据总体空间使用率对动态SLC容量的混合式SSD的最大可用缓存空间进行调整。例如,第三阈值可以是5%、6%、8%等,在此对第三阈值的大小不作限制。
以第三阈值为5%为例,当总体空间使用率大于第一阈值、且小于第二阈值时,可以在总体空间使用率每增加5%时,按照上述公式(1),根据总体空间使用率对动态SLC容量的混合式SSD的最大可用缓存空间的大小进行调整。
也即,本实施例中,可以在第一阈值和第二阈值之间,每间隔第三阈值作为一个动态调整点,对动态SLC容量的混合式SSD的最大可用缓存空间进行调整。最大可用缓存空间的变化可以不是连续的,当总体空间使用率变化第三阈值时,最大可用缓存空间的大小可以更新一次。
以上实现方式介绍了第一阈值是动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,第二阈值是动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率的情况。可选地,另一种可能的实现方式中,第一阈值也可以小于或大于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,如:第一阈值可以小于或大于上述m1;第二阈值也可以小于或大于动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率,如第二阈值可以小于或大于上述m2。本申请对第一阈值和第二阈值的具体大小不作限制。
例如,一种可能的示例中,第一阈值可以大于或等于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,第二阈值可以小于或等于动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率。
又例如,另一种可能的示例中,第一阈值可以小于或等于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,第二阈值可以大于或等于动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率。
可选地,对于上述第一阈值小于或等于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,第二阈值大于或等于动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率的情况,在一些可能的实现场景中,第一阈值可以为0,第二阈值可以为100%,也即,可以根据总体空间使用率,将动态SLC容量的混合式SSD划分为一个整体的阶段。
又例如,又一种可能的示例中,第一阈值可以小于或等于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,第二阈值可以小于或等于动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率。
可选地,对于上述第一阈值小于或等于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,第二阈值小于或等于动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率的情况,在一些可能的实现场景中,第一阈值可以为0,第二阈值可以小于上述m2,也即,可以根据总体空间使用率,将动态SLC容量的混合式SSD划分为:总体空间使用率大于第一阈值、且小于第二阈值,以及总体空间使用率大于或等于第二阈值等两个阶段(总体空间使用率等于0的情况可以划分在总体空间使用率大于第一阈值、且小于第二阈值的极端情况中)。
又例如,又一种可能的示例中,第一阈值可以大于或等于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,第二阈值可以大于或等于动态 SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率。
可选地,对于上述第一阈值大于或等于动态SLC容量的混合式SSD的SLC容量最大时对应的最大总体空间使用率,第二阈值大于或等于动态SLC容量的混合式SSD的SLC容量最小时对应的最小总体空间使用率的情况,在一些可能的实现场景中,第一阈值可以为上述m1,第二阈值可以为100%,也即,可以根据总体空间使用率,将动态SLC容量的混合式SSD划分为:总体空间使用率小于或等于第一阈值,以及总体空间使用率大于第一阈值等两个阶段(总体空间使用率等于第二阈值(即100%)的情况可以划分在总体空间使用率大于第一阈值的极端情况中)。
需要说明的,本申请实施例中所述的第一阈值和第二阈值都不为负数。
以上通过多个不同的示例分别示出了按照第一阈值和第二阈值的大小,根据总体空间使用率,将动态SLC容量的混合式SSD划分为一个整体的阶段,或者两个或三个阶段,并在每个阶段分别对最大可用缓存空间的大小进行调整的方式。可选地,还有一些可能的实现方式中,还可以根据总体空间使用率,将动态SLC容量的混合式SSD划分为更多个阶段,并在每个阶段分别对最大可用缓存空间的大小进行调整。例如,可以按照上述前述实施例中所述的方式先将动态SLC容量的混合式SSD划分为空闲阶段、中度阶段和重度阶段,其中,中度阶段可以被进一步划分为多个子阶段,如:中度阶段可以按照总体空间使用率的大小等间距或非等间距划分为S(S为大于1的整数)个子阶段,每个子阶段可以按照不同的方式(不限于上述公式(1))对最大可用缓存空间的大小进行调整,使其最大可用缓存空间的大小随着总体空间使用率的增大而减小,如:最大可用缓存空间的大小随着总体空间使用率的增大呈线性减小或非线性减小。但需要说明的是,最大可用缓存空间的最大值小于或等于最大SLC容量、且最大可用缓存空间的大小随着总体空间使用率的增大整体呈减小的趋势。
例如,当总体空间使用率为第一总体空间使用率时,调整后的最大可用缓存空间的大小为第一值;当总体空间使用率为第二总体空间使用率时,调整后的最大可用缓存空间的大小为第二值;第二总体空间使用率大于第一总体空间使用率时,第二值小于第一值。
需要说明的是,在本申请实施例中,对于前述实施例中所述的最大可用缓存空间非连续变化(如减小)的情况,第二总体空间使用率和第一总体空间使用率可以是两个不同阶段中动态SLC容量的混合式SSD的总体空间使用率。或者,对于前述实施例中所述的最大可用缓存空间连续变化(如减小)的情况,第二总体空间使用率和第一总体空间使用率也可以是同一个阶段中动态SLC容量的混合式SSD的总体空间使用率。其中,阶段的划分可以参考前述实施例中所述。
可以理解的,前述实施例中提到的在第一阈值和第二阈值之间,每间隔第三阈值作为一个动态调整点,对动态SLC容量的混合式SSD的最大可用缓存空间进行调整的方式,也可以认为是将第一阈值和第二阈值之间的总体空间使用率按照第三阈值作为间隔划分为了多个子阶段,但每个子阶段内对应的最大可用缓存空间的大小是不变的,相邻两个子阶段之间的最大可用缓存空间的大小会发生变化,任意两个相邻的子阶段之间调整最大可用缓存空间的方式是相同的。
以上实施例中说明了当总体空间使用率小于或等于第一阈值、总体空间使用率大 于第一阈值、且小于第二阈值,总体空间使用率大于或等于第二阈值等三种情况下,对最大可用缓存空间的大小调整方式。其中,当总体空间使用率大于或等于第二阈值时,调整动态SLC容量的混合式SSD的最大可用缓存空间,使最大可用缓存空间的大小等于第二容量,第二容量小于或等于动态SLC容量的混合式SSD的静态SLC区域的容量。可选地,另外一些实施例中,第二容量也可以小于或等于动态SLC容量的混合式SSD的剩余可用存储空间的容量,或者,第二容量也可以小于或等于动态SLC容量的混合式SSD的剩余可用存储空间的容量和静态SLC区域的容量之间的较小值。
也即,当总体空间使用率大于或等于第二阈值时,最大可用缓存空间的大小等于第二容量,第二容量可以小于或等于第三容量;第三容量为动态SLC容量的混合式SSD的静态SLC区域的容量,或者,动态SLC容量的混合式SSD的剩余可用存储空间的容量,又或者动态SLC容量的混合式SSD的静态SLC区域的容量和剩余可用存储空间的容量中的较小值。
其中,动态SLC容量的混合式SSD的剩余可用存储空间是指:动态SLC容量的混合式SSD的存储空间中除去常规数据所占用的空间后剩余的空间。例如,对于上述图4所示的动态SLC容量的混合式SSD的存储空间而言,动态SLC容量的混合式SSD的剩余可用存储空间可以包括:缓存数据存储空间和空闲空间。
本申请实施例提供的该存储方法中,通过控制最大可用缓存空间的方法,可以减少动态SLC容量的混合式SSD的总体空间使用量,保持可用SLC缓存空间的大小,提高动态SLC容量的混合式SSD的IO性能。
示例性地,图6为本申请实施例提供的电子设备的存储设备的组成示意图。如图6所示,电子设备可以包括内存601、动态SLC容量的混合式SSD 602。
其中,内存601中可以包括:一个或多个应用程序,缓存系统(或称为缓存管理系统),内存缓存存储空间(简称内存缓存)。例如,应用程序可以包括:聊天软件、网络视频播放器等各类联网应用程序。
动态SLC容量的混合式SSD 602中可以包括:常规数据存储空间、闪存缓存存储空间(即缓存数据存储空间,简称闪存缓存)、空闲空间。
当内存601中的应用程序提出网络文件请求(或称为文件请求)时,如:第一应用程序可以提出网络文件请求,该网络文件请求可以用于请求第一文件,内存601中的缓存系统可以截获该网络文件请求,并判断内存缓存(即内存的缓存空间)和闪存缓存(即动态SLC容量的混合式SSD 602的缓存空间)中是否缓存了该网络文件请求所请求的网络文件(即第一文件);当内存缓存中缓存了该网络文件请求所请求的网络文件时,内存缓存可以向应用程序返回对应的网络文件。当闪存缓存中缓存了该网络文件请求所请求的网络文件时,闪存缓存可以向应用程序返回对应的网络文件。当内存缓存和闪存缓存中都没有缓存该网络文件请求所请求的网络文件时,电子设备可以向通过网络向远端(如应用程序对应的服务器,服务器与)请求缓存该网络文件,并缓存在内存缓存中。
当内存缓存空间占满时,缓存系统可以根据剔除策略从内存缓存中剔除文件(如剔除第二文件),本申请对剔除策略不作限制。内存缓存中剔除的文件可以被缓存到闪存缓存中。缓存系统可以按照本申请实施例提供的存储方法,根据动态SLC容量的 混合式SSD 602的总体空间使用率,对动态SLC容量的混合式SSD 602的最大可用缓存空间进行调整。内存缓存中剔除的文件被缓存到闪存缓存中时,缓存系统可以按照剔除策略对闪存缓存中的缓存文件(即缓存数据)进行剔除,使得闪存缓存中存入的缓存文件所占用的空间不超过最大可用缓存空间。
示例性地,缓存系统中可以包括一个缓存空间管理模块,该缓存空间管理模块可以用于实现上述根据动态SLC容量的混合式SSD 602的总体空间使用率,对动态SLC容量的混合式SSD 602的最大可用缓存空间进行调整的功能。
可选地,本申请实施例提供的该方法中,每次调整最大可用缓存空间的大小后,闪存缓存中的缓存文件所占用的空间如果超过更新后的最大可用缓存空间,则可以按照剔除策略对闪存缓存中的缓存文件进行剔除,使得闪存缓存中存入的缓存文件所占用的空间不超过更新后的最大可用缓存空间。
可选地,本申请实施例中,当动态SLC容量的混合式SSD 602的总体空间使用率达到100%时,如果常规数据存储空间需要继续增长,则可以压缩最大可用缓存空间,剔除闪存缓存中的缓存文件,以腾出空间供常规数据使用。
以上实施例介绍了本申请实施例提供的存储方法中,根据总体空间使用率,对动态SLC容量的混合式SSD的最大可用缓存空间进行调整的过程。可选地,还有一些实施例中,本申请实施例提供的存储方法中,还可以根据动态SLC容量的混合式SSD的总体空间使用率,对缓存文件可以存入动态SLC容量的混合式SSD的缓存数据存储空间(以下均称为闪存缓存)的条件进行动态调整。电子设备可以根据缓存文件可以存入动态SLC容量的混合式SSD的闪存缓存的条件,判断缓存文件是否应该存入闪存缓存中。例如,这些缓存文件可以是从内存缓存中剔除的文件。该方法根据动态SLC容量的混合式SSD的总体空间使用率,对缓存文件可以存入动态SLC容量的混合式SSD的闪存缓存的条件进行动态调整,可以控制对动态SLC容量的混合式SSD的文件写入,维持动态SLC容量的混合式SSD的IO性能处于较好的状态。
示例性地,图7为本申请实施例提供的存储方法的另一流程示意图。如图7所示,该方法可以包括:
S701、获取动态SLC容量的混合式SSD的总体空间使用率。
S701的具体实现过程可以参考前述S301所述,在此不再赘述。
S702、根据总体空间使用率,对缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件进行动态调整。
一些实施例中,电子设备的缓存系统可以将最不常使用(least frequently used,LFU)策略作为闪存缓存的文件管理策略。S702可以包括:当总体空间使用率小于或等于第一阈值时,调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件为:缓存文件在内存中文件操作(如读写操作)命中的次数大于或等于第一次数(第一次数为大于0的整数),即,当缓存文件在内存中文件操作命中的次数大于或等于第一次数时,缓存文件可以被存入动态SLC容量的混合式SSD的闪存缓存;当总体空间使用率大于第一阈值、且小于第二阈值时,第二阈值大于第一阈值,调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件为:缓存文件在内存中文件操作命中的次数大于或等于第二次数(第二次数为大于0的整数),第二次数大于第一次数, 即,当缓存文件在内存中文件操作命中的次数大于或等于第二次数时,缓存文件可以被存入动态SLC容量的混合式SSD的闪存缓存;当总体空间使用率大于或等于第二阈值时,调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件为:缓存文件在内存中文件操作命中的次数大于或等于第三次数(第三次数为大于0的整数),第三次数大于第二次数,即,当缓存文件在内存中文件操作命中的次数大于或等于第三次数时,缓存文件可以被存入动态SLC容量的混合式SSD的闪存缓存。
其中,第一阈值和第二阈值的大小可以参考前述实施例中所述,不再赘述。
本实施例中,第一次数小于第二次数,第二次数小于第三次数,总体空间使用率从小于或等于第一阈值的阶段,向体空间使用率大于第一阈值、且小于第二阈值的阶段、以及总体空间使用率大于或等于第二阈值的阶段变换的过程中,缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件越来越严格,可以维持动态SLC容量的混合式SSD的IO性能处于较好的状态。
示例性地,一些可能的实现方式中,第二次数可以是第一次数的整数倍,如:第一次数可以是L次,第二次数可以是2*L次(“*”表示乘)。第三次数可以是第二次数的整数倍,如:第三次数可以是4*L次。另外一些可能的实现方式中,第二次数也可以不是第一次数的整数倍,如:第一次数可以是L次,第二次数可以是L+L1次。第三次数也可以不是第二次数的整数倍,如:第三次数可以是L+L1+L2次。本申请对第一次数、第二次数、以及第三次数的具体大小不作限制。
另外一些实施例中,电子设备的缓存系统对闪存缓存的文件管理策略可以是基于文件大小的管理策略。S702可以包括:当总体空间使用率小于或等于第一阈值时,调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件为:缓存文件的大小小于或等于第一字节(第一字节为大于0的值),即,当缓存文件的大小小于或等于第一字节时,缓存文件可以被存入动态SLC容量的混合式SSD的闪存缓存;当总体空间使用率大于第一阈值、且小于第二阈值时,第二阈值大于第一阈值,调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件为:缓存文件的大小小于或等于第二字节(第二字节为大于0的值),第二字节小于第一字节,即,当缓存文件的大小小于或等于第二字节时,缓存文件可以被存入动态SLC容量的混合式SSD的闪存缓存;当总体空间使用率大于或等于第二阈值时,调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件为:缓存文件的大小小于或等于第三字节(第三字节为大于0的值),第三字节小于第二字节,即,当缓存文件的大小小于或等于第三字节时,缓存文件可以被存入动态SLC容量的混合式SSD的闪存缓存。
其中,第一阈值和第二阈值的大小可以参考前述实施例中所述,不再赘述。
本实施例中,第三字节小于第二字节,第二字节小于第一字节,总体空间使用率从小于或等于第一阈值的阶段,向体空间使用率大于第一阈值、且小于第二阈值的阶段、以及总体空间使用率大于或等于第二阈值的阶段变换的过程中,能够满足存入动态SLC容量的混合式SSD的闪存缓存的条件的缓存文件越来越小,可以维持动态SLC容量的混合式SSD的IO性能处于较好的状态。
示例性地,一些可能的实现方式中,第一字节可以是第二字节的整数倍,第二字节可以是第三字节的整数倍,如:第一字节可以是B字节,第二字节可以是B/2字节 (“/”表示除以),第三字节可以是B/4字节。另外一些可能的实现方式中,第一字节、第二字节、以及第三字节之间也可以不是整数倍的关系,如:第一字节可以是B字节,第二字节可以是B-B1字节,第三字节可以是B-B1-B2字节。
可选地,以上实施例中示出了总体空间使用率小于或等于第一阈值,总体空间使用率大于第一阈值、且小于第二阈值,以及总体空间使用率大于或等于第二阈值三种情况下对缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件进行动态调整的方式。其中,对于总体空间使用率大于第一阈值、且小于第二阈值的情况,缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件是始终相同的。还有一些实施例中,对于总体空间使用率大于第一阈值、且小于第二阈值的情况,也可以调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件,使缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件随着总体空间使用率的增大而越来越严格。
例如,当电子设备的缓存系统将LFU策略作为闪存缓存的文件管理策略时,对于总体空间使用率大于第一阈值、且小于第二阈值的情况,可以调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件为:缓存文件在内存中文件操作命中的次数大于或等于第二次数,且第二次数随着总体空间使用率的增大而增大。
又例如,当电子设备的缓存系统对闪存缓存的文件管理策略是基于文件大小的管理策略时,对于总体空间使用率大于第一阈值、且小于第二阈值的情况,可以调整缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件为:缓存文件的大小小于或等于第二字节,且第二字节随着总体空间使用率的增大而减小。
可选地,还有一些可能的实现方式中,还可以根据总体空间使用率,将动态SLC容量的混合式SSD划分为更多个阶段,并在每个阶段分别对缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件进行调整。例如,可以按照上述前述实施例中所述的方式先将动态SLC容量的混合式SSD划分为空闲阶段、中度阶段和重度阶段,其中,中度阶段可以被进一步划分为多个子阶段,如:中度阶段可以按照总体空间使用率的大小等间距或非等间距划分为S(S为大于1的整数)个子阶段,每个子阶段可以按照不同的方式对缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件进行调整,使缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件随着总体空间使用率的增大而越来越严格,如:第二次数随着总体空间使用率的增大呈线性增大或非线性增大,或者第二字节随着总体空间使用率的增大呈线性减小或非线性减小。
例如,当总体空间使用率为第三总体空间使用率时,调整后的条件包括:缓存文件在动态SLC容量的混合式SSD所在的电子设备的内存中文件操作命中的次数大于或等于第三值,和/或,缓存文件的大小小于或等于第四值;当总体空间使用率为第四总体空间使用率时,调整后的条件包括:缓存文件在动态SLC容量的混合式SSD所在的电子设备的内存中文件操作命中的次数大于或等于第五值,和/或,缓存文件的大小小于或等于第六值;第四总体空间使用率大于第三总体空间使用率时,第五值大于第三值,第六值小于第四值。
需要说明的是,在本申请实施例中,对于前述实施例中所述的缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件连续变化的情况,第三总体空间使用率和第四总体空间使用率可以是同一个阶段中动态SLC容量的混合式SSD的总体空间使用 率。或者,对于前述实施例中所述的缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件非连续变化的情况,第三总体空间使用率和第四总体空间使用率可以是不同阶段中动态SLC容量的混合式SSD的总体空间使用率。其中,阶段的划分可以参考前述实施例中所述。
本申请实施例提供的该存储方法中,通过对缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件进行动态调整,可以减少了无效缓存文件的缓存次数,减少了对动态SLC容量的混合式SSD的写入,优化了动态SLC容量的混合式SSD的IO性能。
示例性地,以图6所示的电子设备的存储设备的组成为例,当内存601的内存缓存占满时,后续的网络文件请求可能会导致新的网络文件的缓存操作,此时需要缓存系统按照剔除策略(或称为缓存管理策略)剔除内存缓存中的缓存文件,缓存系统可以按照本申请实施例提供的存储方法中动态调整后的缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件,判断从内存缓存中剔除的缓存文件是否可以被缓存在动态SLC容量的混合式SSD 602的闪存缓存中。当从内存缓存中剔除的缓存文件(如第二文件)符合存入动态SLC容量的混合式SSD的闪存缓存的条件时,可以将从内存缓存中剔除的缓存文件存入闪存缓存中;当从内存缓存中剔除的缓存文件不符合存入动态SLC容量的混合式SSD的闪存缓存的条件时,可以删除或拒绝将从内存缓存中剔除的缓存文件存入闪存缓存中。
示例性地,缓存系统中可以包括一个缓存文件筛选模块,该缓存文件筛选模块可以用于实现上述根据总体空间使用率,对缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件进行动态调整的功能,以及按照缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件对缓存文件进行筛选的功能。
可选地,本申请实施例中,缓存系统中可以提供一个管理缓存空间的接口,该接口可以用于接入不同的缓存管理算法,缓存管理算法可以用于对内存缓存和闪存缓存进行管理,本申请对内存缓存和闪存缓存的缓存管理策略并不限制。
一些实施例中,上述电子设备的缓存系统可以同时将LFU策略和基于文件大小的管理策略作为闪存缓存的文件管理策略,前述关于LFU策略的实施例和关于基于文件大小的管理策略的实施例也可以为和的关系,也即,缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件可以包括:缓存文件在内存中文件操作命中的次数和缓存文件的大小,本申请实施例提供的方法可以同时对缓存文件存入动态SLC容量的混合式SSD的闪存缓存的条件中缓存文件在内存中文件操作命中的次数和缓存文件的大小进行调整,调整方式如前述实施例中所述。
需要说明的是,以上实施例中均以动态SLC容量的混合式SSD为例,对本申请实施例提供的存储方法进行了说明。在其他一些可能的实施例中,本申请实施例提供的存储方法也可以适用于其他可以采用混合高速介质和低速介质的存储设备,如:存储设备的存储空间可以包括:多层单元区域、动态SLC区域、以及静态SLC区域。本申请对存储设备的具体类型并不作限制。
可选地,前述图7所示的实施例可以作为一个单独的实施例实现,也可以和图3所示的实施例作为一个整体的实施例实现,在此不作限制。
应当理解,以上各实施例中所述仅为对本申请实施例提供的存储方法的示例性说明。在其他一些可能的实现方式中,以上所述的各实施例也可以删减或增加某些执行步骤,或者以上实施例中所述的部分步骤的顺序也可以进行调整,本申请对此均不作限制。
对应于前述实施例中所述的存储方法,本申请实施例提供一种存储装置,该装置可以应用于上述电子设备,用于实现前述实施例所述的存储方法。该装置的功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与上述存储方法的步骤相对应的模块或单元。例如,图8为本申请实施例提供的存储装置的结构示意图。如图8所示,该装置可以包括:获取单元801、处理单元802等。获取单元801和处理单元802可以配合实现如前述实施例所述的存储方法。
如:获取单元801,可以用于获取单元801,可以用于获取存储设备的总体空间使用率;存储设备包括工作在多层单元区域、动态单层单元区域、以及静态单层单元区域;总体空间使用率是根据存储设备的存储空间的大小、以及存储设备的存储空间中被使用区域的大小所确定的。处理单元802,可以用于根据总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整;最大可用缓存空间是向存储设备中存储缓存数据时,允许缓存数据占用的最大存储空间。
当总体空间使用率为第一总体空间使用率时,动态单层单元区域的大小为第四容量,调整后的最大可用缓存空间的大小为第一值;当总体空间使用率为第二总体空间使用率时,动态单层单元区域的大小为第五容量,调整后的最大可用缓存空间的大小为第二值;第二总体空间使用率大于第一总体空间使用率,第五容量小于第四容量,第二值小于第一值。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,最大可用缓存空间的大小等于第一容量,第一容量小于或等于存储设备的最大单层单元容量、且大于存储设备的静态单层单元区域的容量;最大单层单元容量是存储设备的动态单层单元区域最大时动态单层单元区域和静态单层单元区域的容量之和。
当总体空间使用率大于第一阈值、且小于第二阈值时,最大可用缓存空间的大小随着总体空间使用率的增大而减小;第二阈值大于第一阈值。
当总体空间使用率大于或等于第二阈值时,最大可用缓存空间的大小等于第二容量,第二容量小于或等于第三容量;第三容量为存储设备的静态单层单元区域的容量,或者,存储设备的剩余可用存储空间的容量,又或者存储设备的静态单层单元区域的容量和剩余可用存储空间的容量中较小值;存储设备的剩余可用存储空间是指存储设备的存储除去常规数据所占用的空间后剩余的空间,常规数据包括存储设备所在的电子设备的本地用户产生的数据。
一种可能的示例中,第一阈值等于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值等于存储设备的单层单元容量最小时对应的最小总体空间使用率。
另一种可能的示例中,第一阈值小于或大于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值小于或大于存储设备的单层单元容量最小时对应的最小总体空间使用率。
一种可能的实现方式中,处理单元802,具体用于当总体空间使用率大于第一阈值、且小于第二阈值时,总体空间使用率变化第三阈值时,根据总体空间使用率,对存储设备的最大可用缓存空间的大小进行调整。
一种可能的实现方式中,处理单元802还用于,接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;将第二文件缓存到存储设备的缓存空间中;存储设备的缓存空间中存储的缓存数据所占用的存储空间不超过最大可用缓存空间。
可选地,处理单元802还用于,当内存的缓存空间中缓存了第一文件时,从内存的缓存空间中读取第一文件,并返回给第一应用程序;当存储设备的缓存空间中缓存了第一文件时,从存储设备的缓存空间中读取第一文件,并返回给第一应用程序。
可选地,处理单元802还用于,根据总体空间使用率,对缓存文件存入存储设备的条件进行动态调整。
当总体空间使用率为第三总体空间使用率时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三值,和/或,缓存文件的大小小于或等于第四值;当总体空间使用率为第四总体空间使用率时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第五值,和/或,缓存文件的大小小于或等于第六值;第四总体空间使用率大于第三总体空间使用率,第五值大于第三值,第六值小于第四值。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第一次数,和/或,缓存文件的大小小于或等于第一字节。
当总体空间使用率大于第一阈值、且小于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第二次数,和/或,缓存文件的大小小于或等于第二字节;第二阈值大于第一阈值;第二次数大于第一次数,第二字节小于第一字节。
当总体空间使用率大于或等于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三次数,和/或,缓存文件的大小小于或等于第三字节;第三次数大于第二次数,第三字节小于第二字节。
可选地,第二次数随着总体空间使用率的增大而增大,和/或,第二字节随着总体空间使用率的增加而减小。
一种可能的实现方式中,处理单元802还用于,接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;当第二文件符合调整后的条件时,将第二文件缓存到存储设备的缓存空间中。
类似地,获取单元801和处理单元802可以配合实现如前述实施例所述的存储方 法的全部步骤对应的功能,在此不再一一赘述。
对应于前述实施例中所述的存储方法,本申请实施例还提供一种存储装置。图9为本申请实施例提供的存储装置的另一结构示意图。如图9所示,该装置可以包括:获取单元901、处理单元902等。
获取单元901,可以用于获取存储设备的总体空间使用率;存储设备包括工作在多层单元区域、动态单层单元区域、以及静态单层单元区域;总体空间使用率是根据存储设备的存储空间的大小、以及存储设备的存储空间中被使用区域的大小所确定的。
处理单元902,可以用于根据总体空间使用率,对缓存文件存入存储设备的条件进行动态调整。
当总体空间使用率为第三总体空间使用率时,动态单层单元区域的大小为第四容量,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三值,和/或,缓存文件的大小小于或等于第四值;当总体空间使用率为第四总体空间使用率时,动态单层单元区域的大小为第五容量,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第五值,和/或,缓存文件的大小小于或等于第六值;第四总体空间使用率大于第三总体空间使用率,第五容量小于第四容量,第五值大于第三值,第六值小于第四值。
一种可能的实现方式中,当总体空间使用率小于或等于第一阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第一次数,和/或,缓存文件的大小小于或等于第一字节。当总体空间使用率大于第一阈值、且小于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第二次数,和/或,缓存文件的大小小于或等于第二字节;第二阈值大于第一阈值;第二次数大于第一次数,第二字节小于第一字节。当总体空间使用率大于或等于第二阈值时,调整后的条件包括:缓存文件在存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三次数,和/或,缓存文件的大小小于或等于第三字节;第三次数大于第二次数,第三字节小于第二字节。
一种可能的示例中,第一阈值等于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值等于存储设备的单层单元容量最小时对应的最小总体空间使用率。
另一种可能的示例中,第一阈值小于或大于存储设备的单层单元容量最大时对应的最大总体空间使用率;第二阈值小于或大于存储设备的单层单元容量最小时对应的最小总体空间使用率。
可选地,第二次数随着总体空间使用率的增大而增大,和/或,第二字节随着总体空间使用率的增加而减小。
一种可能的实现方式中,处理单元902还用于,接收第一应用程序提出的文件请求,文件请求用于请求第一文件;第一应用程序为存储设备所在的电子设备的内存中的应用程序;当内存的缓存空间和存储设备的缓存空间均没有缓存第一文件时,从服务器获取第一文件,并缓存在内存的缓存空间中;当内存的缓存空间占满时,从内存的缓存空间中剔除第二文件;当第二文件符合调整后的条件时,将第二文件缓存到存储设备的缓存空间中。
可选地,处理单元902还用于,当内存的缓存空间中缓存了第一文件时,从内存的缓存空间中读取第一文件,并返回给第一应用程序;当存储设备的缓存空间中缓存了第一文件时,从存储设备的缓存空间中读取第一文件,并返回给第一应用程序。
应理解以上装置中模块(或称为单元)的划分仅仅是一种逻辑功能的划分,实际实现时可以全部或部分集成到一个物理实体上,也可以物理上分开。且装置中的单元可以全部以软件通过处理元件调用的形式实现;也可以全部以硬件的形式实现;还可以部分单元以软件通过处理元件调用的形式实现,部分单元以硬件的形式实现。
例如,各个单元可以为单独设立的处理元件,也可以集成在装置的某一个芯片中实现,此外,也可以以程序的形式存储于存储器中,由装置的某一个处理元件调用并执行该单元的功能。此外这些单元全部或部分可以集成在一起,也可以独立实现。这里所述的处理元件又可以称为处理器,可以是一种具有信号的处理能力的集成电路。在实现过程中,上述方法的各步骤或以上各个单元可以通过处理器元件中的硬件的集成逻辑电路实现或者以软件通过处理元件调用的形式实现。
在一个例子中,以上装置中的单元可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个专用集成电路(application specific integrated circuit,ASIC),或,一个或多个数字信号处理器(digital signal process,DSP),或,一个或者多个现场可编辑逻辑门阵列(field programmable gate array,FPGA),或这些集成电路形式中至少两种的组合。
再如,当装置中的单元可以通过处理元件调度程序的形式实现时,该处理元件可以是通用处理器,例如中央处理器(central processing unit,CPU)或其它可以调用程序的处理器。再如,这些单元可以集成在一起,以片上系统(system-on-a-chip,SOC)的形式实现。
在一种实现中,以上装置实现以上方法中各个对应步骤的单元可以通过处理元件调度程序的形式实现。例如,该装置可以包括处理元件和存储元件,处理元件调用存储元件存储的程序,以执行以上方法实施例所述的存储方法。存储元件可以为与处理元件处于同一芯片上的存储元件,即片内存储元件。
在另一种实现中,用于执行以上方法的程序可以在与处理元件处于不同芯片上的存储元件,即片外存储元件。此时,处理元件从片外存储元件调用或加载程序于片内存储元件上,以调用并执行以上方法实施例所述的存储方法。
本申请实施例还提供一种电子设备。该电子设备可以是上述电子设备。电子设备包括:处理器,用于存储处理器可执行指令的存储器;处理器被配置为执行所述指令时,使得电子设备实现如前述实施例所述的存储方法。该存储器可以位于该电子设备之内,也可以位于该电子设备之外。且该处理器包括一个或多个。
示例性地,该电子设备可以是终端设备、服务器或虚拟机(virtual machine,VM)等。终端设备可以是手机、平板电脑、桌面型、膝上型、手持计算机、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本,以及蜂窝电话、个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)\虚拟现实(virtual reality,VR)设备等设备,本申请实施例对电子设备的具体形态不作特殊限制。
在又一种实现中,该电子设备实现以上方法中各个步骤的单元可以是被配置成一个或多个处理元件,这里的处理元件可以为集成电路,例如:一个或多个ASIC,或,一个或多个DSP,或,一个或者多个FPGA,或者这些类集成电路的组合。这些集成电路可以集成在一起,构成芯片。
例如,本申请实施例还提供一种芯片,该芯片可以应用于上述电子设备。芯片包括一个或多个接口电路和一个或多个处理器;接口电路和处理器通过线路互联;处理器通过接口电路从电子设备的存储器接收并执行计算机指令,以实现如前述实施例所述的存储方法。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。
基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,如:程序。该软件产品存储在一个程序产品,如计算机可读存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
例如,本申请实施例还提供一种计算机可读存储介质,其上存储有计算机程序指令;当所述计算机程序指令被电子设备执行时,使得电子设备实现如实施例所述的存储方法。
又例如,本申请实施例还提供一种计算机程序产品,包括:计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器实现如前述实施例所述的存储方法。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (15)

  1. 一种存储方法,其特征在于,所述方法包括:
    获取存储设备的总体空间使用率;所述存储设备包括工作在多层单元区域、动态单层单元区域、以及静态单层单元区域;所述总体空间使用率是根据所述存储设备的存储空间的大小、以及所述存储设备的存储空间中被使用区域的大小所确定的;
    根据所述总体空间使用率,对所述存储设备的最大可用缓存空间的大小进行调整;所述最大可用缓存空间是向所述存储设备中存储缓存数据时,允许缓存数据占用的最大存储空间;
    当所述总体空间使用率为第一总体空间使用率时,所述动态单层单元区域的大小为第四容量,调整后的所述最大可用缓存空间的大小为第一值;当所述总体空间使用率为第二总体空间使用率时,所述动态单层单元区域的大小为第五容量,调整后的所述最大可用缓存空间的大小为第二值;所述第二总体空间使用率大于所述第一总体空间使用率,所述第五容量小于所述第四容量,所述第二值小于所述第一值。
  2. 根据权利要求1所述的方法,其特征在于,当所述总体空间使用率小于或等于第一阈值时,所述最大可用缓存空间的大小等于第一容量,所述第一容量小于或等于所述存储设备的最大单层单元容量、且大于所述存储设备的静态单层单元区域的容量;所述最大单层单元容量是所述存储设备的动态单层单元区域最大时动态单层单元区域和静态单层单元区域的容量之和;
    当所述总体空间使用率大于所述第一阈值、且小于第二阈值时,所述最大可用缓存空间的大小随着所述总体空间使用率的增大而减小;所述第二阈值大于所述第一阈值;
    当所述总体空间使用率大于或等于所述第二阈值时,所述最大可用缓存空间的大小等于第二容量,所述第二容量小于或等于第三容量;所述第三容量为所述存储设备的静态单层单元区域的容量,或者,所述存储设备的剩余可用存储空间的容量,又或者所述存储设备的静态单层单元区域的容量和剩余可用存储空间的容量中的较小值;所述存储设备的剩余可用存储空间是指所述存储设备的存储除去常规数据所占用的空间后剩余的空间,所述常规数据包括所述存储设备所在的电子设备的本地用户产生的数据。
  3. 根据权利要求2所述的方法,其特征在于,所述第一阈值等于所述存储设备的单层单元容量最大时对应的最大总体空间使用率;
    所述第二阈值等于所述存储设备的单层单元容量最小时对应的最小总体空间使用率。
  4. 根据权利要求2所述的方法,其特征在于,所述第一阈值小于或大于所述存储设备的单层单元容量最大时对应的最大总体空间使用率;
    所述第二阈值小于或大于所述存储设备的单层单元容量最小时对应的最小总体空间使用率。
  5. 根据权利要求2-4任一项所述的方法,其特征在于,所述根据所述总体空间使用率,对所述存储设备的最大可用缓存空间的大小进行调整,包括:
    当所述总体空间使用率大于所述第一阈值、且小于第二阈值时,所述总体空间使 用率变化第三阈值时,根据所述总体空间使用率,对所述存储设备的最大可用缓存空间的大小进行调整。
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述方法还包括:
    接收第一应用程序提出的文件请求,所述文件请求用于请求第一文件;所述第一应用程序为所述存储设备所在的电子设备的内存中的应用程序;
    当所述内存的缓存空间和所述存储设备的缓存空间均没有缓存所述第一文件时,从服务器获取所述第一文件,并缓存在所述内存的缓存空间中;
    当所述内存的缓存空间占满时,从所述内存的缓存空间中剔除第二文件;
    将所述第二文件缓存到所述存储设备的缓存空间中;所述存储设备的缓存空间中存储的缓存数据所占用的存储空间不超过所述最大可用缓存空间。
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:
    当所述内存的缓存空间中缓存了所述第一文件时,从所述内存的缓存空间中读取所述第一文件,并返回给所述第一应用程序;
    当所述存储设备的缓存空间中缓存了所述第一文件时,从所述存储设备的缓存空间中读取所述第一文件,并返回给所述第一应用程序。
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述方法还包括:
    根据所述总体空间使用率,对缓存文件存入所述存储设备的条件进行动态调整;
    当所述总体空间使用率为第三总体空间使用率时,调整后的所述条件包括:缓存文件在所述存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三值,和/或,缓存文件的大小小于或等于第四值;当所述总体空间使用率为第四总体空间使用率时,调整后的所述条件包括:缓存文件在所述存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第五值,和/或,缓存文件的大小小于或等于第六值;所述第四总体空间使用率大于所述第三总体空间使用率,所述第五值大于所述第三值,所述第六值小于所述第四值。
  9. 根据权利要求8所述的方法,其特征在于,当所述总体空间使用率小于或等于第一阈值时,调整后的所述条件包括:缓存文件在所述存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第一次数,和/或,缓存文件的大小小于或等于第一字节;
    当所述总体空间使用率大于所述第一阈值、且小于第二阈值时,调整后的所述条件包括:缓存文件在所述存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第二次数,和/或,缓存文件的大小小于或等于第二字节;所述第二阈值大于所述第一阈值;所述第二次数大于所述第一次数,所述第二字节小于所述第一字节;
    当所述总体空间使用率大于或等于所述第二阈值时,调整后的所述条件包括:缓存文件在所述存储设备所在的电子设备的内存中文件操作命中的次数大于或等于第三次数,和/或,缓存文件的大小小于或等于第三字节;所述第三次数大于所述第二次数,所述第三字节小于所述第二字节。
  10. 根据权利要求9所述的方法,其特征在于,所述第二次数随着所述总体空间使用率的增大而增大,和/或,所述第二字节随着所述总体空间使用率的增加而减小。
  11. 根据权利要求8-10任一项所述的方法,其特征在于,所述方法还包括:
    接收第一应用程序提出的文件请求,所述文件请求用于请求第一文件;所述第一应用程序为所述存储设备所在的电子设备的内存中的应用程序;
    当所述内存的缓存空间和所述存储设备的缓存空间均没有缓存所述第一文件时,从服务器获取所述第一文件,并缓存在所述内存的缓存空间中;
    当所述内存的缓存空间占满时,从所述内存的缓存空间中剔除第二文件;
    当所述第二文件符合调整后的所述条件时,将所述第二文件缓存到所述存储设备的缓存空间中。
  12. 一种存储装置,其特征在于,所述装置包括:
    获取单元,用于获取存储设备的总体空间使用率;所述存储设备包括工作在多层单元区域、动态单层单元区域、以及静态单层单元区域;所述总体空间使用率是根据所述存储设备的存储空间的大小、以及所述存储设备的存储空间中被使用区域的大小所确定的;
    处理单元,用于根据所述总体空间使用率,对所述存储设备的最大可用缓存空间的大小进行调整;所述最大可用缓存空间是向所述存储设备中存储缓存数据时,允许缓存数据占用的最大存储空间;
    当所述总体空间使用率为第一总体空间使用率时,所述动态单层单元区域的大小为第四容量,调整后的所述最大可用缓存空间的大小为第一值;当所述总体空间使用率为第二总体空间使用率时,所述动态单层单元区域的大小为第五容量,调整后的所述最大可用缓存空间的大小为第二值;所述第二总体空间使用率大于所述第一总体空间使用率,所述第五容量小于所述第四容量,所述第二值小于所述第一值。
  13. 一种电子设备,其特征在于,包括:处理器,用于存储所述处理器可执行指令的存储器;
    所述处理器被配置为执行所述指令时,使得所述电子设备实现如权利要求1-11任一项所述的方法。
  14. 一种计算机可读存储介质,其上存储有计算机程序指令;其特征在于,当所述计算机程序指令被电子设备执行时,使得电子设备实现如权利要求1-11任一项所述的方法。
  15. 一种计算机程序产品,包括计算机可读代码,或者承载有计算机可读代码的非易失性计算机可读存储介质,其特征在于,当所述计算机可读代码在电子设备中运行时,所述电子设备中的处理器实现如权利要求1-11任一项所述的方法。
PCT/CN2022/119444 2021-10-22 2022-09-16 存储方法、装置、设备及存储介质 WO2023065915A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111236363.1 2021-10-22
CN202111236363.1A CN116009763A (zh) 2021-10-22 2021-10-22 存储方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2023065915A1 true WO2023065915A1 (zh) 2023-04-27

Family

ID=86017935

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/119444 WO2023065915A1 (zh) 2021-10-22 2022-09-16 存储方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN116009763A (zh)
WO (1) WO2023065915A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117201403A (zh) * 2023-09-15 2023-12-08 南京华芯科晟技术有限公司 缓存控制方法、装置和设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105677483A (zh) * 2015-12-31 2016-06-15 Tcl集团股份有限公司 一种数据缓存的方法及装置
WO2017000673A1 (zh) * 2015-06-29 2017-01-05 深圳市中兴微电子技术有限公司 一种共享缓存分配方法、装置及计算机存储介质
US9811261B1 (en) * 2015-09-13 2017-11-07 Amazon Technologies, Inc. Dynamic buffer size
CN108664219A (zh) * 2018-05-07 2018-10-16 苏州恒成芯兴电子技术有限公司 数据存储装置与方法
US20190095109A1 (en) * 2017-09-28 2019-03-28 International Business Machines Corporation Data storage system performance management
CN111752489A (zh) * 2020-06-30 2020-10-09 重庆紫光华山智安科技有限公司 Kubernetes中PVC模块的扩容方法及相关装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017000673A1 (zh) * 2015-06-29 2017-01-05 深圳市中兴微电子技术有限公司 一种共享缓存分配方法、装置及计算机存储介质
US9811261B1 (en) * 2015-09-13 2017-11-07 Amazon Technologies, Inc. Dynamic buffer size
CN105677483A (zh) * 2015-12-31 2016-06-15 Tcl集团股份有限公司 一种数据缓存的方法及装置
US20190095109A1 (en) * 2017-09-28 2019-03-28 International Business Machines Corporation Data storage system performance management
CN108664219A (zh) * 2018-05-07 2018-10-16 苏州恒成芯兴电子技术有限公司 数据存储装置与方法
CN111752489A (zh) * 2020-06-30 2020-10-09 重庆紫光华山智安科技有限公司 Kubernetes中PVC模块的扩容方法及相关装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117201403A (zh) * 2023-09-15 2023-12-08 南京华芯科晟技术有限公司 缓存控制方法、装置和设备
CN117201403B (zh) * 2023-09-15 2024-03-22 南京华芯科晟技术有限公司 缓存控制方法、装置和设备

Also Published As

Publication number Publication date
CN116009763A (zh) 2023-04-25

Similar Documents

Publication Publication Date Title
US10042586B2 (en) Managing operational state data in memory module
US8694811B2 (en) Power management for digital devices
US10120794B2 (en) Storage device including buffer and main memories, and user device including the same
WO2021036848A1 (zh) 一种数据处理方法及装置
US7730236B2 (en) Cellular phone and portable storage device using the same
US8615624B2 (en) Methods, apparatuses, and computer program products for enhancing memory erase functionality
WO2023065915A1 (zh) 存储方法、装置、设备及存储介质
KR20110038625A (ko) 무선 기능성을 갖는 고체-상태 디스크
EP4239477A1 (en) Virtual memory management method and electronic device
JP6363191B2 (ja) データマスキングを介してメモリi/o電力を低減するためのシステムおよび方法
WO2021093626A1 (zh) 一种内存的管理方法及电子设备
WO2021238387A1 (zh) 一种执行应用的方法及装置
WO2023202429A1 (zh) 垃圾回收的方法及电子设备
US9223379B2 (en) Intelligent receive buffer management to optimize idle state residency
CN114153621A (zh) 系统进程调控方法、装置、电子设备及可读存储介质
WO2023065815A1 (zh) 文件系统部署及扩展方法、装置、设备及存储介质
US20160170877A1 (en) System and method for managing bandwidth and power consumption through data filtering
WO2023138282A1 (zh) 一种天线功率控制方法和电子设备
CN113485969B (zh) 一种存储碎片化方法及装置、终端及计算机存储介质
CN101276317A (zh) 数据传输方法、数据传输系统及终端
WO2021128104A1 (zh) 一种报文缓存方法、集成电路系统及存储介质
US10832132B2 (en) Data transmission method and calculation apparatus for neural network, electronic apparatus, computer-readable storage medium and computer program product
US8832346B2 (en) Data packing and unpacking engine
WO2023088090A1 (zh) 文件验证方法及相关设备
WO2023001208A1 (zh) 多文件同步方法及电子设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22882526

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2022882526

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022882526

Country of ref document: EP

Effective date: 20240321