Storage method, electronic device and medium

By adjusting the transfer rate in real time according to the changes in the storage pressure of the first memory, the data in the first memory is transferred to the second memory, which solves the problem of the inability to save memory to the maximum extent and reduce the use of external storage devices in the prior art. Lifespan issues achieve more effective storage management.

CN117707422BActive Publication Date: 2025-02-18HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310873187.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-14
Publication Date
2025-02-18
Estimated Expiration
2043-07-14

AI Technical Summary

Technical Problem

The prior art uses a preset fixed transfer rate to transfer data in the compressed page of memory to an external storage device, which cannot save memory to the maximum extent while reducing the impact on the service life of the external storage device.

Method used

By adjusting the transfer rate in real time according to the change in the storage pressure of the first memory, the data in the first memory is transferred to the second memory. The specific method is to determine the second transfer rate based on the change in the storage pressure of the first memory, and use the second transfer rate to transfer the data in the first memory to the second memory.

Benefits of technology

It is achieved while minimizing the impact on the service life of the second memory while saving the storage space of the first memory to the greatest extent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117707422B_ABST
    Figure CN117707422B_ABST
Patent Text Reader

Abstract

The present application relates to the field of terminal technology, and to a storage method, electronic device, and medium. The storage method includes dynamically adjusting the transfer rate required for the storage space of the current adjustment memory by obtaining the change of the storage pressure of the memory after adjusting the transfer rate. In this way, by adjusting the transfer rate in real time according to the change of the storage pressure of the memory, the storage space of the memory can be saved to the greatest extent while reducing the impact on the service life of the external storage device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a storage method, electronic device and medium. Background Art

[0002] When an electronic device starts an application, it will apply to the memory for memory space to store the application's related data, such as file pages and anonymous pages. Among them, the file page is a recyclable memory, and the data in the file page is backed up in the external storage device, so the data in the file page can be directly discarded to release the memory space represented by the file page, and when the data in the file page is needed, it can be retrieved from the external storage device again. Anonymous pages store data in the running process (such as intermediate results of logical operations). These data are likely to be accessed multiple times in a short period of time during the running process of the application, so these data cannot be directly discarded. However, the data that needs to be stored through anonymous pages is likely to increase during the running process of the application, and if anonymous pages are always divided in the memory to store these data, the storage burden of the memory will increase.

[0003] To this end, in the prior art solution, when the memory pressure is high, the data in the anonymous page is compressed and stored in the compressed page of the memory. During the compression process, if the memory pressure is high again, the data in the compressed page is transferred to an external storage device, such as a disk, a general flash memory, etc., based on a preset fixed transfer rate (the ratio of the amount of data transferred from the memory to the amount of data stored in the memory). When these data are needed, these data are read from the external storage device to the anonymous page of the memory. However, during the transfer process, the preset fixed transfer rate cannot save memory to the greatest extent, and a large amount of data in the anonymous page is transferred to the external storage device. When these data are needed, they need to be frequently read from the external storage device, which will affect the service life of the external storage device. Summary of the invention

[0004] In order to solve the problem that transferring data in compressed pages of memory to an external storage device at a preset fixed transfer rate cannot save memory to the greatest extent while reducing the impact on the service life of the external storage device, an embodiment of the present application provides a storage method, an electronic device and a medium.

[0005] A first aspect of an embodiment of the present application provides a storage method for an electronic device, the electronic device comprising a first memory and a second memory, the storage method comprising: transferring first data in the first memory to the second memory using a first transfer rate; obtaining a change in storage pressure of the first memory after transferring the first data in the first memory to the second memory using the first transfer rate; determining a second transfer rate based on the change in storage pressure of the first memory, and transferring the second data in the first memory to the second memory using the second transfer rate; wherein determining the second transfer rate based on the change in storage pressure of the first memory comprises: setting the second transfer rate to be greater than the first transfer rate in response to the change in storage pressure of the first memory satisfying a first increase condition; setting the second transfer rate to be less than the first transfer rate in response to the change in storage pressure of the first memory satisfying a first decrease condition.

[0006] Based on the above solution, by adjusting the transfer rate in real time according to the change of the storage pressure of the first memory, the storage space of the first memory can be saved to the greatest extent while reducing the impact on the service life of the second memory.

[0007] It is understood that the first memory may be a memory, and the second memory may be a disk and / or a general flash memory. Using the first transfer rate to transfer the first data in the first memory to the second memory may mean: using the first transfer rate to transfer the data in the compressed page of the memory to the general flash memory.

[0008] In some optional instances, if after adjusting the storage space of the first memory with the first transfer rate L1, that is, after transferring the first data in the first memory to the second memory, the storage pressure of the first memory shows an increasing trend, a second transfer rate L2 greater than the first transfer rate L1 can be set as the transfer rate for currently adjusting the storage space of the first memory. If after adjusting the storage space of the first memory with the first transfer rate L1, that is, after transferring the first data in the first memory to the second memory, the storage pressure of the first memory shows a decreasing trend, a second transfer rate L2 less than the first transfer rate L1 can be set as the transfer rate for currently adjusting the storage space of the first memory. If after adjusting the storage space of the first memory with the first transfer rate L1, that is, after transferring the first data in the first memory to the second memory, the storage pressure of the first memory shows a constant trend, the first transfer rate L1 can still be used as the transfer rate for currently adjusting the storage space of the first memory.

[0009] In some optional instances, the first transfer rate described above is also referred to as the initial transfer rate hereinafter. First memories of different specifications may have different initial transfer rates, for example, the initial transfer rate of the 8G first memory is 37%, the initial transfer rate of the 12G first memory is 30%, and the initial transfer rate of the 16G first memory is 25%. The first transfer rate may be the transfer rate used in the process of adjusting the storage space of the first memory in the previous round, which may be the transfer rate obtained by adjusting the initial transfer rates of first memories of different specifications multiple times, or the initial transfer rates of first memories of different specifications.

[0010] In a possible implementation of the first aspect above, at a first moment, first data in a first memory is transferred to a second memory using a first transfer rate, and at a second moment, a change in storage pressure of the first memory after the first data in the first memory is transferred to the second memory using the first transfer rate is obtained; and the change in storage pressure of the first memory is determined in the following manner: a first time period between the first moment and the second moment is divided into a plurality of sub-time periods; a first storage pressure value of the first memory in a first sub-time period among the plurality of sub-time periods and a second storage pressure value of the first memory in a second sub-time period are calculated, wherein the first sub-time period is closer to the first moment than the second sub-time period; and the storage pressure change of the first memory is represented by the size and positive and negative conditions of the first storage pressure value and the second storage pressure value.

[0011] It can be understood that both the first moment and the second moment can be historical moments equivalent to the current moment, and the first time period between the first moment and the second moment is also referred to as a historical time period hereinafter, which can include multiple historical moments.

[0012] In some optional examples, the first storage pressure value may be obtained based on multiple storage pressure evaluation values ​​corresponding to multiple historical moments in the first sub-time period. The time lengths between two adjacent historical moments in the first sub-time period may not be equal. By obtaining storage pressure evaluation values ​​corresponding to random historical moments, the randomness of determining the storage pressure value of the first storage can be improved, thereby improving the accuracy of determining the storage pressure value of the first storage.

[0013] In some optional examples, the first storage pressure value may be obtained based on a plurality of storage pressure evaluation values ​​corresponding to a plurality of historical moments in the first sub-time period. The time lengths between two adjacent historical moments in the first sub-time period may be equal. By obtaining storage pressure evaluation values ​​corresponding to historical moments based on preset intervals, the regularity of determining the storage pressure value of the first storage may be improved, thereby improving the accuracy of determining the storage pressure value of the first storage.

[0014] In some optional instances, the storage pressure change of the first storage device may be represented by the size and the positive or negative condition of the first storage pressure value and the second storage pressure value: the storage pressure change of the first storage device may be represented by the difference between the first storage pressure value and the second storage pressure value and the positive or negative condition of the second storage pressure value.

[0015] In a possible implementation of the first aspect above, the first increase condition includes: a difference between the first stored pressure value and the second stored pressure value is greater than a preset change amplitude threshold, and the second stored pressure value is a positive number.

[0016] In a possible implementation of the first aspect above, the first reduction condition includes: a difference between the first stored pressure value and the second stored pressure value is greater than a preset change amplitude threshold, and the second stored pressure value is a negative number.

[0017] In a possible implementation of the first aspect, the first storage pressure value is determined by using the following formula:

[0018]

[0019] Among them, Eswap pressure_t Indicates the first stored pressure value, Pressure window represents the storage pressure evaluation value of the first storage device in the first sub-time period, Time window Indicates that the time corresponding to the first sub-time period is long.

[0020] For example, the storage pressure evaluation value corresponding to the first storage device at 15 seconds in the first sub-time period is 30, the storage pressure evaluation value corresponding to 18 seconds is 50, and the storage pressure evaluation value corresponding to 21 seconds is 60. The first storage pressure value corresponding to the first storage device in the first sub-time period is:

[0021]

[0022] In a possible implementation of the first aspect, a storage pressure evaluation value of the first storage device corresponding to the first sub-time period is determined by using the following formula:

[0023]

[0024] Among them, Pressure represents the storage pressure evaluation value of the first storage at a historical moment, and Eswap total Indicates the total storage pressure of the first storage in the first sub-time period, Eswap weight Represents the weighted total item of storage pressure corresponding to the first storage in the first sub-time period.

[0025] In a possible implementation of the first aspect above, the total storage pressure item and the weighted total storage pressure item are both determined based on the system native pressure value of the electronic device, the number of transfer conflicts, the number of transfer errors, the available storage space of the first memory and the used storage space of the second memory in the first sub-time period, wherein the system native pressure value of the electronic device is recorded internally by the electronic device system, the transfer conflict refers to that the previous process of transferring data from the first memory to the second memory has not been completed, and the next process of transferring data from the first memory to the second memory is already in progress, and the transfer error refers to the failure to transfer data from the first memory to the second memory.

[0026] In a possible implementation of the first aspect, the method for determining the second transfer rate includes: determining the second transfer rate based on the first transfer rate and a storage pressure value corresponding to the first storage at a current moment.

[0027] In a possible implementation of the first aspect, the second transfer rate is determined by using the following formula:

[0028]

[0029] Among them, EswapRatio current Indicates the second swap ratio, EswapRatio org Indicates the first transfer rate, Eswap pressure Indicates the storage pressure value of the first storage at the current moment.

[0030] In some optional examples, after the first data in the first memory is transferred to the second memory using the first transfer rate, if the change range of the storage pressure of the first memory is greater than a preset change range threshold, the determined second transfer rate is also referred to as the target transfer rate hereinafter. If the change range of the storage pressure of the first memory is less than or equal to the preset change range threshold, the determined second transfer rate is also referred to as the initial transfer rate hereinafter.

[0031] In a second aspect, the present application provides an electronic device, comprising: a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, for executing the storage method mentioned in the present application.

[0032] In a third aspect, the present application provides a readable storage medium having instructions stored thereon, which, when executed on an electronic device, enables the electronic device to execute the storage method mentioned in the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 According to some embodiments of the present application, a schematic diagram of a processing method for reducing memory pressure is shown;

[0034] Figure 2 According to some embodiments of the present application, a schematic flow chart of a storage method is shown;

[0035] Figure 3 According to some embodiments of the present application, a schematic flow chart of a method for determining a storage pressure value of a first storage device is shown;

[0036] Figure 4 According to some embodiments of the present application, a schematic diagram of a software structure of an electronic device is shown;

[0037] Figure 5 According to some embodiments of the present application, a schematic flow chart of a storage method is shown;

[0038] Figure 6 According to some embodiments of the present application, a schematic diagram of the hardware structure of an electronic device is shown. DETAILED DESCRIPTION

[0039] The illustrative embodiments of the present application include, but are not limited to, a storage method, an electronic device, and a medium.

[0040] The storage method mentioned in the embodiment of the present application can be applied to an electronic device, which can also be called a user equipment (UE), a mobile station (MS), a mobile terminal (Mobile Terminal), etc. Optionally, the electronic device can have the ability to communicate with one or more core networks via a radio access network (RAN), for example, the electronic device can be a mobile phone (or a "cellular" phone), or a computer with a mobile nature, etc.

[0041] As mentioned above, in the prior art solution, the memory pressure can be reduced by storing the data in the anonymous page in other storage devices, for example, Figure 1 It shows a processing method for reducing memory pressure in the mobile phone 100 by first compressing the data in the anonymous page into the compressed page of the memory and then transferring the data in the compressed page to the general flash memory.

[0042] like Figure 1As shown, the mobile phone 100 includes a processor 101, a memory 102, and a general flash memory 103. Part of the space of the memory 102 is divided into a block space 1021, a file page 1022, and anonymous pages 1023-1 to 1023-n1. As mentioned above, when the processor 101 runs the application, it will apply to the memory 102 for memory space for storing the relevant data of the application, such as the file page 1022 and the anonymous page 1023-1 to 1023-n1. If the memory pressure is large, for example, there are many relevant data stored and many anonymous pages 1023, some or all of the infrequently accessed data in the anonymous page 1023 will be compressed and stored in the block space 1021. However, since the block space is a part of the space divided from the memory, the infrequently accessed data stored in the block space is actually still stored in the memory. The infrequently accessed data that needs to be stored in the block space is likely to increase during the operation of the application. If these data are stored in the block space all the time, the storage burden of the memory will be increased again. Therefore, if the memory pressure is high again, for example, there is a large amount of compressed data, the data in the block space 1021 will be transferred to the universal flash memory 103 based on a preset fixed transfer rate.

[0043] However, during the transfer process, if the preset fixed transfer rate is set too high, a large amount of data in anonymous pages will be transferred to the external storage device. When these data are needed, they need to be frequently read from the external storage device, which will reduce the service life of the external storage device. If the preset fixed transfer rate is set too low, it is impossible to save memory to the greatest extent. It can be seen that the prior art solution transfers the data in the compressed pages of the memory to the external storage device by using the preset fixed transfer rate, which cannot save memory to the greatest extent while reducing the impact on the service life of the external storage device.

[0044] In order to solve the above problems, an embodiment of the present application provides a storage method, which dynamically adjusts the transfer rate required for the current adjustment of the storage space of the first memory according to the change of the storage pressure of the first memory after the last round of adjustment of the transfer rate. For example, the transfer rate of the storage space of the first memory in the last round of adjustment is L1. If the storage pressure of the first memory shows an increasing trend after the storage space of the first memory is adjusted with the transfer rate L1 in the last round, then L2 greater than L1 is set as the transfer rate of the storage space of the first memory in this round of adjustment. If the storage pressure of the first memory shows a decreasing trend after the storage space of the first memory is adjusted with the transfer rate L1 in the last round, then L3 less than L1 is set as the transfer rate of the storage space of the first memory in this round of adjustment. In this way, by adjusting the transfer rate in real time according to the change of the storage pressure of the first memory, the storage space of the first memory can be saved to the greatest extent while reducing the impact on the service life of the second memory.

[0045] It can be understood that the first storage may be a memory, and the second storage may be a disk and / or a general flash memory.

[0046] In some optional instances, the storage pressure of the first memory can be measured by at least one of the system native pressure value of the electronic device, the number of transfer conflicts, the number of transfer errors, the available storage space of the first memory, and the used storage space of the second memory in the previous round of transferring data from the first memory to the second memory at the transfer rate L1.

[0047] The system native pressure value of the electronic device is recorded inside the electronic device system and can be directly read. A transfer conflict may mean that the previous process of transferring data from the first memory to the second memory has not been completed, and the next process of transferring data from the first memory to the second memory is already in progress. A transfer error may mean that the transfer of data from the first memory to the second memory fails.

[0048] In some optional examples, the method of adjusting the transfer rate may be: if the storage pressure of the first storage presents an increasing trend after the storage space of the first storage is adjusted with the transfer rate L1 in the previous round, according to the transfer rate L1 of the storage space of the first storage in the previous round and the storage pressure of the storage space of the first storage from the beginning of the previous round of adjustment to the beginning of the current round of adjustment, L2 which is greater than L1 is set as the transfer rate of the storage space of the first storage in the current round of adjustment. If the storage pressure of the first storage presents a decreasing trend after the storage space of the first storage is adjusted with the transfer rate L1 in the previous round and the storage pressure of the storage space of the first storage from the beginning of the previous round of adjustment to the beginning of the current round of adjustment, L3 which is less than L1 is set as the transfer rate of the storage space of the first storage in the current round of adjustment.

[0049] The storage method mentioned in the embodiment of the present application is described in detail below. Figure 2 A schematic diagram of a storage method is shown, and the storage method can be applied to electronic devices. Figure 2 As shown, the storage method may include:

[0050] 201: Acquire a plurality of stored pressure values ​​in a first memory in an electronic device within a historical time period.

[0051] It can be understood that the historical time period may refer to the time period corresponding to the process of adjusting the storage space of the first memory in the last round.

[0052] In some embodiments, when the data storage capacity in the first memory is greater than the preset data storage capacity, the data in the first memory can be transferred to the second memory according to the transfer rate corresponding to the historical time period. The first memory can be a memory, and the second memory can be a disk and / or a general flash memory.

[0053] In some embodiments, the historical time period may include multiple historical moments, and the first memory may have a corresponding storage pressure evaluation value at each historical moment. According to the storage pressure evaluation values ​​corresponding to the first memory at multiple historical moments, multiple storage pressure values ​​of the first memory in the historical time period may be determined. It can be understood that the storage pressure value may be the storage pressure value corresponding to the first memory in a sub-time period, wherein the sub-time period may be a partial time period in the historical time period, and the sub-time period may include a partial historical moment in the historical time period, and the multiple sub-time periods corresponding to the multiple storage pressure values ​​may partially overlap, or the time periods may not overlap at all.

[0054] It can be understood that the storage pressure evaluation value of the first memory can be determined based on at least one of the system native pressure value of the electronic device corresponding to each historical moment, the number of transfer conflicts, the number of transfer errors, the available storage space of the first memory and the used storage space of the second memory. The system native pressure value of the electronic device is recorded inside the electronic device system and can be read directly. A transfer conflict may refer to that the previous process of transferring data from the first memory to the second memory has not been completed, and the next process of transferring data from the first memory to the second memory is already in progress. A transfer error may refer to a failure to transfer data from the first memory to the second memory. The specific method for determining the storage pressure evaluation value of the first memory will be described in detail in the following. Figure 3 Described in detail in.

[0055] The following introduces a method for determining multiple storage pressure values ​​of the first storage within a historical time period according to storage pressure evaluation values ​​corresponding to the first storage at multiple historical moments.

[0056] It can be understood that based on the preset window length (calc_window), multiple sub-time periods are determined from the historical time period based on the preset window length, and based on multiple storage pressure evaluation values ​​of the first storage in each sub-time period, the storage pressure value corresponding to the first storage in the sub-time period is determined. The preset window lengths corresponding to the multiple sub-time periods may be the same or different.

[0057] In some optional examples, the time lengths between two adjacent historical moments in the historical time period may not be equal. Table 1 below shows storage pressure evaluation values ​​corresponding to a first storage at different historical moments.

[0058] Table 1

[0059] Historical Moments 1 3 6 7 9 15 17 19 Storage pressure assessment value 30 50 40 20 10 30 50 60

[0060] It can be seen from Table 1 that the storage pressure evaluation value corresponding to the first storage at 1s is 30, the corresponding storage pressure evaluation value at 3s is 50, the corresponding storage pressure evaluation value at 6s is 40, the corresponding storage pressure evaluation value at 7s is 20, the corresponding storage pressure evaluation value at 9s is 10, the corresponding storage pressure evaluation value at 15s is 30, the corresponding storage pressure evaluation value at 17s is 50, and the corresponding storage pressure evaluation value at 19s is 60.

[0061] In the embodiment of the present application, by obtaining the storage pressure evaluation value corresponding to the random historical moment, the randomness of determining the storage pressure value of the first storage can be improved, and then the accuracy of determining the storage pressure value of the first storage can be improved.

[0062] For example, based on the multiple storage pressure evaluation values ​​shown in Table 1, the first sub-time period (3s-7s) can be determined from the historical time period based on the first preset window length (such as 4s), and the storage pressure value corresponding to the first memory in the first sub-time period (3s-7s) can be determined based on the storage pressure evaluation values ​​50, 40, and 20 in the first sub-time period. At the same time, the second sub-time period (15s-19s) can be determined from the historical time period based on the second preset window length (such as 4s), and the storage pressure value corresponding to the first memory in the second sub-time period (15s-19s) can be determined based on the storage pressure evaluation values ​​30, 50, and 60 in the second sub-time period (15s-19s). The second sub-time period (17s-19s) can also be determined from the historical time period based on the second preset window length (such as 2s), and the storage pressure value corresponding to the first memory in the second time period (17s-19s) can be determined based on the storage pressure evaluation values ​​750 and 60 in the second sub-time period (17s-19s).

[0063] In some other optional examples, the time lengths between two adjacent historical moments in the historical time period may be equal. Table 2 below shows storage pressure evaluation values ​​corresponding to a first storage at different historical moments.

[0064] Table 2

[0065] Historical Moments 0 3 6 9 12 15 18 21 Storage pressure assessment value 30 50 40 20 10 30 50 60

[0066] It can be seen from Table 2 that the storage pressure evaluation value corresponding to the first storage at 0s is 30, the storage pressure evaluation value corresponding to 3s is 50, the storage pressure evaluation value corresponding to 6s is 40, the storage pressure evaluation value corresponding to 9s is 20, the storage pressure evaluation value corresponding to 12s is 10, the storage pressure evaluation value corresponding to 15s is 30, the storage pressure evaluation value corresponding to 18s is 50, and the storage pressure evaluation value corresponding to 21s is 60.

[0067] In the embodiment of the present application, by obtaining storage pressure evaluation values ​​corresponding to historical moments based on preset intervals, the regularity of determining the storage pressure value of the first storage device can be improved, thereby improving the accuracy of determining the storage pressure value of the first storage device.

[0068] In some specific implementations, the storage pressure value corresponding to the first storage device in the sub-time period may be determined in the form shown in formula (1):

[0069]

[0070] Among them, Eswap pressure_t It can be expressed as determining the storage pressure value of the first storage at the historical time t, Pressure window It can represent the storage pressure evaluation value of the first storage device corresponding to the sub-time period corresponding to the historical time t, Time window It can represent the length of the sub-time period corresponding to the historical moment t.

[0071] For example, based on the example listed in Table 2 above, the specific formula for determining the storage pressure value corresponding to the first storage device in the first sub-time period (3s-7s) is shown in formula (2):

[0072]

[0073] The specific formula for determining the storage pressure value corresponding to the first storage device in the second time period (15s-21s) is shown in formula (3):

[0074]

[0075] 202: Determine a change range of storage pressure of the first storage within the historical time period according to multiple storage pressure values ​​of the first storage within the historical time period.

[0076] In some optional instances, the average value of multiple storage pressure values ​​of the first storage in the historical time period can be used as the variation range of the storage pressure of the first storage in the historical time period, or the average value of multiple storage pressure values ​​of the first storage in the historical time period except the maximum value and the minimum value can be used as the variation range of the storage pressure of the first storage in the historical time period. The variation range of the storage pressure of the first storage in the historical time period can also be determined based on multiple storage pressure values ​​corresponding to a preset number of sub-time periods closest to the current moment in the historical time period. For example, the difference between the storage pressure value of the first storage in the first sub-time period and the storage pressure value of the first storage in the second sub-time period can be determined as the variation range of the storage pressure of the first storage in the historical time period.

[0077] The above-mentioned method of determining the change range of the storage pressure of the first storage device within the historical time period is only a part of the embodiments listed in the embodiments of the present application, and may also include other methods of determining the change range of the storage pressure of the first storage device within the historical time period, which will not be repeated here.

[0078] 203: Determine whether the change range of the storage pressure of the first storage device in the historical time period is greater than a preset change range threshold. If the judgment result is yes, execute step 204; otherwise, execute step 206.

[0079] It can be understood that a preset change amplitude threshold can be set in advance, and the preset change amplitude threshold can be used as a basis for judging whether it is necessary to adjust the initial transfer rate corresponding to the first memory at the current moment. When the first memory adjusts the storage space of the first memory with the initial transfer rate corresponding to the first memory at the current moment in the historical time period, the change amplitude of the storage pressure of the first memory is greater than the preset change amplitude threshold, and the initial transfer rate corresponding to the first memory at the current moment can be adjusted, such as increasing the initial transfer rate corresponding to the first memory at the current moment, and reducing the initial transfer rate corresponding to the first memory at the current moment. When the first memory adjusts the storage space of the first memory with the initial transfer rate corresponding to the first memory at the current moment in the historical time period, the change amplitude of the storage pressure of the first memory is less than or equal to the preset change amplitude threshold, and the initial transfer rate corresponding to the first memory can be maintained.

[0080] 204: Based on the initial transfer rate corresponding to the first storage at the current moment and the storage pressure value of the first storage at the current moment, the initial transfer rate corresponding to the first storage is adjusted to obtain a target transfer rate corresponding to the first storage at the current moment.

[0081] It is understandable that first memories of different specifications may have different initial transfer rates, for example, the initial transfer rate of the 8G first memory is 37%, the initial transfer rate of the 12G first memory is 30%, and the initial transfer rate of the 16G first memory is 25%. The initial transfer rate corresponding to the first memory at the current moment may be the transfer rate used to adjust the storage space of the first memory in the historical time period, that is, the transfer rate used in the process of adjusting the storage space of the first memory in the last round, which may be the transfer rate obtained by adjusting the initial transfer rates of first memories of different specifications multiple times, or may be the initial transfer rates of first memories of different specifications.

[0082] In some optional instances, the initial transfer rate corresponding to the first memory at the current moment is L1. If the storage pressure of the first memory shows an increasing trend after the storage space of the first memory is adjusted with the transfer rate L1 in the historical time period, L2 which is greater than L1 can be set as the target transfer rate corresponding to the current moment, that is, the transfer rate for transferring data in the storage space of the first memory to the second memory in the predicted time period. Specifically, if the storage pressure value of the first memory corresponding to the sub-time period closest to the current moment is a positive number after the storage space of the first memory is adjusted with the transfer rate L1 in the historical time period, it can be determined that the storage pressure of the first memory shows an increasing trend.

[0083] In some other optional examples, the initial transfer rate corresponding to the first memory at the current moment is L1. If the storage pressure of the first memory shows a decreasing trend after the storage space of the first memory is adjusted with the transfer rate L1 in the historical time period, L2 which is less than L1 can be set as the target transfer rate corresponding to the current moment, that is, the transfer rate for transferring data in the storage space of the first memory to the second memory in the predicted time period. Specifically, if the storage pressure value of the first memory corresponding to the sub-time period closest to the current moment is negative after the storage space of the first memory is adjusted with the transfer rate L1 in the historical time period, it can be determined that the storage pressure of the first memory shows a decreasing trend.

[0084] In some specific implementations, the target transfer rate corresponding to the first memory at the current moment may be determined in the form shown in formula (4):

[0085]

[0086] Among them, EswapRatio current It can represent the target swap ratio, EswapRatio org It can represent the initial swap rate of the first storage at the current moment, Eswap pressure It can represent the storage pressure value of the first memory at the current moment.

[0087] 205: During the prediction time period, the storage space of the first storage is adjusted based on the target transfer rate corresponding to the first storage at the current moment.

[0088] It can be understood that after determining the target transfer rate corresponding to the first memory at the current moment, the target transfer rate of the first memory at the current moment can be used as the transfer rate for adjusting the storage space of the first memory within the predicted time period, and the data in the storage space of the first memory can be transferred to the second memory at the target transfer rate within the predicted time period, that is, the target transfer rate can be used as the transfer rate used in the process of adjusting the storage space of the first memory in this round, and can also be used as the initial transfer rate for the next round of adjusting the storage space of the first memory.

[0089] 206: During the prediction time period, the storage space of the first memory is adjusted based on the initial transfer rate corresponding to the first memory at the current moment.

[0090] In some optional instances, the initial transfer rate corresponding to the first memory at the current moment is L1. If after adjusting the storage space of the first memory with the transfer rate L1 within the historical time period, the storage pressure of the first memory shows no change trend, or a very small change trend, L1 can still be used as the target transfer rate corresponding to the current moment, that is, the transfer rate for transferring data in the storage space of the first memory to the second memory within the predicted time period.

[0091] The following takes a historical moment as an example to describe in detail the method for determining the storage pressure evaluation value of the first storage device. Figure 3 A schematic flow chart of a method for determining a storage pressure value of a first storage device is shown. Figure 3 As shown, the method for determining the storage pressure value of the first storage may include:

[0092] 301: Obtain the total storage pressure item and the weighted total storage pressure item corresponding to the first storage device at a historical moment.

[0093] It can be understood that, taking a historical moment as an example, the total storage pressure item and the weighted total storage pressure item corresponding to the first memory at the historical moment can be determined based on the system native pressure value of the electronic device, the number of transfer conflicts, the number of transfer errors, and at least one of the available storage space of the first memory and the used storage space of the second memory at the historical moment in the process of transferring data in the first memory to the second memory from the previous historical moment to the historical moment.

[0094] The system native pressure value of the electronic device is recorded inside the electronic device system and can be directly read. A transfer conflict may mean that the previous process of transferring data from the first memory to the second memory has not been completed, and the next process of transferring data from the first memory to the second memory is already in progress. A transfer error may mean that the transfer of data from the first memory to the second memory fails.

[0095] In some optional instances, the total storage pressure item and the weighted total storage pressure item corresponding to the first memory at the historical moment can be determined based on the number of transfer conflicts, the number of transfer errors, the available storage space of the first memory and the used storage space of the second memory corresponding to the historical moment.

[0096] In some specific examples, the total storage pressure item corresponding to the first storage device at a historical moment may be determined in the form shown in formula (5):

[0097] Eswap total =memory psi +reclaimin infight +reclaimin ierror +UFS used -MemDiff formula(5)

[0098] Among them, Esawp total Can represent the total storage pressure, memory psi It can represent the system native pressure value of electronic equipment, reclaimin inf ight Can indicate the number of reclaim conflicts, ierror Can indicate the number of transfer errors, UFS used It can represent the used storage space of the second memory, and MemDiff can represent the difference between the available memory space of the first memory and the preset transfer watermark, wherein the preset transfer watermark is used to determine whether the data in the first memory needs to be transferred to the second memory. When the available memory space of the first memory is greater than or equal to the preset transfer watermark, the data in the first memory can be transferred to the second memory. When the available memory space of the first memory is less than the preset transfer watermark, the data in the first memory may not be transferred to the second memory.

[0099] In some specific examples, the difference between the available memory space of the first memory and the preset transfer watermark may be determined in the form shown in formula (6):

[0100]

[0101] Among them, MemDiff can represent the difference between the available memory space of the first memory and the preset swap watermark, MemAvailable can represent the available memory space of the first memory, and MemEswap can represent the preset swap watermark.

[0102] In some specific examples, the weighted total item of storage pressure corresponding to the first storage at a historical moment may be determined in the form shown in formula (7):

[0103]

[0104] Among them, Esawp weight It can represent the weighted total item of storage pressure, memory psi It can represent the system native pressure value of electronic equipment, reclaimin inf ight Can indicate the number of reclaim conflicts, ierror Can indicate the number of transfer errors, UFS used It can represent the used storage space of the second storage, MemDiff can represent the difference between the available memory space of the first storage and the preset transfer watermark, weight inf ight It can represent the weight corresponding to the number of transfer conflicts, weight ierror It can represent the weight corresponding to the number of transfer errors, weight used It can represent the weight corresponding to the used storage space of the second memory, weight MemDiff The weight corresponding to the difference between the available memory space of the first memory and the preset transfer watermark can be represented, and each weight is in the range of (0,1].

[0105] 302: Determine a storage pressure evaluation value corresponding to the first storage at a historical moment according to the total storage pressure item and the weighted total storage pressure item corresponding to the first storage at a historical moment.

[0106] In some specific examples, the storage pressure evaluation value corresponding to the first storage at a historical moment may be determined in the form shown in formula (8):

[0107]

[0108] Among them, Pressure can represent the storage pressure evaluation value of the first storage at a historical moment, and Eswap total It can represent the total storage pressure item corresponding to the first storage at a historical moment, Eswap weight It can represent the weighted total item of storage pressure corresponding to the first storage at a historical moment.

[0109] In some optional instances, after obtaining the storage pressure evaluation value of the first memory at each historical moment, it can be recorded in a ring buffer (RingBuffer) for storage, that is, the multiple storage pressure evaluation values ​​shown in Table 1 and the multiple storage pressure evaluation values ​​shown in Table 2 can be stored in the ring buffer.

[0110] The following is an introduction to the software structure of electronic equipment. Figure 4 As shown, the electronic device 400 may include a kernel layer 401 , a framework layer 402 and an application layer 403 .

[0111] The kernel layer 401 may include a first transfer strategy initialization module 4011 , a transfer pressure perception module 4012 , a transfer strategy dynamic adjustment module 4013 , a transfer strategy execution module 4014 and a transfer strategy feedback module 4015 .

[0112] The first transfer strategy initialization module 4011 is used to obtain the initial transfer rate corresponding to the first storage at the current moment from the framework layer 402 .

[0113] The transfer pressure perception module 4012 is used to obtain at least one of the system native pressure value of the electronic device, the number of transfer conflicts that occurred, the number of transfer errors, the available storage space of the first memory and the used storage space of the second memory in the process of transferring the data in the first memory to the second memory at the initial transfer rate corresponding to the current moment in the previous round, and determine the storage pressure value corresponding to the first memory at the current moment. Among them, the system native pressure value of the electronic device can be recorded internally by the electronic device system and can be read directly. A transfer conflict may refer to that the previous process of transferring data from the first memory to the second memory has not ended, and the next process of transferring data from the first memory to the second memory is already in progress. A transfer error may refer to a failure to transfer data from the first memory to the second memory.

[0114] The transfer strategy dynamic adjustment module 4013 is used to adjust the initial transfer rate corresponding to the first storage device based on the initial transfer rate corresponding to the first storage device at the current moment and the storage pressure value of the first storage device at the current moment to obtain the target transfer rate corresponding to the first storage device at the current moment.

[0115] The transfer strategy execution module 4014 is used to adjust the storage space of the first memory based on the target transfer rate corresponding to the first memory at the current moment.

[0116] The transfer strategy feedback module 4015 is used to feed back the target transfer rate corresponding to the first storage at the current moment to the framework layer 402 .

[0117] The framework layer 402 may include a second transfer strategy initialization module 4021 and a transfer strategy dynamic decision module 4022 .

[0118] The second transfer strategy initialization module 4021 is used to read the initial transfer rate corresponding to the first memory at the current moment, and send it to the first transfer strategy initialization module 4011 in the kernel layer 401 .

[0119] The transfer strategy dynamic decision module 4022 is used to obtain the target transfer rate corresponding to the first memory at the current moment sent by the transfer strategy feedback module 4015 in the kernel layer 401.

[0120] The application layer 403 may include multiple applications, such as a foreground application 4031 , a background application 4032 , and a background application 4033 .

[0121] The storage method provided by the embodiment of the present application is introduced below based on the software structure of the electronic device. Figure 5 A schematic diagram of a storage method is shown, and the storage method can be applied to the framework layer in an electronic device. Figure 4 and 5 As shown, the storage method may include:

[0122] 501: The first transfer strategy initialization module sends the initial transfer rate corresponding to the first storage device at the current moment to the transfer strategy dynamic adjustment module.

[0123] It can be understood that the first transfer policy initialization module 4011 in the kernel layer 401 can obtain the initial transfer rate corresponding to the first memory at the current moment from the second transfer policy initialization module 4021 in the framework layer 402. The initial transfer rate corresponding to the first memory at the current moment may be the transfer rate used to adjust the storage space of the first memory in the historical time period, that is, the transfer rate used in the process of adjusting the storage space of the first memory in the previous round, which may be the transfer rate obtained by adjusting the initial transfer rates of first memories of different specifications multiple times.

[0124] 502: The storage pressure sensing module determines a storage pressure value corresponding to the first storage at the current moment.

[0125] It can be understood that the transfer pressure perception module 4012 in the kernel layer 401 is used to obtain the system native pressure value of the electronic device, the number of transfer conflicts that occurred, the number of transfer errors, the available storage space of the first memory and the used storage space of the second memory in the process of transferring the data in the first memory to the second memory at the initial transfer rate corresponding to the current moment in the previous round, and determine the storage pressure value corresponding to the first memory at the current moment. Among them, the system native pressure value of the electronic device can be recorded by the electronic device system and can be read directly. A transfer conflict may refer to the previous process of transferring data from the first memory to the second memory not being completed, and the next process of transferring data from the first memory to the second memory is already in progress. A transfer error may refer to a failure to transfer data from the first memory to the second memory.

[0126] 503: The transfer pressure sensing module sends the storage pressure value corresponding to the first storage device at the current moment to the transfer strategy dynamic adjustment module.

[0127] It can be understood that the transfer pressure perception module 4012 in the kernel layer 401 can send the storage pressure value corresponding to the first memory at the current moment to the transfer strategy dynamic adjustment module 4013 in the kernel layer 401.

[0128] 504: The transfer strategy dynamic adjustment module determines a target transfer rate corresponding to the first storage device at the current moment.

[0129] It can be understood that the transfer strategy dynamic adjustment module 4013 in the kernel layer 401 can adjust the initial transfer rate corresponding to the first memory based on the initial transfer rate corresponding to the first memory at the current moment and the storage pressure value of the first memory at the current moment, so as to obtain the target transfer rate corresponding to the first memory at the current moment.

[0130] 505: The transfer strategy dynamic adjustment module sends the target transfer rate to the transfer strategy execution module.

[0131] It can be understood that after determining the target transfer rate corresponding to the first memory at the current moment, the transfer policy dynamic adjustment module 4013 in the kernel layer 401 can send the target transfer rate to the transfer policy execution module 4014 in the kernel layer 401 .

[0132] 506: The transfer strategy execution module adjusts the storage space of the first memory based on the target transfer rate corresponding to the first memory at the current moment.

[0133] It can be understood that the transfer policy execution module 4014 in the kernel layer 401 can adjust the storage space of the first memory based on the target transfer rate corresponding to the first memory at the current moment within the predicted time period.

[0134] 507: The transfer strategy dynamic adjustment module sends the target transfer rate to the transfer strategy feedback module.

[0135] It can be understood that after determining the target transfer rate corresponding to the first memory at the current moment, the transfer strategy dynamic adjustment module 4013 in the kernel layer 401 can also send the target transfer rate to the transfer strategy feedback module 4015 in the kernel layer 401 .

[0136] 508: The transfer strategy feedback module sends the target transfer rate to the transfer strategy dynamic decision module.

[0137] It can be understood that after obtaining the target transfer rate corresponding to the first memory at the current moment, the transfer strategy feedback module 4015 in the kernel layer 401 can send the target transfer rate to the transfer strategy dynamic decision module 4022 in the framework layer 402, so that the transfer strategy dynamic decision module 4022 in the framework layer 402 updates the initial transfer rate corresponding to the first memory at the current moment in the second transfer strategy initialization module 4021 based on the target transfer rate.

[0138] The following is an introduction to the hardware structure of electronic equipment. Figure 6 As shown, the electronic device 600 may include a processor 610, an external memory interface 620, an internal memory 621, a universal serial bus (USB) interface 630, a charging management module 640, a power management module 641, a battery 642, an antenna 1, an antenna 2, a mobile communication module 650, a wireless communication module 660, an audio module 670, a speaker 670A, a receiver 670B, a microphone 670C, an earphone interface 670D, a sensor module 680, a button 690, a motor 691, an indicator 692, a camera 693, a display screen 694, and a subscriber identification module (SIM) card interface 695, etc. The sensor module 680 may include a pressure sensor 680A, a gyroscope sensor 680B, an air pressure sensor 680C, a magnetic sensor 680D, an acceleration sensor 680E, a distance sensor 680F, a proximity light sensor 680G, a fingerprint sensor 680H, a temperature sensor 680J, a touch sensor 680K, an ambient light sensor 680L, a bone conduction sensor 680M, etc.

[0139] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device 600 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0140] The processor 610 may include one or more processing units, for example, the processor 610 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0141] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0142] The processor 610 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 610 is a cache memory. The memory may store instructions or data that the processor 610 has just used or cyclically used. If the processor 610 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 610, and thus improves the efficiency of the system.

[0143] The external memory interface 620 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 600. The external memory card communicates with the processor 610 through the external memory interface 620 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0144] The internal memory 621 can be used to store computer executable program codes, which include instructions. The internal memory 621 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 600 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 621 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 610 executes various functional applications and data processing of the electronic device 600 by running instructions stored in the internal memory 621 and / or instructions stored in a memory provided in the processor.

[0145] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.

[0146] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one" do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0147] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the present application.

Claims

1. A storage method for an electronic device, characterized in that: The electronic device comprises a first memory and a second memory; And the method comprises: Transferring the first data in the first memory to the second memory using a first transfer rate; Acquire a change in storage pressure of the first memory after first data in the first memory is transferred to the second memory using a first transfer rate; Determine a second transfer rate based on a change in storage pressure of the first memory, and transfer the second data in the first memory to the second memory using the second transfer rate, wherein the storage pressure of the first memory is determined based on at least one of a system native pressure value of the electronic device, a number of transfer conflicts, a number of transfer errors, an available storage space of the first memory, and a used storage space of the second memory; The second transfer rate is determined based on the change of the storage pressure of the first storage device, including: In response to the change in the storage pressure of the first storage device satisfying a first increase condition, setting the second transfer rate to be greater than the first transfer rate; In response to a change in the storage pressure of the first storage device satisfying a first reduction condition, setting the second transfer rate to be less than the first transfer rate; The obtaining of a change in storage pressure of the first memory after the first data in the first memory is transferred to the second memory using a first transfer rate includes: At a first moment, first data in the first memory is transferred to the second memory using the first transfer rate, and after the first data in the first memory is transferred to the second memory using the first transfer rate at a second moment, a change in storage pressure of the first memory is determined; and The change of the storage pressure of the first storage device is determined by: Dividing a first time period between the first moment and the second moment into a plurality of sub-time periods; Calculating a first storage pressure value of the first storage device in a first sub-time period and a second storage pressure value of the first storage device in a second sub-time period among the multiple sub-time periods, wherein the first sub-time period is closer to the first moment than the second sub-time period; The change of the storage pressure of the first storage device is represented by the magnitude and the positive and negative status of the first storage pressure value and the second storage pressure value.

2. The method according to claim 1, characterized in that The first increase condition includes: a difference between the first stored pressure value and the second stored pressure value is greater than a preset change amplitude threshold, and the second stored pressure value is a positive number.

3. The method according to claim 1, characterized in that The first reduction condition includes: a difference between the first stored pressure value and the second stored pressure value is greater than a preset change amplitude threshold, and the second stored pressure value is a negative number.

4. The method according to claim 1, characterized in that: The first storage pressure value is determined by the following formula: Among them, Eswap pressure_t Indicates the first stored pressure value, Pressure window represents the storage pressure evaluation value of the first storage device in the first sub-time period, Time window Indicates that the time corresponding to the first sub-time period is long.

5. The method according to claim 4, characterized in that The storage pressure evaluation value corresponding to the first storage device in the first sub-time period is determined by using the following formula: Among them, Pressure represents the storage pressure evaluation value of the first storage at a historical moment, and Eswap total Indicates the total storage pressure of the first storage device in the first sub-time period, Eswap weight Represents the weighted total item of storage pressure corresponding to the first storage device in the first sub-time period.

6. The method according to claim 5, characterized in that The total storage pressure item and the weighted total storage pressure item are both determined based on a system native pressure value of the electronic device, a number of transfer conflicts, a number of transfer errors, an available storage space of the first memory, and a used storage space of the second memory in the first sub-time period, Among them, the system native pressure value of the electronic device is recorded inside the electronic device system, the transfer conflict refers to the previous process of transferring data from the first memory to the second memory has not been completed, and the next process of transferring data from the first memory to the second memory is already in progress, and the transfer error refers to the failure to transfer data from the first memory to the second memory.

7. The method according to claim 1, characterized in that The method for determining the second transfer rate includes: The second transfer rate is determined based on the first transfer rate and a storage pressure value corresponding to the first memory at a current moment.

8. The method according to claim 7, characterized in that The second transfer rate is determined by the following formula: Among them, EswapRatio current Indicates the second swap ratio, EswapRatio org Indicates the first transfer rate, Eswap pressure Indicates the storage pressure value of the first memory at the current moment.

9. An electronic device, characterized in that: include: A memory, used to store instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, used to execute the storage method described in any one of claims 1-8.

10. A readable storage medium, characterized in that: The readable storage medium stores instructions, and when the instructions are executed on an electronic device, the electronic device executes the storage method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Memory recycle method and device

    CN107220076A

  • Method for controlling memory recovery, electronic equipment and storage medium

    CN116166573A