Storage space management method, electronic device, and vehicle
By predicting the distribution of storage space data and proactively migrating valid data in storage devices, the problem of long processing times and congestion caused by centralized cleanup after storage pages are full is solved, thus achieving efficient management of storage space.
Patent Information
- Application Number
- CN202611290028.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-24
- Publication Date
- 2026-11-03
AI Technical Summary
In existing technologies, storage devices need to centrally clean up valid data and move it to new pages after the storage pages are full, which results in long processing times and can easily cause storage blockage.
By acquiring the time-series status data of the storage space and inputting it into a pre-trained storage space prediction model, the model predicts the storage space distribution in future time periods, proactively migrates the data in the target storage block to the currently active storage page, and reclaims the space of the target storage block.
It alleviates the storage space expansion problem caused by random writes, reduces the execution time of centralized page swapping operations, realizes distributed storage cleanup operations of storage devices, reduces the blocking probability of new storage write requests, improves the management efficiency of storage devices, and solves the storage blocking problem of storage devices in the prior art.
Smart Images

Figure CN123030129A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage space management technology, and in particular to a storage space management method, electronic device, and vehicle. Background Technology
[0002] Currently, the conventional way storage management works is as follows: when a random storage write request is made, the storage block entry is written to the storage space of the storage device. When new data is written to the storage block, the old data is not erased. Instead, the data is written to the new blank space and the old data is marked as invalid. When each page is full, the valid data in the page is moved to a new page and the old page is erased after the movement is completed. This paging process is time-consuming and can easily cause storage blockage. Summary of the Invention
[0003] This application provides a storage space management method, electronic device, and vehicle to solve the problems in related technologies, such as storage devices passively waiting for storage pages to be filled before centrally moving valid data to new storage pages, which is time-consuming and prone to causing storage blockage.
[0004] The first aspect of this application provides a storage space management method. The method is applied to a storage device, and the storage space includes multiple storage pages, each storage page including multiple storage blocks. The method includes the following steps: acquiring time-series status data of the storage space, wherein the time-series status data includes spatial distribution data and space usage data at the current time and within a target historical time period; inputting the time-series status data into a pre-trained storage space prediction model, the prediction model outputting predicted distribution data of the storage space within a future time period; determining a target storage block based on the predicted distribution data; moving the data in the target storage block to the currently active storage page of the storage space; and reclaiming the storage space corresponding to the target storage block.
[0005] Optionally, in one embodiment of this application, determining the target storage block based on predicted distribution data includes: determining a first offset and a second offset of the storage space and the storage block in a future time period based on the predicted distribution data; and determining the target storage block based on the first offset and the second offset of the storage block.
[0006] Optionally, in one embodiment of this application, the predicted distribution data includes storage page status data and storage block distribution data. The storage page status data includes the number and type flag of the storage page, and the storage block distribution data includes the number, relative position, and status flag of the storage block.
[0007] Optionally, in one embodiment of this application, determining the first offset of the storage space in a future time period based on predicted distribution data includes: determining the target active storage page in the future time period based on storage page state data; identifying the first tail address and the second tail address corresponding to the currently active storage page and the target active storage page; and determining the first offset based on the first tail address and the second tail address.
[0008] Optionally, in one embodiment of this application, determining the second offset of a storage block in a future time period based on predicted distribution data includes: obtaining the first relative position and the second relative position of the storage block at the current time and at all times in the future time period; and calculating the second offset based on the first relative position and the second relative position.
[0009] Optionally, in one embodiment of this application, determining the target storage block based on the first offset and the second offset of the storage block includes: calculating the ratio of the first offset and the second offset; if the ratio is greater than a preset threshold, then determining the corresponding storage block as the target storage block.
[0010] Optionally, in one embodiment of this application, the training process of the prediction model includes: acquiring a training set, which includes historical time-series state data and ground truth data; training the prediction model using the data in the training set; updating the model parameters using the prediction distribution data and ground truth data output by the prediction model during the training process, until training stops when a preset condition is met.
[0011] Optionally, in one embodiment of this application, after moving the data in the target storage block to the currently active storage page of the storage space, the method further includes: identifying the state of the currently active storage page; if the state is the target state, then moving the data in the target storage block to the target active storage page.
[0012] Optionally, in one embodiment of this application, the spatial distribution data has the same structure as the predicted distribution data, and the spatial usage data includes storage block write frequency data and storage block read / write characteristic data.
[0013] A second aspect of this application provides a storage space management device. The device is applied to a storage device, and the storage space includes multiple storage pages, each storage page including multiple storage blocks. The device includes: an acquisition module for acquiring time-series status data of the storage space, wherein the time-series status data includes spatial distribution data and space usage data within the current time period and a target historical time period; an output module for inputting the time-series status data into a pre-trained storage space prediction model, the prediction model outputting predicted distribution data of the storage space within a future time period; and a management module for determining a target storage block based on the predicted distribution data, moving the data in the target storage block to the currently active storage page of the storage space, and reclaiming the storage space corresponding to the target storage block.
[0014] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to perform the storage space management method as described in the above embodiments.
[0015] A fourth aspect of this application provides a vehicle including electronic devices as described in the above embodiments.
[0016] A fifth aspect of this application provides a computer-readable storage medium having a computer program or instructions stored thereon, which are executed by a processor to perform the storage space management method as described in the above embodiments.
[0017] A sixth aspect of this application provides a computer program product, including a computer program or instructions, which, when executed, implement the storage space management method as described in the above embodiments.
[0018] Therefore, this application has at least the following beneficial effects: This application's embodiments input the time-series status data of the storage space into a pre-trained storage space prediction model. The prediction model predicts the distribution data of the storage space in future time periods. Based on the predicted distribution data output by the prediction model, target storage blocks are selected, and valid data in the target storage blocks is actively migrated to the currently active storage pages. Simultaneously, the storage space originally occupied by the target storage blocks is released and reclaimed. By migrating data in storage blocks to be cleaned in advance and reclaiming idle local space, the storage cleanup operation is distributed, alleviating the storage space expansion problem caused by random writes, reducing the execution time of subsequent centralized page swapping operations, and reducing the probability of new storage write requests being blocked for a long time. Thus, it solves the technical problems in related technologies, such as storage devices passively waiting for storage pages to be full before centrally moving valid data to new storage pages, which is time-consuming and prone to storage blocking.
[0019] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0020] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a flowchart of a storage space management method provided according to an embodiment of this application; Figure 2 This is a schematic diagram of the structure of spatial distribution data provided according to an embodiment of this application; Figure 3 This is a schematic diagram of the structure of space usage data provided according to an embodiment of this application; Figure 4 This is a flowchart illustrating the implementation of the storage space management method provided in the embodiments of this application; Figure 5 This is a schematic diagram illustrating the training of the spatial prediction model provided according to an embodiment of this application; Figure 6 This is a schematic diagram of a system equipped with hardware for the storage space management method provided in the embodiments of this application; Figure 7 This is an example diagram of a storage space management device provided according to an embodiment of this application; Figure 8 This is a schematic diagram of the structure of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0021] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0022] The storage space management method, electronic device, and vehicle of this application are described below with reference to the accompanying drawings. Addressing the issues raised in the background art, where after each page is full, valid data is centrally cleaned up and moved to a new page, and the old page is erased after the transfer, this paging process is time-consuming and causes storage congestion. This application provides a storage space management method in which the distribution of storage space data can be predicted in real time, and local adjustments to the storage space can be proactively made. This solves the problems of storage devices passively waiting for storage pages to be full before centrally transferring valid data to new storage pages, which is time-consuming and prone to causing storage congestion.
[0023] Specifically, Figure 1 This is a flowchart illustrating the storage space management method provided in an embodiment of this application.
[0024] This storage space management method is applied to storage devices, where the storage space includes multiple storage pages, and each storage page includes multiple storage blocks.
[0025] The storage device in this application embodiment can be an in-vehicle non-volatile storage hardware, such as Flash; the storage space is the physical storage area within the storage device, which is divided into multiple levels: storage space → storage page (the smallest unit to be erased) → storage block (the basic data writing unit).
[0026] like Figure 1 As shown, the storage space management method includes the following steps: In step S10, the time-series status data of the storage space is obtained, wherein the time-series status data includes the spatial distribution data and space usage data of the current time and the target historical time period.
[0027] Among them, the time-series status data is the storage status sequence data collected continuously according to the time sequence; the spatial distribution data includes storage page (Fee page) status data and space usage data; the storage page status data includes storage page status data and storage block distribution data. The storage page status data includes the storage page number and type flag, and the storage block distribution data can also be called spatial layout data, including the storage block number, relative position and status flag; the space usage data includes storage block write frequency data and storage block read and write characteristic data.
[0028] Specifically, the structure of the spatial distribution data in the embodiments of this application is as follows: Figure 2 As shown, Figure 2 The Fee page status and storage block distribution data 203 in the text refers to spatial distribution data, which includes storage page status data 201 and storage block distribution data 202. The storage page status data includes ID (i.e., number) and type flags (including flags for active page, invalid page, and reclaimed page). The data structure can be a sequence composed of {page ID, active page flag, reclaimed page flag}. The storage block distribution data includes block ID, block active and reclaimed status flags, and block distribution location flags (i.e., relative position). The data structure can be a sequence composed of {storage block ID, relative storage block position, and status flags}. In actual use or during the input model process, the data can be converted into ASCII encoded data and merged using data concatenation.
[0029] The structure of the space usage data in this application embodiment is as follows: Figure 3 As shown, Figure 3The storage block usage habit monitoring statistics 206 in the data refers to space usage data, including storage block write frequency data 204 and storage block read / write characteristic curves 205. Storage block write frequency data 204 is calculated as the number of writes per block divided by the total number of writes to the storage space. The data structure of storage block write frequency data 205 can be {{Storage Block ID 1, "ID 1 block write count / total storage space write count"}, {Storage Block ID 2, "ID 2 block write count / total storage space write count"}, {Storage Block ID 3, "ID 3 block write count / total storage space write count"}...}. Storage block read / write characteristic curves 205 include the following data types: block write time interval over a period of time, storage block ID, and block storage address space interval over a period of time. The data structure of storage block read / write characteristic curves 205 can be {{Storage Block ID 1, ID 1 block write time interval Bitmap, ID 1 block write space interval Bitmap}, {Storage Block ID 2, ID 2 block write time interval Bitmap, ID 2 block write space interval Bitmap}, {Storage Block ID 3, ID...}, {Storage Block ID 2, ID 2 ... The data can be converted to ASCII encoded data (or the storage block ID can be converted to ASCII code while the Bitmap area remains unchanged to save data space) and merged by data concatenation.
[0030] The total length of the Bitmap for the aforementioned block write interval can be 128 bits, represented by 16 1-byte bits, where the bit position n from left to right represents the nth bit counted back from the current time. 10ms to (n+1) If a write operation occurs within 10ms, the bit is set to 1; otherwise, it is set to 0. The 10ms interval can be adjusted to the minimum storage write interval as needed. The total length of the block write space interval Bitmap can be 65536 bits, represented by 8192 bytes. The bit position 'n' from left to right represents the offset 'n' from the start position of flash storage. (4 bytes) Whether the address location has been written to; if written, set the bit to 1, otherwise set it to 0; the 4 bytes can be adjusted according to the actual hardware situation to the minimum write unit / storage alignment size of flash storage.
[0031] In step S20, the time-series state data is input into the pre-trained storage space prediction model, and the prediction model outputs the predicted distribution data of storage space in future time periods.
[0032] The storage space prediction model is an AI inference model, which can be built using the Tansformer model or frameworks such as PyTorch, without any specific limitations. The predicted distribution data is the time-series projection results of the location and status of each storage page and storage block in the storage space over a future period, output by the model. The specific content is the same as that of the spatial distribution data.
[0033] It is understood that, in the embodiments of this application, time-series state data can be input into a pre-trained storage space prediction model, and the prediction model outputs the predicted distribution data of storage space in future time periods, so as to manage the storage space in advance.
[0034] In step S30, the target storage block is determined based on the predicted distribution data, the data in the target storage block is moved to the currently active storage page of the storage space, and the storage space corresponding to the target storage block is reclaimed.
[0035] The target storage block is a storage block that meets the preset rules; the currently active storage page is a storage page that is currently used for data writing, is not full, and can be appended with data.
[0036] It is understood that the embodiments of this application can determine the target storage block based on the predicted distribution data, move the data in the target storage block to the currently active storage page of the storage space, and reclaim the storage space corresponding to the target storage block. By predicting the future storage layout in advance through the model, the storage space management can be proactively intervened in advance, the data of the storage block to be cleaned can be migrated in advance, the idle local space can be reclaimed, the storage cleanup operation can be distributed, the storage space expansion problem caused by random writes can be alleviated, the execution time of subsequent centralized page swapping operations can be reduced, and the probability of new storage write requests being blocked for a long time can be reduced.
[0037] This application embodiment inputs the time-series status data of the storage space into a pre-trained storage space prediction model. The prediction model predicts the distribution data of the storage space in the future period. Based on the predicted distribution data output by the prediction model, target storage blocks are selected, and the valid data in the target storage blocks is migrated to the currently active storage pages. At the same time, the storage space originally occupied by the target storage blocks is released and reclaimed. The data of the storage blocks to be cleaned is migrated in advance, and idle local space is reclaimed. The storage cleanup operation is distributed to alleviate the storage space expansion problem caused by random writes, reduce the execution time of subsequent centralized page swapping operations, and reduce the probability of new storage write requests being blocked for a long time.
[0038] In one example of this application, determining a target storage block based on predicted distribution data includes: determining a first offset and a second offset of the storage space and the storage block in a future time period based on the predicted distribution data; and determining the target storage block based on the first offset and the second offset of the storage block.
[0039] The first offset is the average offset of the address position of the entire storage space and the storage page as a whole in the future time period, representing the overall movement of the global storage layout; the second offset is the average offset of the position of a single storage block relative to the base address of the storage page in the future time period, representing the change of the position of a single block of data.
[0040] It is understood that, in the embodiments of this application, the first offset of the overall storage space and the second offset of a single storage block can be calculated from the predicted distribution data, and the target storage block can be determined by combining the first offset and the second offset.
[0041] In one embodiment of this application, determining a first offset of storage space in a future time period based on predicted distribution data includes: determining a target active storage page in the future time period based on storage page state data; identifying a first tail address and a second tail address corresponding to the currently active storage page and the target active storage page; and determining the first offset based on the first tail address and the second tail address.
[0042] Wherein, the target active storage page is the storage page that will be called the write carrier in the future time period predicted by the model; the first tail address is the physical address of the end of the current active storage page; and the second tail address is the physical address of the end of the target active storage page.
[0043] It is understood that, in the embodiments of this application, the target active storage page for a future time period can be determined by storage page state data, the first tail address and the second tail address corresponding to the current active storage page and the target active storage page can be identified, and the first offset can be determined based on the first tail address and the second tail address.
[0044] Specifically, embodiments of this application can identify type flags in storage page state data to determine target active storage pages for future periods.
[0045] The calculation process of the first offset in this embodiment can be as follows: Extract the tail address of the active storage page in the entire storage space under each time node in the Fee page state and storage block distribution sequence, and record them sequentially as: the tail address E0 of the active storage page at the current time, the tail address E1 of the active storage page at the first prediction time, the tail address E2 of the active storage page at the second prediction time, ..., the tail address E... n Calculate the tail address difference between adjacent time series segment by segment, and subtract the tail address of the previous time series from the tail address of the next time series to obtain the global spatial boundary change of each time series group: , … ; Calculate the absolute value of all differences, take the absolute value of the tail address change for each group, and only count the change of the global space boundary; the average value is the first offset, add up all the absolute values of the tail addresses, divide by the total number of timing segments n, and the result is the average offset of the tail address of the storage space (first offset).
[0046] In one embodiment of this application, determining a second offset of a storage block in a future time period based on predicted distribution data includes: obtaining the first relative position and the second relative position of the storage block at the current time and at all times in the future time period; and calculating the second offset based on the first relative position and the second relative position.
[0047] Wherein, the first relative position is the relative address of the storage block within the storage page at the current moment; the second relative position is the relative address of the same storage block within the storage page at multiple future moments predicted by the model.
[0048] It is understood that the embodiments of this application can traverse all storage blocks, extract the first relative position at the current time and the second relative position corresponding to all future time nodes respectively, and combine the current and future multiple sets of relative position data to calculate the second offset corresponding to the storage block. Using time-series multi-node position data to calculate the offset is more in line with the long-term storage write change trend and improves the accuracy of offset calculation.
[0049] Specifically, the calculation process of the second offset in this embodiment can be as follows: From the Fee page state and storage block distribution sequence output by the model, extract the relative position within the page corresponding to each storage block ID at each time node, and record them sequentially as: current time position S0, first prediction time position S1, second prediction time position S2…nth prediction time position S… n ; Calculate the position difference between adjacent time steps segment by segment, subtracting the position of the previous time step from the position of the storage block at the next time step to obtain the position change of each group of adjacent time steps: , … ; Calculate the absolute value of all differences, take the absolute value of each group of position changes to eliminate the calculation interference caused by the address increase or decrease direction, and only retain the position change amplitude; calculate the average value to obtain the second offset: add all the absolute values and divide by the total number of timing segments n. The result is the average position offset of the memory block (i.e., the second offset).
[0050] In one embodiment of this application, determining a target storage block based on a first offset and a second offset of the storage block includes: calculating the ratio of the first offset and the second offset; if the ratio is greater than a preset threshold, then determining the corresponding storage block as the target storage block.
[0051] The preset threshold can be set according to specific circumstances, and no specific restrictions are imposed on it.
[0052] It is understood that the embodiments of this application can calculate the ratio of the first offset and the second offset; if the ratio is greater than a preset threshold, the corresponding storage block is determined to be the target storage block.
[0053] Specifically, the overall implementation flow of the storage space management method in this application embodiment is as follows: Figure 4 As shown.
[0054] Figure 4 In this diagram, 101 represents the current storage status, 102 represents storage read / write statistics over a period of time, 103 represents the storage AI management deployment model (i.e., the trained storage space prediction model, which can be built using frameworks such as PyTorch), 104 represents the predicted page status and space layout output by the model, and 105 represents the proactive storage management by adjusting the storage layout in advance based on the model's prediction results. The specific mechanism involves obtaining the time series distribution of the subsequent storage space predicted by the model, calculating the ratio of the position change trend of each storage block to the overall layout distribution change, which also reflects the relative write update frequency of the storage blocks. After comparison, lower-frequency storage blocks or storage blocks that will not move for a long time are filtered out and moved backward in advance for local updates to free up old local spaces that have been occupied for a long time. Multiple local spaces are then integrated into a page that can be locally erased to complete local reclamation.
[0055] The basis for determining whether a storage block needs to be moved is to calculate the average position offset of the current storage block in the data sequence (i.e., the average of (sequence n) - (sequence n-1)) in the data sequence, based on the data sequence of the predicted Fee page state and storage block distribution, as well as the current Fee page state and storage distribution, and to the average position offset of the end address of the storage space in the data sequence. When the ratio exceeds a preset threshold, it is determined that the storage block needs to be actively moved.
[0056] In one embodiment of this application, after moving the data in the target storage block to the currently active storage page of the storage space, the method further includes: identifying the state of the currently active storage page; if the state is the target state, then moving the data in the target storage block to the target active storage page.
[0057] The target state is when the storage page is either close to being full of data or has already been full of data.
[0058] It is understood that in the embodiments of this application, when the current active storage page is in the target state, it indicates that the storage page is written at the shoulder height, and the target storage block data is migrated a second time to the predicted target active storage page in order to write the data in a distributed manner.
[0059] In one embodiment of this application, the training process of the prediction model includes: acquiring a training set, wherein the training set includes historical time-series state data and ground truth data; training the prediction model using the data in the training set; updating the model parameters using the prediction distribution data and ground truth data output by the prediction model during the training process, until training stops when a preset condition is met.
[0060] Among them, historical time-series state data is real time-series storage data collected over a long period of time; true value data is real storage space distribution data that actually occurs; model parameters may include model weights, biases, etc.; preset conditions can be set according to actual conditions, such as loss function convergence, upper limit of iteration number, etc.
[0061] It is understood that the embodiments of this application can use the training set to train the prediction model, continuously correct the model parameters by the error between the predicted distribution data and the true data, gradually reduce the model prediction bias, and ensure the accuracy of subsequent model predictions.
[0062] Specifically, the training configuration of the storage space prediction model in this application embodiment is as follows: Figure 5 As shown, in this section, the storage space prediction model can be called the storage AI management training model. The training data includes training data on the Fee page status and storage block distribution, as well as training data on the monitoring and statistics of storage block usage habits. The corresponding ground truth data is the target page status and space layout. The training data comes from the page status and storage block distribution data collected in the regular storage reclamation process. During the training process, the model is trained based on the deviation between the predicted page status and space layout and the target page status and space layout, so as to update the model parameters.
[0063] The application of the storage space management method of this application embodiment will be described below in conjunction with a specific application scenario, taking a vehicle equipped with the Zonal architecture as an example. The hardware involved in the entire storage space management implementation process constitutes a system, and the system structure is as follows: Figure 6 As shown, Figure 6 In this context, 401 corresponds to domain controllers 1-4, and 403 corresponds to the vehicle central computing unit (e.g., CCU (Central Computing Unit) / VCC (Vehicle Central Computer)). The vehicle central computing unit 403 is equipped with a trained storage space prediction model, which is used to execute the prediction process. Domain controllers 401 send requests and data to the vehicle central computing unit 403 via Ethernet 402, and the vehicle central computing unit 403 replies with the processing results to the corresponding domain controller 401 via Ethernet 402.
[0064] The entire system operation process is as follows: If a domain controller's own MCU Flash storage needs to use the storage space management function, and the vehicle central computing unit has deployed a trained storage model (a single model on the vehicle central computing unit can be used to train / infer the stored data of all domain controllers), the domain controller sends a model inference request / input data to the vehicle central computing unit via Ethernet connection. After receiving the inference request, the vehicle central computing unit calculates the prediction result and replies to the corresponding domain controller via Ethernet connection. Each domain controller executes the corresponding active storage management strategy based on the model inference feedback result.
[0065] In summary, the storage space management method of this application embodiment, after training a space prediction model using specified storage-related data on an onboard central computing unit with corresponding computing capabilities, performs proactive real-time management and early partial reclamation of local storage based on the prediction results. This avoids the high latency and read / write blocking during centralized paging in conventional storage methods. Through storage model training, spatial distribution data after a period of time can be predicted, which can then be used as a reference for real-time intervention in a small amount of local storage space that needs to be processed. Necessary relocation and reclamation of scattered invalid storage entries in a small local area can be performed in advance (for example, identifying low-frequency write entries and moving them to a new location in advance to free up the smallest erase unit for local erasure; for high-frequency entries, relocation can be postponed and they can be automatically written to the new location by subsequent write requests). This ensures that overall invalid and valid data are subject to reasonable spatial distribution constraints and proactive management in a timely manner, rather than centralized large-scale passive reclamation. This avoids the problems of chaotic distribution of invalid and valid data and data area expansion caused by long-term random writing, resulting in high time consumption during centralized paging processing and long-term blocking of new storage requests, which in turn leads to untimely response to critical security data storage.
[0066] According to the storage space management method proposed in the embodiments of this application, the time-series status data of the storage space is input into a pre-trained storage space prediction model. The prediction model predicts the distribution data of the storage space in the future period. The target storage block is selected based on the predicted distribution data output by the prediction model. The effective data in the target storage block is actively migrated to the currently active storage page. The storage space originally occupied by the target storage block is released and reclaimed simultaneously. The data of the storage block to be cleaned is migrated in advance, and the idle local space is reclaimed. The storage cleanup operation is distributed to alleviate the storage space expansion problem caused by random writes, reduce the execution time of subsequent centralized page swapping operations, and reduce the probability of new storage write requests being blocked for a long time.
[0067] Next, a storage space management device according to an embodiment of this application is described with reference to the accompanying drawings.
[0068] This storage space management device is applied to storage devices, where the storage space includes multiple storage pages, and each storage page includes multiple storage blocks.
[0069] Figure 7 This is a block diagram of a storage space management device according to an embodiment of this application.
[0070] like Figure 7 As shown, the storage space management device 10 includes: an acquisition module 100, an output module 200, and a management module 300.
[0071] The acquisition module 100 is used to acquire the time-series status data of the storage space, which includes the spatial distribution data and space usage data of the current time and the target historical time period; the output module 200 is used to input the time-series status data into a pre-trained storage space prediction model, and the prediction model outputs the predicted distribution data of the storage space in the future time period; the management module 300 is used to determine the target storage block based on the predicted distribution data, move the data in the target storage block to the currently active storage page of the storage space, and reclaim the storage space corresponding to the target storage block.
[0072] In one embodiment of this application, the management module 300 is further configured to: determine a first offset and a second offset of the storage space and the storage block in a future time period based on the predicted distribution data; and determine the target storage block according to the first offset and the second offset of the storage block.
[0073] In one embodiment of this application, the predicted distribution data includes storage page status data and storage block distribution data. The storage page status data includes the number and type flag of the storage page, and the storage block distribution data includes the number, relative position, and status flag of the storage block.
[0074] In one embodiment of this application, the management module 300 is further configured to: determine the target active storage page for a future time period based on storage page status data; identify the first tail address and the second tail address corresponding to the currently active storage page and the target active storage page; and determine a first offset based on the first tail address and the second tail address.
[0075] In one embodiment of this application, the management module 300 is further configured to: obtain the first relative position and the second relative position of the storage blocks at the current time and all time periods in the future time period respectively; and calculate the second offset based on the first relative position and the second relative position.
[0076] In one embodiment of this application, the management module 300 is further configured to: calculate the ratio of the first offset and the second offset; if the ratio is greater than a preset threshold, then determine the corresponding storage block as the target storage block.
[0077] In one embodiment of this application, the training process of the prediction model includes: acquiring a training set, which includes historical time-series state data and ground truth data; training the prediction model using the data in the training set; updating the model parameters using the prediction distribution data and ground truth data output by the prediction model during the training process, until training stops when a preset condition is met.
[0078] In one embodiment of this application, the storage space management device 10 of this application embodiment further includes: an identification module.
[0079] The identification module is used to identify the status of the currently active storage page after moving the data in the target storage block to the currently active storage page of the storage space; if the status is the target status, the data in the target storage block is moved to the target active storage page.
[0080] In one embodiment of this application, the spatial distribution data has the same structure as the predicted distribution data, and the spatial usage data includes storage block write frequency data and storage block read / write characteristic data.
[0081] It should be noted that the foregoing explanation of the storage space management method embodiment also applies to the storage space management device of this embodiment, and will not be repeated here.
[0082] According to the storage space management device proposed in the embodiments of this application, the storage space time-series status data is input into a pre-trained storage space prediction model. The prediction model predicts the distribution data of storage space in the future time period. The target storage block is selected based on the predicted distribution data output by the prediction model. The effective data in the target storage block is actively migrated to the currently active storage page. The storage space originally occupied by the target storage block is released and reclaimed simultaneously. The storage cleanup operation is distributed in advance, the storage space expansion problem caused by random writes is alleviated, the execution time of subsequent centralized page swapping operations is reduced, and the probability of new storage write requests being blocked for a long time is reduced.
[0083] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device may include: The memory 801, the processor 802, and the computer program stored on the memory 801 and capable of running on the processor 802.
[0084] When the processor 802 executes the program, it implements the storage space management method provided in the above embodiments.
[0085] Furthermore, electronic devices also include: Communication interface 803 is used for communication between memory 801 and processor 802.
[0086] The memory 801 is used to store computer programs that can run on the processor 802.
[0087] The memory 801 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0088] If the memory 801, processor 802, and communication interface 803 are implemented independently, then the communication interface 803, memory 801, and processor 802 can be interconnected via a bus to complete communication between them. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized into address buses, data buses, control buses, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0089] Optionally, in a specific implementation, if the memory 801, processor 802, and communication interface 803 are integrated on a single chip, then the memory 801, processor 802, and communication interface 803 can communicate with each other through an internal interface.
[0090] The processor 802 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0091] This application also provides a vehicle including the electronic equipment described above.
[0092] This application also provides a computer-readable storage medium storing a computer program or instructions thereon, which, when executed by a processor, implements the storage space management method described above.
[0093] This application also provides a computer program product, including a computer program or instructions, which, when executed, implement the storage space management method described above.
[0094] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0095] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0096] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or N executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0097] It should be understood that the various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, the N steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or more of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (FPGAs), field-programmable gate arrays (FPGAs), etc.
[0098] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
Claims
1. A storage space management method, characterized in that, The method is applied to a storage device, the storage space comprising multiple storage pages, each storage page comprising multiple storage blocks, wherein the method includes the following steps: Obtain the time-series status data of the storage space, wherein the time-series status data includes the spatial distribution data and space usage data of the current time and the target historical time period; The time-series state data is input into a pre-trained storage space prediction model, and the prediction model outputs the predicted distribution data of the storage space in future time periods. Based on the predicted distribution data, a target storage block is determined, the data in the target storage block is moved to the currently active storage page of the storage space, and the storage space corresponding to the target storage block is reclaimed.
2. The storage space management method according to claim 1, characterized in that, The step of determining the target storage block based on the predicted distribution data includes: Based on the predicted distribution data, determine the first offset and the second offset of the storage space and the storage block in the future time period; The target storage block is determined based on the first offset and the second offset of the storage block.
3. The storage space management method according to claim 1 or 2, characterized in that, The predicted distribution data includes storage page status data and storage block distribution data. The storage page status data includes the storage page number and type flag, and the storage block distribution data includes the storage block number, relative position, and status flag.
4. The storage space management method according to claim 3, characterized in that, Determining the first offset of the storage space in a future time period based on the predicted distribution data includes: Determine the target active storage pages for future time periods based on the storage page status data; Identify the first tail address and the second tail address corresponding to the currently active storage page and the target active storage page; The first offset is determined based on the first tail address and the second tail address.
5. The storage space management method according to claim 3, characterized in that, Determining the second offset of the storage block in a future time period based on the predicted distribution data includes: Obtain the first relative position and the second relative position of all storage blocks at the current time and within the future time period, respectively; The second offset is calculated based on the first relative position and the second relative position.
6. The storage space management method according to claim 2, characterized in that, Determining the target storage block based on the first offset and the second offset of the storage block includes: Calculate the ratio of the first offset to the second offset; If the ratio is greater than a preset threshold, then the corresponding storage block is determined to be the target storage block.
7. The storage space management method according to claim 1, characterized in that, The training process for the prediction model includes: Obtain the training set, which includes historical time-series state data and ground truth data; The prediction model is trained using the data in the training set. During the training process, the model parameters are updated using the predicted distribution data and ground truth data output by the prediction model until the preset conditions are met and training stops.
8. The storage space management method according to claim 4, characterized in that, After moving the data in the target storage block to the currently active storage page of the storage space, the process further includes: Identify the status of the currently active storage page; If the state is the target state, then the data in the target storage block is moved to the target active storage page.
9. The storage space management method according to claim 1, characterized in that, The spatial distribution data has the same structure as the predicted distribution data, and the spatial usage data includes storage block write frequency data and storage block read / write characteristic data.
10. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the storage space management method as described in any one of claims 1-9.
11. A vehicle, characterized in that, Including the electronic device as described in claim 10.
