CN117435124A - Data storage method, electronic device and storage medium - Google Patents

Data storage method, electronic device and storage medium Download PDF

Info

Publication number
CN117435124A
CN117435124A CN202210837667.1A CN202210837667A CN117435124A CN 117435124 A CN117435124 A CN 117435124A CN 202210837667 A CN202210837667 A CN 202210837667A CN 117435124 A CN117435124 A CN 117435124A
Authority
CN
China
Prior art keywords
data
stored
length
block
storage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210837667.1A
Other languages
Chinese (zh)
Inventor
王棪腾
蒋为正
马耀辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202210837667.1A priority Critical patent/CN117435124A/en
Priority to PCT/CN2023/107237 priority patent/WO2024012528A1/en
Publication of CN117435124A publication Critical patent/CN117435124A/en
Pending legal-status Critical Current

Links

Classifications

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

Landscapes

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

Abstract

The application provides a data storage method, an electronic device and a computer readable storage medium. The method comprises the following steps: acquiring the 1 st section of data to be stored, and determining that the 1 st section of data to be stored is above a first length; compressing the 1 st segment of data to be stored in a page alignment mode to obtain a 1 st compression block; acquiring the data to be stored in the ith section, and determining that the uncompressed data of the data to be stored in the (i-1) th section and the length of the data to be stored in the (i) th section are more than a first length; compressing the data to be stored in the ith section and the uncompressed data of the data to be stored in the (i-1) th section in a page alignment mode to obtain an ith compressed block; the page alignment mode enables the length of each compression block to be D times of the storage capacity of each storage page; and determining that the sum of the lengths of the 1 st to i th compressed blocks is greater than or equal to the second length, and storing the 1 st to i th compressed blocks to a storage medium. The method and the device can ensure the timely landing of the data to be stored, and can reduce the write amplification phenomenon of the storage medium.

Description

Data storage method, electronic device and storage medium
Technical Field
The present disclosure relates to the field of terminal technologies, and in particular, to a data storage method, an electronic device, and a computer readable storage medium.
Background
The intelligent driving technology is a hot spot technology in vehicle engineering. The intelligent driving vehicle comprises a vehicle machine (or a driving computer) which can be used as a brain of the vehicle and is responsible for monitoring, recording, controlling and the like of the running state of the vehicle.
For some vehicles, the eMMC (Embedded Multi Media Card) specification is adopted, and a Solid State Disk (SSD) is used as a nonvolatile storage medium (i.e., a vehicle hard Disk). Compared with other forms of storage media (such as mechanical hard disks), the solid state hard disk is adopted as the hard disk of the vehicle, so that the vehicle has higher read-write speed, and the overall performance of the vehicle can be improved.
According to the working principle of the solid state disk, the solid state disk has a write amplification phenomenon. That is, the actual amount of data written to the solid state disk may be several times the amount of valid data written. Because the total number of times that each storage unit of the solid state disk can be written in is fixed (for example, 100000 times), the phenomenon of write amplification can shorten the service life of the solid state disk. When the service life of the solid state disk is significantly shorter than the scrapping period of the vehicle (the scrapping period of the vehicle is usually more than 10 years, and the highest scrapping period of the vehicle specified by national regulations is 15 years), the user needs to frequently replace the hard disk of the vehicle, so that the maintenance cost of the vehicle can be increased.
In addition, the running environment of the vehicle has high uncertainty, for example, the sudden flameout of the vehicle can cause the power failure of the vehicle and the like. When the vehicle is suddenly powered off, some data may not be stored in the fixed hard disk in time, which may result in loss of information.
Disclosure of Invention
Some embodiments of the present application provide a data storage method, an electronic device, and a computer-readable storage medium, and the following description of aspects of the present application may be referred to herein.
In a first aspect, the present application provides a data storage method for an electronic device, the electronic device including a storage medium including a plurality of storage pages; the method comprises the following steps: acquiring the 1 st section of data to be stored, and determining that the length of the 1 st section of data to be stored is greater than or equal to the first length; compressing at least part of the data of the 1 st section of data to be stored in a page alignment mode to obtain a 1 st compression block; acquiring the data to be stored in the ith section, determining that the sum of the uncompressed data of the data to be stored in the ith-1 section and the length of the data to be stored in the ith section is greater than or equal to a first length, and i is a positive integer greater than or equal to 2; compressing at least part of the data to be stored in the ith section and uncompressed data of the data to be stored in the (i-1) section in a page alignment mode to obtain an ith compressed block; the page alignment mode is that the length of each compressed block is an integer multiple of a first storage length, the first storage length is D times of the storage capacity of each storage page, and D is a positive integer; determining that preset storage conditions are met, and storing data to be stored in a storage medium; wherein determining that the preset storage condition is satisfied, storing the data to be stored to the designated storage location includes: and determining that the sum of the lengths of the 1 st to i th compressed blocks is greater than or equal to the second length, and storing the 1 st to i th compressed blocks to a storage medium.
According to the embodiment of the application, the data to be stored can be dropped in time, and the write amplification factor of a storage medium (such as a solid state disk) can be reduced, so that the service life of the storage medium is prolonged, and meanwhile, the load of I/O resources of the electronic equipment can be reduced.
In some embodiments, compressing at least a portion of the data of the 1 st segment of data to be stored in a page aligned manner to obtain a 1 st compressed block, comprising: sequentially compressing N continuous fragments of the data to be stored in the 1 st section one by one from the head of the data to be stored in the 1 st section to obtain N sub-compression blocks, wherein N is a positive integer above 2, and the lengths of the 1 st to N-1 st sub-compression blocks are the first storage length; comparing the length of the Nth sub-compression block with the first storage length, and if the length of the Nth sub-compression block is smaller than the first storage length, taking the combination of the 1 st to N-1 st sub-compression blocks as the 1 st compression block; if the length of the nth sub-compressed block is equal to the first storage length, the 1 st to nth sub-compressed blocks are combined into the 1 st compressed block.
In some embodiments, compressing at least a portion of the data of the 1 st segment of data to be stored in a page aligned manner to obtain a 1 st compressed block, comprising: compressing all data in the data to be stored in the 1 st section to obtain an initial compression block; judging whether the length of the initial compression block is an integer multiple of the first storage length, if so, taking the initial compression block as a 1 st compression block; if not, dividing the initial compression block into a first sub-block and a second sub-block, and taking the first sub-block as a 1 st compression block, wherein the first sub-block is positioned at the head of the initial compression block, the length of the first sub-block is an integer multiple of the first storage length, and the length of the second sub-block is smaller than the first storage length.
In some embodiments, the 1 st compressed block includes a header portion and a content portion, the header portion having a length of a preset fixed length, the content portion including compressed data of at least part of the data to be stored in the 1 st segment.
In some embodiments, d=5 to P, where P is the number of memory pages contained in each memory block of the solid state disk. According to the embodiment of the application, the data to be stored is compressed in a page alignment mode, so that the compression block can just occupy an integer number of storage pages, the storage space of the storage medium can be fully utilized, and the write amplification factor of the storage medium is reduced.
In some implementations, the first length is 0.1-0.5 times the bandwidth of the I/O data bus of the electronic device; and/or the second length is 0.1-0.4 times the bandwidth of the I/O data bus of the electronic device.
According to the embodiment of the application, the compression rate of the data to be stored can be improved, frequent occupation of I/O resources can be avoided, and the burden of the I/O resources is reduced.
In some embodiments, determining that the preset storage condition is satisfied, storing the data to be stored to the specified storage location further comprises: and determining that the difference between the current time and the preset storage starting timing time is more than a first time length, and storing the 1 st to i th compression blocks and additional compression blocks into a designated storage position, wherein the additional compression blocks are compression blocks obtained after compressing data to be stored which are not compressed into the compression blocks. The embodiment of the application can further ensure timely landing of data.
In some embodiments, the second length is 0.1-0.2 times the product of the bandwidth of the I/O data bus of the electronic device and the first length of time.
In a second aspect, embodiments of the present application provide a data storage method for an electronic device, where the electronic device includes a storage medium including a plurality of storage pages; the method comprises the following steps: acquiring data to be stored, and determining that the sum of the length of the data to be stored and the length of the legacy data in the electronic equipment is more than a first length, wherein the legacy data is uncompressed data to be stored; compressing data to be stored and legacy data in a page alignment manner to obtain a compressed block to be stored; the page alignment mode enables the length of the compressed block to be an integer multiple of a first storage length, the first storage length is D times of the storage capacity of each storage page, and D is a positive integer; determining that the preset storage condition is met, storing the data to be stored in a storage medium, otherwise, returning to the step of acquiring the data to be stored until the preset storage condition is met; wherein determining that the preset storage condition is satisfied, storing the data to be stored to the designated storage location includes: and determining that the total length of the obtained compressed block is more than the second length, and storing the obtained compressed block to a storage medium.
In a third aspect, embodiments of the present application provide an electronic device, including: a memory for storing instructions for execution by one or more processors of the electronic device; a processor, when executing instructions in memory, may perform the method of any of the embodiments of the first aspect of the present application. The advantages achieved by the third aspect may refer to the advantages provided by any embodiment of the first aspect, and are not described here again.
In a fourth aspect, embodiments provide a computer readable storage medium having instructions stored thereon, which when executed on a computer, cause the computer to perform any of the embodiments of the first aspect of the present application. The advantages achieved by the fourth aspect may refer to the advantages of any embodiment of the first aspect, and are not described here again.
Drawings
Fig. 1 illustrates an exemplary application scenario of a data storage method provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of a storage data setup interface according to an embodiment of the present disclosure;
fig. 3 shows an exemplary structural diagram of a vehicle machine provided in an embodiment of the present application;
FIG. 4 shows an exemplary block diagram of a solid state disk provided by an embodiment of the present application;
FIG. 5 is a schematic diagram of a storage setup interface according to an embodiment of the present disclosure;
FIG. 6 illustrates an exemplary flow chart of a data storage method provided by an embodiment of the present application;
fig. 7 is a schematic diagram of an acquisition manner of data to be stored according to an embodiment of the present application;
FIG. 8 illustrates an exemplary block diagram of a compression block provided by an embodiment of the present application;
FIG. 9 illustrates an exemplary flow chart of a block alignment compression method provided by an embodiment of the present application;
FIG. 10 is a schematic diagram showing a first embodiment of a method for forming a compression block;
FIG. 11 illustrates an exemplary second flowchart of a block alignment compression method provided by embodiments of the present application;
FIG. 12 is a schematic diagram showing a second embodiment of a method for forming a compression block;
fig. 13 is a schematic diagram illustrating a forming manner of data to be dropped according to an embodiment of the present application;
FIG. 14 illustrates an exemplary second flowchart of a data storage method provided by an embodiment of the present application;
FIG. 15 shows a block diagram of an electronic device provided by an embodiment of the present application;
fig. 16 shows a schematic structural diagram of a System on Chip (SoC) according to an embodiment of the present application.
Detailed Description
Specific embodiments of the present application will be described in detail below with reference to the accompanying drawings.
The embodiment of the application is used for providing a data storage method for electronic equipment, and the electronic equipment comprises a nonvolatile storage medium taking a page as a storage unit. The method provided by the embodiment of the application can store the data in the storage medium of the electronic equipment in a page alignment mode, so that the write amplification factor of the storage medium is reduced, and the service life of the storage medium is prolonged. In addition, the embodiment of the application can also ensure that the data is stored in the storage medium in time so as to avoid data loss. Hereinafter, a solid state disk is taken as an example of a nonvolatile storage medium of an electronic device, but the present application is not limited thereto. In other embodiments, the non-volatile storage medium may also be in other forms, such as flash memory, etc.
In the present application, the electronic device may be a device of various forms, for example, a mobile device such as a car machine, a notebook computer, a wearable device, a personal digital assistant (Personal Digital Assistant, PDA), or a fixed device such as a server, a desktop computer, or a machine tool main control computer, which is not limited in this application.
In addition, the application of the electronic device may be various occasions such as vehicles, factories, ships, mines, aircrafts, civil/industrial buildings, amusement facilities, and the like, and the application is not limited.
Hereinafter, the vehicle machine will be described as an example of the electronic device.
Fig. 1 shows an exemplary application scenario of the present embodiment. Referring to fig. 1, a vehicle machine 100 is provided in a vehicle. In the running process of the vehicle, the vehicle 100 not only can realize the user interaction function, for example, the vehicle 100 can provide the voice call function, the navigation function and the like for the user; the running state of the vehicle may also be monitored and controlled, for example, the vehicle machine 100 may acquire various running state data of the vehicle (e.g., vehicle speed data, steering data, battery level data, road condition image data, etc.), control the running state of the vehicle (e.g., control the acceleration performance of the vehicle), and the like. That is, the vehicle 100 may be understood as a "brain" of the vehicle for maintaining normal operation of the vehicle.
During vehicle operation, it is desirable to store some important data (e.g., vehicle operating state data) in order to analyze the vehicle operating state in order to discover potential vehicle defects in time and optimize vehicle performance.
The data to be stored is referred to herein as "data to be stored". In the present application, the data type of the data to be stored is not limited, and for example, the data to be stored may be one or more of vehicle running state data, navigation data, multimedia data, and radio voice data. The source of the data to be stored may be data collected by a peripheral device (e.g., a vehicle sensor) of the vehicle 100, data downloaded by the vehicle 100 through a network (e.g., a 5G network), data obtained by the vehicle 100 through operation (e.g., a recognition result obtained by recognizing a user's voice by the vehicle 100), and so on.
In some examples, the type of data to be stored may be set by the vehicle manufacturer, e.g., the vehicle manufacturer sets data collected by a particular sensor (e.g., road condition image sensor, vehicle speed sensor) as the data to be stored; in other examples, the data to be stored may also be set by an application, for example, a "navigation application" sets map data acquired by itself as the data to be stored; in other examples, the data to be stored may also be set by a user, for example, referring to fig. 2, the user sets "road condition image data", "station voice data" as the data to be stored through the stored data setting interface 10 provided by the car machine 100.
After the vehicle 100 receives the data to be stored, the data to be stored is first stored in a memory (Random Access Memory, RAM) (also referred to as "main memory") of the vehicle 100. When the vehicle 100 is powered off, the data in the memory will disappear. Therefore, the data to be stored needs to be transferred from the memory of the vehicle 100 to the solid state disk of the vehicle 100 in time (also called "drop the data to be stored"), so that the data to be stored can be reliably stored.
In some implementations, the data drop opportunity is configured by the operating system. For example, when the operating system determines that the current occupancy rate of the memory is higher than a set threshold (e.g., 70%), the data to be stored is dropped to release the memory space; or when the operating system judges that the currently running application comprises the application (for example, navigation application) with higher memory occupancy rate, the data to be stored is dropped, so that the normal running of the current application is ensured.
In this embodiment, the landing time of the data to be stored has high uncertainty, and timely landing of the data to be stored cannot be ensured. For example, when the vehicle suddenly turns off due to sudden braking, the operating system may not have dropped the data to be stored for a long time, which may result in loss of data.
In other embodiments, the data to be stored is compressed when the electronic device receives the data to be stored. If the length of the compressed data is an integer multiple of the page size (for example, 4K) of the solid state disk, the compressed data is dropped; otherwise, the compressed data is processed and then dropped (for example, the compressed data is dropped by adopting a head alignment or tail alignment mode).
The embodiment can reduce the write amplification factor of the solid state disk as much as possible. However, this embodiment cannot guarantee timely landing of data, nor can it guarantee the compression rate of data.
Therefore, the embodiment of the application provides a data storage method, which can ensure that data is timely dropped, and simultaneously can reduce the write amplification factor of the solid state disk as much as possible. Specifically, in the embodiment of the present application, the electronic device compresses the data to be stored in a page-aligned manner every time after the length of the accumulated data to be stored reaches the length L1 (first length accumulation), so as to obtain a plurality of compression blocks C. The length of each compression block C is an integer multiple of a set length L0, and the set length L0 is an integer multiple of the storage capacity of a storage page of the solid state disk. After the total length of the plurality of compression blocks C reaches the length L2 (second length accumulation), the vehicle 100 trays the plurality of compression blocks C as a whole. Therefore, not only can the data to be stored be dropped in time, but also the write amplification coefficient of the solid state disk can be reduced, so that the service life of the solid state disk can be prolonged, and meanwhile, the burden of I/O resources can be reduced.
In other embodiments, a time-triggered drop mechanism is also included. That is, every a set period of time Δt (as a first period of time), the electronic device will automatically execute the data disc drop once, so as to further ensure that the data disc drops in time, and avoid the data loss.
Specific embodiments of the present application are described below. In the following embodiments, the car machine 100 is taken as an example of an electronic device, but it is understood that the present application is not limited thereto. In other embodiments, the electronic device may be a device that is used in factories, ships, mines, aircraft, and other applications.
Fig. 3 shows an exemplary structural diagram of the car machine 100. Referring to fig. 3, the vehicle 100 includes a processor 110, a memory 120, an Input/Output (I/O) bus, a mobile communication module 130, a wireless communication module 140, a solid state disk 150, and the like. The mobile communication module 130, the wireless communication module 140 and the solid state disk 150 are connected to the processor 110 and the memory 120 through I/O buses. In addition, the vehicle 100 may also be connected to one or more functional units of the vehicle (e.g., a power management module, status sensors, etc.) via an I/O bus, and the I/O bus connected to the vehicle 100 and the functional units of the vehicle (e.g., a vehicle speed sensor) are referred to herein as peripheral devices (or I/O devices) of the vehicle 100.
It should be understood that the connection relationship between the modules illustrated in the present embodiment is only illustrative, and is not limited to the configuration of the vehicle 100. In other embodiments of the present application, the vehicle 100 may also employ different connection manners, or a combination of multiple connection manners in the foregoing embodiments.
The I/O devices and the vehicle 100 may communicate with each other through an I/O bus, for example, the I/O devices may upload message data to the vehicle 100 through the I/O bus (e.g., the road condition image sensor may upload collected road condition image data to the vehicle 100), and the vehicle 100 issues control instructions to the I/O devices through the I/O bus (e.g., the vehicle 100 may issue instructions for entering the energy-saving mode to the vehicle power management module).
The I/O buses may be peripheral component interconnect (Peripheral Component Interconnent, PCI) buses, integrated circuit (inter-integrated circuit, I2C) buses, integrated circuit built-in audio (inter-integrated circuit sound, I2S) buses, pulse code modulation (pulse code modulation, PCM) buses, universal asynchronous receiver/transmitter (UART) buses, and the like.
The I/O buses may include a control bus, an address bus, and a data bus. The maximum data interaction amount between the I/O device and the vehicle 100 in unit time (1 s) is determined by the bandwidth of the I/O data bus. The bandwidth of the I/O data bus is the amount of data (unit: B) that can be transferred on the data bus per unit time, and is related to the clock frequency and bit width of the data bus. For example, when the clock frequency of the I/O data bus is 2MHz and the bit width is 32 bits, the bandwidth of the I/O data bus=32 bits×2mhz≡8=8 MB/s.
Memory 120 may be used to store computer-executable program code that includes instructions. Memory 120 may include a program storage area and a data storage area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data (e.g., audio data, phonebook, etc.) created during use of the car machine 100, and the like. In addition, the memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash memory (universal flash storage, UFS), and the like. The processor 110 performs various functional applications and data processing of the vehicle 100 by executing instructions stored in the memory 120 and/or instructions stored in a memory provided in the processor.
The mobile communication module 130 may provide a solution including 2G/3G/4G/5G wireless communication applied to the car machine 100. The mobile communication module 130 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA), etc. The mobile communication module 130 may receive electromagnetic waves from an antenna of the vehicle 100, perform processes such as filtering, amplifying, and the like on the received electromagnetic waves, and transmit the processed electromagnetic waves to a modem processor for demodulation. The mobile communication module 130 may amplify the signal modulated by the modem processor, and convert the signal into electromagnetic waves through the antenna to radiate. In some embodiments, at least some of the functional modules of the mobile communication module 130 may be disposed in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 130 may be disposed in the same device as at least some of the modules of the processor 110.
The vehicle 100 may communicate with a cloud server through a mobile communication module. For example, after the vehicle machine 100 obtains the data to be stored of the vehicle, the data to be stored may be uploaded to the cloud server through the mobile communication module for storage.
The wireless communication module 140 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc., applied to the vehicle 100. The wireless communication module 140 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via an antenna of the vehicle 100, modulates the electromagnetic wave signals, filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 140 may also receive a signal to be transmitted from the processor 110, frequency modulate the signal, amplify the signal, and convert the signal into electromagnetic waves to radiate the electromagnetic waves through the antenna of the vehicle 100.
The solid state disk 150 is a nonvolatile storage medium in the vehicle 100, and the vehicle 100 may store data to be stored in the solid state disk 150. The solid state disk 150 may achieve faster read and write speeds than other types of storage media (e.g., mechanical hard disks), and thus may improve the performance of the vehicle 100. However, due to the structural characteristics of the solid state disk 150, a phenomenon of write amplification exists, which will be described with reference to fig. 4.
Fig. 4 shows an exemplary structural diagram of solid state disk 150. Referring to fig. 4, the solid state disk 150 includes B blocks, each consisting of P pages. Typically, the page size is 512 bytes to 4KB, and the block is made up of 32 to 128 pages. Hereinafter, for ease of understanding, each memory block is exemplified by a composition of 64 memory pages, with the size of each page being 4 KB.
The solid state disk 150 is based on flash technology. Each block can be regarded as a flash memory (flash memory) chip. The data in the block is erased before each writing to the block, and one erase clears all the data in the block. Since valid data is usually stored in the block, the solid state disk 150 will move the original data to other blocks in order to ensure that the original data in the block is not lost.
For example, the block 1 stores 40KB of original data (denoted as data_b1). When new data of 5KB is to be written to block 1, solid state disk 150 needs to transfer original data data_b1 in block 1 to the new block. Generally, the solid state disk 150 transfers the original data (i.e. data_b1) in the block 1 together with the original data in other blocks (e.g. the block 2) to a new block (e.g. the block 3) to clean up a plurality of blank blocks (this mechanism is a garbage collection mechanism of the solid state disk). Assuming that the original data in the block 2 is data_b2 (the size is 20 KB), at this time, the solid state disk 150 needs to write the original data in the block 1 and the block 2 (i.e. data_b1 and data_b2) into the block 3, erase the block 1 and the block 2, and then write new data of 5KB into the block 1. In this example, to write 5KB of new data into the solid state disk 150, the actual written data of the solid state disk 150 is 65KB, and the actual written amount is 13 times of the effective written amount, which is the write amplification phenomenon of the solid state disk 150. In this example, the write amplification factor of solid state disk 150 is 13.
The total number of times each block of the solid state disk 150 can be written is a certain number (e.g., 100000 times), beyond which data cannot be written to the block any more. Therefore, the write amplification phenomenon may reduce the service life of the solid state disk 150. When the service life of the solid state disk 150 is significantly less than the scrapped life of the vehicle, the user needs to replace the solid state disk 150 frequently, and the maintenance cost of the vehicle is increased.
The data storage method provided in this embodiment is described below with reference to the structure diagram of fig. 4. The data storage method provided in this embodiment may be automatically started when the vehicle 100 is started, or may be started based on a user instruction. For example, referring to FIG. 5 (a), the user may enter the storage setup interface 30 shown in FIG. 5 (b) by clicking on the "store" option of the setup interface 20. After the user checks the selection box 40 of "whether to start storage optimization", the vehicle 100 may start executing the data storage method provided in this embodiment.
Fig. 6 is an exemplary flowchart of a data storage method according to one embodiment of the present application. Referring to fig. 6, the data storage method provided in this embodiment includes the following steps:
s110: the vehicle 100 acquires the data D1 to be stored (as the 1 st piece of data to be stored).
In this embodiment, the data to be stored may be various types of data, for example, data reported by an I/O device, data downloaded from a network, data obtained by the operation of the vehicle 100 (for example, a recognition result obtained by the vehicle 100 recognizing the voice of the user), and the like, which will be described below by taking the data reported by the I/O device as an example.
In the on state of the vehicle 100, each I/O device (e.g., an image sensor) may report the collected data to the vehicle 100. After receiving the message data from the I/O device, the vehicle 100 may generate data to be stored. In some examples, the vehicle 100 may directly use the received I/O device message data as the data to be stored; in other examples, the vehicle 100 may process the message data of the I/O device (for example, add additional information such as source, length, etc. to the message data), and then use the processed message data as the data to be stored. After the vehicle 100 generates (or "acquires") the data to be stored, the data to be stored is stored in the vehicle 100 memory 120.
The vehicle 100 may receive message data from the I/O devices aperiodically. For example, referring to fig. 7, the vehicle 100 receives the message data from the vehicle speed sensor at time t1, the message data from the direction sensor at time t2, and the message data from the image sensor at time t 3. The vehicle 100 may generate the Data to be stored Data1, data2, and Data3 according to the above message Data, respectively. In addition, since the time for the vehicle 100 to process the message data into data to be stored (for example, adding additional information to the message data, etc.) is very short (for example, on the order of microseconds), it can be ignored. Herein, the time when the vehicle 100 receives the message data is regarded as the time when the vehicle 100 acquires the data to be stored. For example, the time t1 is regarded as the time when the Data1 to be stored is acquired.
In some embodiments, the time when the vehicle 100 receives a message is the time when the vehicle 100 receives the message completely. The vehicle 100 can determine whether a certain message data is completely received according to a preset rule. For example, in some examples, the message has a preset fixed length (e.g., 1 KB), and in the examples, when the length of the message received by the vehicle 100 is equal to the preset fixed length, it is determined that the message has been completely received; in other examples, the message has a header and a trailer in a fixed format (e.g., the header is a fixed character "0011" and the trailer is a fixed character "1100"), and in this example, when the truck 100 detects the header and trailer of the message, it is determined that the message has been received completely.
In other embodiments, the data to be stored may also include data downloaded from a network, data calculated by the vehicle 100, and the like. In this embodiment, the vehicle 100 may determine the time to acquire the data to be stored according to the type of the data to be stored. For example, for data downloaded from a network, the vehicle machine 100 may take the time when the complete network data packet is received as the time when the data to be stored is acquired; for the calculated data, the vehicle 100 may use the time when the calculation is completed as the time when the data to be stored is acquired.
S120: the vehicle 100 determines whether the length of the data D1 to be stored is greater than or equal to the length L1 (as the first length).
Each piece of data to be stored may include a plurality of pieces of message data. Referring to fig. 7, the Data D1 to be stored includes Data1, data2, and Data3. After the vehicle 100 acquires the I/O device message data each time (for example, time t1, time t2, and time t 3), it is determined whether the total length of the acquired data D1 to be stored is greater than or equal to the length L1. If the total length of the data D1 to be stored is greater than the length L1, step S130 is performed to compress the data D1 to be stored; otherwise, the process returns to step S110 to continue to acquire the data D1 to be stored.
That is, the length L1 is a threshold value for triggering the vehicle machine 100 to compress the data D1 to be stored, and when the length of the data D1 to be stored is smaller than the length L1, the vehicle machine 100 does not compress the data D1 to be stored. It will be appreciated that data compression is the re-encoding of repeated segments/redundant data in the original data in a more refined manner to reduce the amount of data after compression. Therefore, the longer the length of the original data, the higher the probability of the occurrence of the repeated segments in the original data, and the higher the compression rate of the compressed file. Therefore, compared with the manner of compressing the Data to be compressed one by one (for example, the manner of compressing the Data1, data2, and Data3 included in the Data to be stored D1 respectively), in this embodiment, by setting the length threshold L1 for triggering Data compression, the compression rate of the Data to be stored can be improved, so as to reduce the amount of dropped Data in the solid state disk 150, and improve the service life of the solid state disk 150.
The specific value of the length L1 is not limited in this embodiment. In some embodiments, length L1 is positively correlated to the bandwidth of the I/O data bus. For example, the length L1 is 0.1 to 0.5 times (e.g., 0.1 times, 0.2 times, etc.) the bandwidth of the I/O data bus. In this way, for the car machine 100 having a strong capability of communicating with I/O, the length L1 as large as possible can be set to raise the threshold for triggering data compression, thereby achieving the compression ratio as high as possible.
Hereinafter, for ease of understanding, the length l1=1024 KB is taken as an example for explanation. Referring to fig. 7, at time t3, the vehicle machine 100 acquires data to be stored data1, data2, data3, which are 85KB,66KB,2250KB in length, respectively, and therefore the length (2401 KB) of the data to be stored D1 is greater than the length L1 (1024 KB). Therefore, after the time t3, the vehicle 100 starts to execute step S130 to compress the data D1 to be stored.
S130: the vehicle 100 compresses the data D1 to be stored in a page-aligned manner to obtain a compressed block C1. The page alignment manner is such that the length of the compressed block obtained after the data to be stored is compressed is an integer multiple of the storage length L0 (as the first storage length), the storage length L0 is D times of the storage capacity of each storage page of the solid state disk 150, and D is a positive integer.
In this embodiment, the data to be stored is compressed in a page alignment manner, so that the compression block can occupy just an integer number of storage pages, thereby fully utilizing the storage space of the solid state disk 150 and reducing the write amplification coefficient of the solid state disk 150. Herein, a compressed block obtained by using the page alignment method is referred to as "compressed block C". For the different compressed blocks C, the identification is performed by the sequence number of the tail, for example, the compressed block C1 represents a compressed block obtained by the data D1 to be stored, and the compressed block C2 represents a compressed block obtained by the data D2 to be stored. It will be appreciated that when compression is performed in a page-aligned manner, a portion of the data to be stored may not be compressed into the compression block C.
Further, the length of the compressed block C is an integer multiple of the storage length L0, and the storage length L0 is D times the storage capacity (i.e., page size) of the storage page of the solid state disk 150. It will be appreciated that when D is equal to P (P is the number of pages each block contains as described above), each compressed block C occupies exactly an integer number of blocks, and the write amplification factor of the solid state disk 150 can be controlled to the maximum. However, when D is equal to P, the size of the compressed block C is larger, which may increase the burden of the memory 120 during compression, and more data to be stored may not be compressed into the compressed block C. Thus, in some examples, D may be less than P. In this embodiment, D is an arbitrary value between 5 and P, for example, 5,8, 20, etc.
The compression algorithm is not limited in this embodiment, and for example, the compression algorithm may be huffman compression (Huffman compression) algorithm, LZW algorithm, run-length encoding algorithm, or the like.
An exemplary method of compressing the data D1 to be compressed is described below. For ease of understanding, the structure of the compression block C will be described first.
Fig. 8 shows an exemplary structure of the compression block C. Referring to fig. 8, the compression block C includes a header portion and a content portion. The header portion includes an identification (or "flag") of the compressed block and a size (called "size") of the content portion including compressed data (called "content") of data to be stored.
The header portion of the compressed block C has a preset fixed length B, for example, a flag field and a size field are 1 byte (i.e., length b=2b), respectively. The flag is used for uniquely identifying the compressed block C, for example, the flag may be a generation sequence number, a generation time, and the like of the compressed block C; the size is the size of the content part, and it is understood that the value of the size is equal to the length of the compressed block C minus the length B of the header part, for example, when the length of the compressed block C is 64K, the value of the size is 64KB-2B; when the compressed block C has a length of 96K, the size has a value of 96KB-2B. It should be noted that, in other embodiments, the compression block C may not include a header portion.
The specific method for compressing the data D1 to be stored is not limited, and only the data D1 to be stored is compressed in a page alignment manner. Two specific examples are given below.
For example one, referring to fig. 9 and 10, in the present example, the process of compressing the data D1 to be stored by the vehicle machine 100 includes the steps of:
s131: the vehicle 100 sequentially compresses N consecutive segments of the data D1 to be stored from the head of the data D1 to be stored to obtain N sub-compressed blocks, wherein the lengths of the 1 st to N-1 st sub-compressed blocks are respectively equal to the storage length L0 (assuming 32 KB), and the length of the nth sub-compressed block is less than or equal to the storage length L0 (in the example given in fig. 10, the length of the nth sub-compressed block is less than L0).
Specifically, referring to fig. 10, the vehicle machine 100 compresses data in the data D1 to be stored starting from the head of the data D1 to be stored until a compressed block C1-1 'of length L0-b is formed (the portion of the data D1 to be stored compressed into the compressed block C1-1' is the segment 1 of the data D1 to be stored). Thereafter, a header portion having a length b is added in front of the compression block C1-1', so that a sub-compression block C1-1 can be formed. It is understood that the length of the sub-compression block C1-1 is L0. Wherein the value of the header portion flag may be determined according to a preset rule, for example, the flag value of the compressed block C1 is determined to be 0001 according to the generation sequence number of the compressed block C1, and the value of the header portion size may be determined in a subsequent step (determined after determining the length of the compressed block C1, which will be described later).
Then, the car machine 100 compresses the data after the segment 1 until a compressed block C1-2 with a length L0 is formed, and the part of the data D1 to be stored compressed into the compressed block C1-2 is the segment 2; the vehicle machine 100 continues to compress the data after the segment 2 until a compressed block C1-3 with the length of L0 is formed, and the data D1 to be stored is compressed into the compressed block 03 to be the segment 3; … …; the above steps are repeated until the vehicle 100 compresses the data D1 to be stored. At this time, the vehicle 100 compresses the data D1 to be stored into N sub-compressed blocks, the lengths of the 1 st to N-1 st sub-compressed blocks being equal to the storage length L0, respectively. In this embodiment, the value of N is not limited, and N may be any integer of 2 or more.
In addition, in other embodiments, the header portion may not be included in the compression block C. When the header portion is not included in the compressed block C, the length b is set to 0. At this time, the sub-compressed block C1-1' obtained by compressing the segment 1 is the sub-compressed block C1-1.
S132: the vehicle 100 determines whether the length of the nth sub-compression block is less than the length L0, if yes, step S133 is executed; if not, step S134 is performed.
S133: the vehicle 100 combines the sub-compression blocks C1-1 to C1- (N-1) to form a compression block C1.
Since the nth sub-compression block has a length smaller than the length L0, the nth sub-compression block is a sub-compression block that cannot achieve "page alignment", and thus the vehicle 100 combines the sub-compression blocks C1-1 to C1- (N-1) to form the compression block C1 so that the compression block C1 can achieve page alignment (i.e., the length of the compression block C1 is an integer multiple of the length L0).
In addition, the car machine 100 may determine the value of the title portion size according to the total length of the compression blocks C1-1' to C1- (N-1), and it is understood that the size has a value of L0 x (N-1) -b.
The data in segment N is data that is uncompressed into compressed block C1, and this portion of data is referred to herein as uncompressed data D1-r of data D1 to be stored. The partial data is compressed together with the data D2 to be stored, which is acquired later by the vehicle 100 (specifically, will be described in step S160).
S134: the vehicle 100 combines the sub-compression blocks C1-1 to C1-N to form a compression block C1.
Since the length of the nth sub-compression block is equal to the length L0, the combination of the sub-compression blocks C1-1 to C1-N can achieve page alignment. Accordingly, the vehicle 100 combines the sub-compression blocks C1-1 to C1-N to form the compression block C1.
In addition, the car machine 100 may determine the value of the header portion size according to the total length of the compression blocks C1-1' to C1-N. Unlike step S133, when the length of the nth sub-compressed block is equal to the length L0, the size has a value of l0×n-b.
It is understood that when the length of the nth sub-compression block is equal to the length L0, the data in the data D1 to be stored may be all compressed into the compression block C1.
For example two, referring to fig. 11 and 12, in this example, the process of compressing the data D1 to be stored includes the steps of:
s135: all data in the data D1 to be stored is compressed to obtain compressed blocks C1-S.
Specifically, referring to fig. 12, all data in the data D1 to be stored is compressed, and the compressed result is compressed blocks C1-S'. The compressed blocks C1-S (as initial compressed blocks) can be formed by adding a header portion of length b in front of the compressed blocks C1-S'. Wherein the value of the header portion size may be determined in a subsequent step (determined after determining the length of the compressed block C1, as will be described later).
In other embodiments, the header portion may not be included in the compression block C. When the header portion is not included in the compressed block C, the length b is set to 0. At this time, the compressed blocks C1-S' obtained by compressing the data D1 to be compressed are the compressed blocks C1-S.
S136: it is determined whether the length of the compressed blocks C1-S is an integer multiple of the length L0. If yes, go to step S137; if not, step S138 is performed. In the example shown in FIG. 12, the length of the compressed blocks C1-S is not an integer multiple of L0.
S137: the compression blocks C1 to S are taken as compression blocks C1. When the length of the compressed blocks C1-S is an integer multiple of the length L0, the compressed blocks C1-S can achieve "page alignment", and thus, the compressed blocks C1-S are regarded as compressed blocks C1.
S138: the compressed block C1-S is divided into a sub-block C1-S1 (serving as a first sub-block) and a sub-block C1-S2 (serving as a second sub-block), wherein the sub-block C1-S1 is positioned at the head of the compressed block C1-S, the length of the sub-block C1-S1 is an integer multiple of L0, and the length of the sub-block C1-S2 is smaller than L0.
That is, after dividing the compressed blocks C1-S, the sub-blocks C1-S1 are compressed blocks in which "page alignment" can be achieved, and the sub-blocks C1-S2 are compressed blocks in which one "full page" is not satisfied.
S139: the compression blocks C1 to S1 are referred to as compression blocks C1. Since the compression blocks C1 to S1 are compression blocks that can realize "page alignment", the write amplification factor of the solid state disk 150 can be reduced by using them as the compression blocks C1.
In addition, the data of the data D1 to be stored corresponding to the sub-blocks C1-S2 is data that is not compressed into the compressed block C1, and this part of the data is referred to herein as uncompressed data D1-r of the data D1 to be stored. The partial data is compressed together with the data D2 to be stored, which is acquired later by the vehicle 100 (specifically, will be described in step S160).
S140: the data Di to be stored is acquired (as the i-th piece of data to be stored), where i starts from 2. In the following, i=2, i.e. the case of data D2 to be stored, will first be described.
Referring to fig. 6, after compressing the data D1 to be stored, the vehicle machine 100 continues to acquire the data D2 to be stored. The manner in which the vehicle 100 obtains the data D2 to be stored is substantially the same as the manner in which the data D1 to be stored is obtained, so the description in step S110 may be referred to, and detailed description is omitted. For example, referring to fig. 7, the vehicle 100 acquires the message Data from the road condition image sensor at time t4, and the vehicle 100 generates the Data4 to be stored according to the message Data.
S150: it is determined whether or not the sum of the uncompressed data D (i-1) -r of the data D (i-1) to be stored and the length of the data Di to be stored exceeds the length L1. If yes, go to step S170; if not, the process returns to step S150 to continue to acquire the data Di to be stored.
Assume that the length of the uncompressed Data D1-r of the Data D1 to be stored is 120KB and the length of the newly acquired Data4 to be stored is 1900KB, and therefore, the sum of the uncompressed Data D1-r of the Data D1 to be stored and the length of the Data D2 to be stored (120kb+1900kb=2020 KB) exceeds the length L1 (assumed to be 1024 KB), and therefore, the vehicle 100 proceeds to step S170.
S160: the uncompressed data D (i-1) -r of the data D (i-1) to be stored and the data Di to be stored are compressed in a page-aligned manner to obtain a compressed block Ci.
That is, the vehicle 100 combines the uncompressed data D (i-1) -r of the data D (i-1) to be stored and the data Di to be stored to form new data Di ', wherein the uncompressed data D (i-1) -r is located at the head of the new data block Di'. Thereafter, the vehicle 100 compresses the new data Di' in a page-aligned manner to obtain a compressed block Ci.
Taking i=2 as an example, the vehicle 100 combines the uncompressed data D1-r of the data D1 to be stored with the data D2 to be stored to obtain new data D2', wherein the uncompressed data D1-r is located at the head of the data block D2'. Thereafter, the vehicle 100 compresses the new data D2' in a page-aligned manner to obtain a compressed block C2.
The manner of compressing the data D2' by the page alignment manner is substantially the same as the manner of compressing the data D1 to be stored in step S130, so the description in step S130 may be referred to, and details thereof will not be repeated. It will be appreciated that the compressed block C2 may be obtained after compression of the data D2'. In some embodiments, the data D2 to be stored may have data uncompressed into the compressed block C2, which is the uncompressed data D2-r of the data D2 to be stored.
S170: it is determined whether the lengths of the compression blocks C1 to Ci are equal to or greater than the length L2 (as the second length). If yes, go to step S190 to drop the compression blocks C1 to Ci; otherwise, step S140 is executed again to continue to acquire more compressed blocks C until the total length of the compressed blocks C is above L2.
That is, in the present embodiment, instead of dropping the compressed blocks C immediately after each compressed block C is acquired, the entire length of the compressed blocks C is accumulated over the length L2, and then dropping is performed on a batch of compressed blocks C (including a plurality of compressed blocks C) together. With this arrangement, it is possible to avoid the long-term occupation of the I/O resources (e.g., the time for the processor 110 to process the I/O data, the bandwidth resources of the I/O bus, etc.) by frequent dropping of data, and to alleviate the burden on the I/O resources.
The value of the length L2 is not limited in this embodiment. In some embodiments, length L2 is positively correlated to the bandwidth of the I/O data bus. For example, the length L2 is 0.1 to 0.4 times, e.g., 0.1 times, 0.2 times, etc., the bandwidth of the I/O data bus. That is, for the car machine 100 having a strong capability of communicating with the I/O, since the quick drop of the compression block C can be achieved, the length L2 can be set to a large value to minimize the frequent occupation of the I/O resources.
Taking i=2 as an example. If the total length of the compression blocks C1 and C2 is above the length L2, step S180 is performed to reel down the compression blocks C1 and C2; otherwise, the process returns to step S140 to continue to acquire the new compressed block C3, C4, … … until the total length of the acquired compressed block C is above L2.
S180: the compressed blocks C1 to Ci are stored in the solid state disk 150 (as one example of a designated storage location).
Referring to fig. 13, according to the above steps S110 to S170, a plurality of compression blocks C (compression block C1, compression blocks C2, … …, compression block Ci, i being a positive integer of 2 or more) can be obtained, and the total length of the compression blocks C1 to Ci is L2 or more. At this time, the vehicle 100 transfers the compressed blocks C1 to Ci from the memory 120 to the solid state disk 150 to drop the compressed blocks C1 to Ci. After the car machine 100 performs the disc dropping on the compression blocks C1 to Ci, the compression blocks C1 to Ci in the memory 120 may be deleted.
In summary, the present embodiment provides a data storage method, when the accumulated length of the data to be stored in the memory 120 reaches the length L1 (first length accumulation), the data to be stored is compressed in a page alignment manner to obtain a plurality of compression blocks C (compression block C1, compression blocks C2, … …, compression block Ci); after the total length of the plurality of compression blocks C reaches L2 (second length accumulation), the car machine 100 trays the plurality of compression blocks C as a whole.
That is, in this embodiment, the data to be stored is dropped by adopting a secondary length accumulation manner. Through this setting, can have following technical effect simultaneously: (1) When the accumulated total length of the compression blocks C reaches the length L2, the vehicle machine 100 can timely drop the compression blocks C, and compared with other embodiments in which the disk dropping is controlled according to the occupancy rate of the memory 120, the method can ensure timely disk dropping of data and avoid the loss of data due to sudden power failure of the vehicle machine 100; (2) The data to be stored is dropped in a page alignment mode, so that the write amplification coefficient of the solid state disk 150 can be reduced, and the service life of the solid state disk 150 can be prolonged; (3) When the total length of the compression blocks C reaches the length L2, one or more compression blocks C are subjected to integral disc placement, so that frequent occupation of I/O resources can be avoided, and the burden on the I/O resources is reduced.
The present embodiment is an exemplary description of the technical solution of the present application, and other modifications may be made by those skilled in the art.
For example, in the present embodiment, when the total length of the compressed blocks C is accumulated to L2 or more, the vehicle 100 stores the compressed blocks C1 to Ci in the solid state disk 150. The present application is not limited thereto. In other embodiments, the vehicle 100 may also store the compressed blocks C1-Ci in a cloud server communicatively connected to the vehicle 100.
Specifically, the vehicle 100 may determine the storage locations of the compression blocks C1 to Ci according to the current communication rate K with the cloud server. In some examples, when the current communication rate is greater than or equal to the rate K0 (as the first rate), the vehicle 100 uploads the compressed blocks C1 to Ci to the cloud server. In this example, the vehicle 100 may not store the compression blocks C1 to Ci in the solid state disk 150, so as to reduce the amount of data written into the solid state disk 150 and improve the service life of the solid state disk 150; in other examples, when the current communication rate K is less than the rate K0, the vehicle 100 stores the compression blocks C1 to Ci in the solid state disk 150 to ensure that the data is stored in time. After the network condition is improved (for example, after the communication rate between the vehicle 100 and the cloud server is greater than the rate K0), the vehicle 100 uploads the compression blocks C1 to Ci to the cloud server. After the vehicle 100 uploads the compressed blocks C1 to Ci to the cloud server, the compressed blocks C1 to Ci stored in the solid state disk 150 may be deleted.
The specific value of the rate K is not limited in this embodiment. For example, the rate K may be empirically chosen to be 700mbps to 1000mbps. The current communication rate of the vehicle 100 and the cloud server can be obtained through testing. For example, the vehicle 100 may send a test message of a preset size (e.g., 1 MB) to the cloud server. After receiving the test message, the cloud server sends a reply message with a preset size (e.g., 0.5 MB) to the vehicle 100. The vehicle 100 calculates the current communication rate between the vehicle 100 and the cloud server according to the time interval (e.g., T1) from the start of sending the test message to the receipt of the reply message. For example, the current communication rate is 2× (1mb+0.5mb)/T1.
The foregoing describes a data storage method provided by some embodiments of the present application. In the above-described embodiment, when the total length of each compressed block C exceeds the length L2, the trigger car machine 100 makes a landing (hereinafter, this trigger condition is referred to as "data amount trigger condition"). When the amount of data to be stored is small, it may take a longer time to trigger the car machine 100 to drop a disc. Therefore, the present application further provides another data storage method, in which the conditions for triggering the data disc-dropping include not only the data volume triggering conditions but also the time triggering conditions (the vehicle 100 will automatically execute the data disc-dropping every set time Δt) so as to further ensure that the data is timely dropped. The following is a detailed description.
Referring to fig. 14, in some embodiments of the present application, a data storage method includes:
s210: the vehicle 100 starts a timer M at time T0 (as a stored start timing time), and the timing duration of the timer M is Δt (as a first time, for example, 2s,5 s).
The time t0 may be any time. In some embodiments, the time t0 may be a time when the vehicle 100 starts to execute the data storage method provided in the present embodiment.
S220: the vehicle machine 100 acquires data to be stored and compresses the data to be stored in a page alignment manner.
After acquiring the data to be stored, the vehicle machine 100 compresses the data to be stored in a page alignment manner. The manner of compressing the data to be stored may refer to the descriptions in steps S110 to S170, and will not be repeated. After compressing the data to be stored, the vehicle 100 may obtain a plurality of compressed blocks C.
S230: the vehicle 100 determines whether the total length of the compression block C exceeds the length L2.
After each acquisition of a new compressed block C, the vehicle 100 determines whether the total length of the currently acquired compressed block C exceeds the length L2. If yes, the vehicle 100 executes step S240 to drop the compression blocks C; if not, step S250 is performed to further determine whether the time trigger condition for the data drop is satisfied.
S240: the vehicle 100 stores each compressed block C in a designated storage location.
When the data amount trigger condition is satisfied, the vehicle machine 100 stores each compressed block C in a specified storage location. The designated storage location may be the solid state disk 150 and/or a cloud server communicatively coupled to the vehicle 100.
In some examples, when the current communication rate K of the vehicle 100 and the cloud server is greater than or equal to the rate K0 (as the first rate), the vehicle 100 uploads each compressed block C to the cloud server; in other examples, when the current communication rate K between the vehicle 100 and the cloud server is less than the rate K0, the vehicle 100 stores each compressed block C in the solid state disk 150 to ensure that the data is stored in time.
After storing each compressed block C, the vehicle 100 restarts the timer M (i.e., performs step S270) so that the timer M restarts counting.
S250: the vehicle 100 determines whether the timing period of the timer M expires. If the timing period of the timer M expires, the time trigger condition indicating that the data is dropped is satisfied (i.e., the difference between the current time and the time T0 is at least Δt), and the vehicle 100 executes step S260 to drop the data to be stored; otherwise, the vehicle 100 returns to execute step S220 to continue to acquire the data to be stored.
S260: the vehicle 100 stores each compressed block C and the additional compressed block in a designated storage location.
That is, when the time trigger condition of the data drop is satisfied, the vehicle machine 100 stores not only each compressed block C but also a portion where the data to be stored is not compressed into the compressed block C (uncompressed data called data to be stored). Specifically, the vehicle machine 100 compresses uncompressed data of the data to be stored to generate a compressed block a (referred to as an "additional compressed block"). Then, the vehicle 100 stores each compressed block C together with the compressed block a. It will be appreciated that when the time trigger condition is met, the truck 100 may not be dropped in a "page-aligned" manner (i.e., the total length of compression block C and compression block a may not be an integer multiple of length L0).
The car machine 100 may store the compressed block C and the compressed block a in the designated storage locations. The designated storage location may be the solid state disk 150 and/or a cloud server communicatively coupled to the vehicle 100. The specific configuration of the designated storage location is substantially the same as that of step S240, so reference may be made to the description of step S240, and details thereof will not be repeated.
S270: the car machine 100 restarts the timer M. After each storage of the data (e.g., after performing steps S250, S260), the vehicle 100 restarts the timer M to start the next storage timing period.
In summary, the present embodiment provides a data storage method, which includes two triggering conditions of data landing, namely a data volume triggering condition and a time triggering condition. When either of the two trigger conditions is satisfied, the car machine executes a tray-dropping action. Therefore, the embodiment can further ensure the timely landing of the data and avoid the loss of the data caused by the sudden power failure of the vehicle.
The value of the timing duration Δt of the timer M is not limited in this embodiment. In some embodiments, the timing duration ΔT is empirically determined, e.g., the timing duration ΔT is determined to be 1 s-5 s (e.g., 2 s). In this embodiment, every interval of 2s triggers an automatic landing of data to be stored once; in other embodiments, to make the tray drop as "page-aligned" as possible, the value of the timing duration Δt is associated with the length L2. Specifically, the length L2 is as smaller than the product of the I/O data bus bandwidth and the timing time period t as possible, for example, the length L2 is 0.1 to 0.2 times the product of the I/O data bus bandwidth and the timing time period t.
Referring now to fig. 15, shown is a block diagram of an electronic device 400 in accordance with one embodiment of the present application. The electronic device 400 may include one or more processors 401 coupled to a controller hub 403. For at least one embodiment, the controller hub 403 communicates with the processor 401 via a multi-drop Bus such as a Front Side Bus (FSB), a point-to-point interface such as a Quick Path Interconnect (QPI), or similar connection 406. The processor 401 executes instructions that control the general type of data processing operations. In one embodiment, controller Hub 403 includes, but is not limited to, a Graphics Memory Controller Hub (GMCH) (not shown) and an Input Output Hub (IOH) (which may be on separate chips) (not shown), where the GMCH includes memory and Graphics controllers and is coupled to the IOH.
The electronic device 400 may also include a coprocessor 402 and memory 404 coupled to a controller hub 403. Alternatively, one or both of the memory and GMCH may be integrated within the processor (as described herein), with the memory 404 and co-processor 402 coupled directly to the processor 401 and the controller hub 403, the controller hub 403 being in a single chip with the IOH.
Memory 404 may be, for example, dynamic random access memory (DRAM, dynamic Random Access Memory), phase change memory (PCM, phase Change Memory), or a combination of both. One or more tangible, non-transitory computer-readable media for storing data and/or instructions may be included in memory 404. The computer-readable storage medium has stored therein instructions, and in particular, temporary and permanent copies of the instructions. The instructions may include: instructions that when executed by at least one of the processors cause the electronic device 400 to implement the methods shown in fig. 6, 9, 11, 14. When executed on a computer, the instructions cause the computer to perform the data storage methods disclosed in embodiments of the present application.
In one embodiment, coprocessor 402 is a special-purpose processor, such as, for example, a high-throughput MIC (Many Integrated Core, integrated many-core) processor, network or communication processor, compression engine, graphics processor, GPGPU (General-purpose computing on a graphics processing unit), embedded processor, or the like. Optional properties of coprocessor 402 are shown in dashed lines in fig. 15.
In one embodiment, the electronic device 400 may further include a network interface (NIC, network Interface Controller) 406. The network interface 406 may include a transceiver to provide a radio interface for the electronic device 400 to communicate with any other suitable device (e.g., front end module, antenna, etc.). In various embodiments, the network interface 406 may be integrated with other components of the electronic device 400. The network interface 406 may implement the functions of the communication units in the above-described embodiments.
Electronic device 400 may further include an Input/Output (I/O) device 405.I/O405 may include: a user interface, the design enabling a user to interact with the electronic device 400; the design of the peripheral component interface enables the peripheral component to also interact with the electronic device 400; and/or sensors designed to determine environmental conditions and/or location information associated with the electronic device 400.
It is noted that fig. 15 is merely exemplary. That is, although fig. 15 shows that the electronic apparatus 400 includes a plurality of devices such as the processor 401, the controller hub 403, and the memory 404, in practical applications, the apparatus using the methods of the present application may include only a part of the devices of the electronic apparatus 400, for example, may include only the processor 401 and the network interface 406. The nature of the alternative device is shown in dashed lines in fig. 15.
Referring now to fig. 16, shown is a block diagram of a SoC (System on Chip) 500 in accordance with an embodiment of the present application. In fig. 16, similar parts have the same reference numerals. In addition, the dashed box is an optional feature of a more advanced SoC. In fig. 16, the SoC500 includes: an interconnect unit 550 coupled to the processor 510; a system agent unit 580; a bus controller unit 590; an integrated memory controller unit 540; a set or one or more coprocessors 520 which may include integrated graphics logic, an image processor, an audio processor, and a video processor; a Static Random-Access Memory (SRAM) unit 530; a direct memory access (DMA, direct Memory Access) unit 560. In one embodiment, coprocessor 520 includes a special-purpose processor, such as, for example, a network or communication processor, compression engine, GPGPU (General-purpose computing on graphics processing units, general purpose computing on a graphics processing unit), high-throughput MIC processor, embedded processor, or the like.
Static Random Access Memory (SRAM) unit 530 may include one or more tangible, non-transitory computer-readable media for storing data and/or instructions. The computer-readable storage medium has stored therein instructions, and in particular, temporary and permanent copies of the instructions. The instructions may include: instructions that when executed by at least one of the processors cause the SoC to implement the methods shown in fig. 6, 9, 11, 14. When executed on a computer, the instructions cause the computer to perform the data storage methods disclosed in embodiments of the present application.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, in the present embodiment, the value of each data range includes an end value. For example, a=10 to 50, meaning that a may be 10 or 50.
The method embodiments of the present application may be implemented in software, magnetic elements, firmware, etc.
Program code may be applied to input instructions to perform the functions described herein and generate output information. The output information may be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (Digital Signal Processor, DSP), microcontroller, application Specific Integrated Circuit (ASIC), or microprocessor.
The program code may be implemented in a high level procedural or object oriented programming language to communicate with a processing system. Program code may also be implemented in assembly or machine language, if desired. Indeed, the mechanisms described herein are not limited in scope to any particular programming language. In either case, the language may be a compiled or interpreted language.
One or more aspects of at least one embodiment may be implemented by representative instructions stored on a computer readable storage medium, which represent various logic in a processor, which when read by a machine, cause the machine to fabricate logic to perform the techniques described herein. These representations, referred to as "intellectual property (Intellectual Property, IP) cores," may be stored on a tangible computer-readable storage medium and provided to a plurality of customers or production facilities for loading into the manufacturing machines that actually manufacture the logic or processor.
In some cases, an instruction converter may be used to convert instructions from a source instruction set to a target instruction set. For example, the instruction converter may transform (e.g., using a static binary transform, a dynamic binary transform including dynamic compilation), morph, emulate, or otherwise convert an instruction into one or more other instructions to be processed by the core. The instruction converter may be implemented in software, hardware, firmware, or a combination thereof. The instruction converter may be on-processor, off-processor, or partially on-processor and partially off-processor.

Claims (10)

1. A data storage method for an electronic device, the electronic device comprising a storage medium comprising a plurality of storage pages; characterized in that the method comprises:
Acquiring the 1 st section of data to be stored, and determining that the length of the 1 st section of data to be stored is greater than or equal to a first length;
compressing at least part of the data of the 1 st segment of data to be stored in a page alignment mode to obtain a 1 st compression block;
acquiring the data to be stored in the ith section, determining that the sum of uncompressed data of the data to be stored in the ith-1 section and the length of the data to be stored in the ith section is greater than or equal to the first length, and i is a positive integer greater than or equal to 2;
compressing at least part of the data to be stored in the ith section and the uncompressed data of the data to be stored in the (i-1) th section in a page alignment mode to obtain an ith compressed block; the page alignment mode is that the length of each compression block is an integer multiple of a first storage length, the first storage length is D times of the storage capacity of each storage page, and D is a positive integer;
determining that a preset storage condition is met, and storing data to be stored in the storage medium;
wherein the determining that the preset storage condition is satisfied, storing the data to be stored to the designated storage location includes: determining that the sum of the lengths of the 1 st to i th compressed blocks is greater than or equal to a second length, and storing the 1 st to i th compressed blocks to the storage medium.
2. The method of claim 1, wherein compressing at least a portion of the segment 1 data to be stored in a page aligned manner to obtain a 1 st compressed block comprises:
sequentially compressing N continuous fragments of the data to be stored in the 1 st section from the head of the data to be stored in the 1 st section one by one to obtain N sub-compression blocks, wherein N is a positive integer above 2, and the lengths of the 1 st to N-1 st sub-compression blocks are the first storage length;
comparing the length of the Nth sub-compression block with the first storage length, and if the length of the Nth sub-compression block is smaller than the first storage length, taking the combination of the 1 st to N-1 st sub-compression blocks as the 1 st compression block; and if the length of the Nth sub-compression block is equal to the first storage length, combining the 1 st to the Nth sub-compression blocks into the 1 st compression block.
3. The method of claim 1, wherein compressing at least a portion of the segment 1 data to be stored in a page aligned manner to obtain a 1 st compressed block comprises:
compressing all data in the data to be stored in the 1 st section to obtain an initial compression block;
Judging whether the length of the initial compression block is an integral multiple of the first storage length, if so, taking the initial compression block as the 1 st compression block; if not, dividing the initial compression block into a first sub-block and a second sub-block, and taking the first sub-block as the 1 st compression block, wherein the first sub-block is positioned at the head of the initial compression block, the length of the first sub-block is an integer multiple of the first storage length, and the length of the second sub-block is smaller than the first storage length.
4. A method according to any one of claims 1 to 3, wherein the 1 st compressed block includes a header portion and a content portion, the header portion having a predetermined fixed length, the content portion including compressed data of the at least part of the 1 st data to be stored.
5. The method of any one of claims 1-4, wherein the storage medium is a solid state disk; wherein d=5 to P, and P is the number of storage pages included in each storage block of the solid state disk.
6. The method of any of claims 1-5, wherein the first length is 0.1-0.5 times a bandwidth of an I/O data bus of the electronic device; and/or the number of the groups of groups,
The second length is 0.1-0.4 times of the bandwidth of the I/O data bus of the electronic equipment.
7. The method according to any one of claims 1 to 6, wherein the determining that a preset storage condition is satisfied, storing data to be stored to the storage medium, further comprises:
and determining that the difference between the current time and the preset storage starting timing time is more than a first time length, and storing the 1 st to i th compression blocks and additional compression blocks into the storage medium, wherein the additional compression blocks are compression blocks obtained after the data to be stored, which are not compressed into the compression blocks, are compressed.
8. The method of claim 7, wherein the second length is 0.1-0.2 times a product of a bandwidth of an I/O data bus of the electronic device and the first duration.
9. An electronic device, comprising:
a memory for storing instructions for execution by one or more processors of the electronic device;
a processor, which when executing the instructions in the memory, is operable to perform the method of any of claims 1 to 8.
10. A computer readable storage medium having stored thereon instructions which, when executed on a computer, cause the computer to perform the method of any of claims 1 to 8.
CN202210837667.1A 2022-07-15 2022-07-15 Data storage method, electronic device and storage medium Pending CN117435124A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202210837667.1A CN117435124A (en) 2022-07-15 2022-07-15 Data storage method, electronic device and storage medium
PCT/CN2023/107237 WO2024012528A1 (en) 2022-07-15 2023-07-13 Data storage method, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210837667.1A CN117435124A (en) 2022-07-15 2022-07-15 Data storage method, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN117435124A true CN117435124A (en) 2024-01-23

Family

ID=89535630

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210837667.1A Pending CN117435124A (en) 2022-07-15 2022-07-15 Data storage method, electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN117435124A (en)
WO (1) WO2024012528A1 (en)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107153647B (en) * 2016-03-02 2021-12-07 北京字节跳动网络技术有限公司 Method, apparatus, system and computer program product for data compression
CN109690681B (en) * 2016-06-24 2021-08-31 华为技术有限公司 Data processing method, storage device, solid state disk and storage system
CN110389723A (en) * 2019-07-22 2019-10-29 广东美的制冷设备有限公司 Storage method, device, air conditioner and the storage medium of data
CN113129943A (en) * 2019-12-30 2021-07-16 深圳大普微电子科技有限公司 Data operation method based on flash memory data page storage structure and solid state disk
CN113176859B (en) * 2021-05-24 2022-11-08 锐掣(杭州)科技有限公司 Data storage method and device

Also Published As

Publication number Publication date
WO2024012528A1 (en) 2024-01-18

Similar Documents

Publication Publication Date Title
KR101745456B1 (en) Ecu for transmitting large data in hil test environment, system including the same and method thereof
CN102609361B (en) Method and device for transferring storage data of virtual machine
CN109726163B (en) SPI-based communication system, method, equipment and storage medium
CN109802684B (en) Method and device for data compression
CN102521174B (en) In a kind of embedded system, data acquisition stores the method with transmission
US20100191992A1 (en) Wireless communication apparatus and power management method for the same
CN110727608A (en) Log data storage method, electronic equipment and storage medium
CN110431540B (en) Method and apparatus for copying data pages in an unmanaged flash memory device
CN115269455A (en) Disk data read-write control method and device based on FPGA and storage terminal
CN111694766B (en) CAN data acquisition method and device
CN117435124A (en) Data storage method, electronic device and storage medium
CN108616598B (en) Data synchronization method and device and distributed storage system
CN108228476B (en) Data acquisition method and device
CN115809071A (en) Software upgrading method, device, system, equipment and storage medium
CN112346660B (en) Data storage method and device, and data reading method and device
CN111800248B (en) Communication method and device based on virtual carrier data mode
CN108037942B (en) Adaptive data recovery and update method and device for embedded equipment
CN103809579A (en) Method for extracting vehicle state information from center
JP3914398B2 (en) IC card reader / writer communication method
EP3441869A1 (en) Storage controller, storage device, and write control method
US20240080702A1 (en) Communication control device, system, and method
CN105631965A (en) Vehicle-mounted WTB message recorder
CN104202124A (en) Erp (enterprise resource planning) data package communication method
CN113268375B (en) Reset method of vehicle-mounted terminal, related equipment and storage medium
CN110489359B (en) Data transmission control method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination