Memory data compression method and device, and electronic device

By dividing memory data into data blocks and adjusting the compression speed according to the compression rate of different data types, the problem of slow data compression speed under tight memory resources is solved, and system performance and memory utilization are improved.

CN114629500BActive Publication Date: 2025-01-07GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210240401.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-10
Publication Date
2025-01-07
Estimated Expiration
2042-03-10

AI Technical Summary

Technical Problem

In the case of tight memory resources, the existing technology cannot effectively and quickly compress memory data, resulting in reduced system performance and further tight memory resources.

Method used

By dividing the memory data to be compressed into data blocks and dynamically adjusting the compression speed in real time according to the compression rate of different data types, rapid compression and decompression can be achieved.

Benefits of technology

When memory resources are tight, the compression speed of memory data and system performance are improved, the memory usage is reduced, and the system fluency and performance are ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114629500B_ABST
    Figure CN114629500B_ABST
Patent Text Reader

Abstract

This application discloses a memory data compression method, apparatus, and electronic device. The method includes: obtaining memory data to be compressed, where the memory data to be compressed consists of data of different data types; dividing the memory data to be compressed into N data blocks, where N is a positive integer; when compressing the i-th data block among the N data blocks, determining the compression rate under the data type to which the i-th data block belongs to obtain a first compression rate, where 1 ≤ i < N; adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression rate, so as to, in the case of tight (or limited) memory resources, achieve real-time dynamic adjustment of the compression speed according to the compression rates of data blocks of different data types, achieve a large increase in compression speed with a small loss of compression rate, and ensure that the occupancy rate of memory resources is within a reasonable range to ensure the good performance and smoothness of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a memory data compression method and device, and an electronic device. Background Art

[0002] During the reading and writing of memory data, when memory resources are tight (or limited), the operating system usually writes part of the memory data to the disk. Therefore, when the operating system needs to call this part of the memory data, it needs to be reloaded from the disk to the memory. Compared with calling the memory data directly from the memory, the method of loading from the disk to the memory will lead to problems such as slow memory data calling.

[0003] In order to avoid problems such as slow memory data calls when memory resources are tight (or limited), a memory compression algorithm can be used to compress part of the memory data to reduce memory usage. Then, when this part of the memory data is needed, it is decompressed by the memory compression algorithm and re-acquired. Therefore, when memory resources are tight (or limited), compressing memory data can effectively reduce the memory resource usage and improve system performance. Summary of the invention

[0004] The present application provides a memory data compression method and device, and an electronic device, so as to dynamically adjust the compression speed of data blocks in real time according to the compression rates of data blocks of different data types when memory resources are tight (or limited), so as to achieve the possibility of obtaining a larger compression speed improvement with a smaller compression rate loss, achieve the possibility of rapid compression of memory data when memory resources are tight (or limited), increase the practicality when memory resources are tight (or limited), and ensure that the occupancy rate of memory resources is within a reasonable range to ensure the goodness and smoothness of system performance.

[0005] In a first aspect, a memory data compression method of the present application comprises:

[0006] Acquire memory data to be compressed, wherein the memory data to be compressed is composed of data of different data types;

[0007] Divide the memory data to be compressed into N data blocks, where N is a positive integer;

[0008] When compressing an i-th data block among the N data blocks, determining a compression ratio of a data type to which the i-th data block belongs to obtain a first compression ratio, 1≤i <N;

[0009] According to the first compression rate, a first compression speed required for compressing the (i+1)th data block among the N data blocks is adjusted.

[0010] It can be seen that the present application can divide the memory data to be compressed into blocks to obtain N data blocks, and compress the N data blocks in blocks in turn. When compressing the i-th data block among the N data blocks, determine the compression rate under the data type to which the i-th data block belongs to obtain a first compression rate, and adjust the first compression speed required for compressing the i+1-th data block among the N data blocks according to the first compression rate, so that in the case of tight (or limited) memory resources, the compression speed of the data blocks can be adjusted in real time and dynamically according to the compression rate of data blocks of different data types, which is conducive to achieving the possibility of obtaining a larger compression speed increase with a smaller compression rate loss, achieving the possibility of rapid compression of memory data under tight (or limited) memory resources, increasing the practicality under tight (or limited) memory resources, and ensuring that the occupancy rate of memory resources is within a reasonable range to ensure the goodness and fluency of system performance.

[0011] In a second aspect, a memory data compression device of the present application includes:

[0012] An acquisition unit, used for acquiring memory data to be compressed, wherein the memory data to be compressed is composed of data of different data types;

[0013] A block division unit, used for dividing the memory data to be compressed into N data blocks, where N is a positive integer;

[0014] A determining unit is configured to determine, when compressing an i-th data block among the N data blocks, a compression ratio of a data type to which the i-th data block belongs to obtain a first compression ratio, 1≤i <N;

[0015] An adjusting unit is used to adjust a first compression speed required for compressing the (i+1)th data block among the N data blocks according to the first compression rate.

[0016] It can be seen that the memory data compression device of the present application can divide the memory data to be compressed into blocks to obtain N data blocks, and compress the N data blocks in blocks in turn. When compressing the i-th data block among the N data blocks, determine the compression rate under the data type to which the i-th data block belongs to obtain a first compression rate, and adjust the first compression speed required for compressing the i+1-th data block among the N data blocks according to the first compression rate, so that when memory resources are tight (or limited), the compression speed of the data blocks can be adjusted in real time and dynamically according to the compression rates of data blocks of different data types, which is conducive to achieving the possibility of obtaining a larger compression speed improvement with a smaller compression rate loss, achieving the possibility of rapid compression of memory data when memory resources are tight (or limited), increasing the practicality when memory resources are tight (or limited), and ensuring that the occupancy rate of memory resources is within a reasonable range to ensure the goodness and fluency of system performance.

[0017] The third aspect is an electronic device of the present application, comprising a processor, a memory, and a computer program or instructions stored in the memory, wherein the processor executes the computer program or instructions to implement the steps in the method designed in the first aspect.

[0018] The fourth aspect is a computer-readable storage medium of the present application, wherein the computer-readable storage medium stores a computer program or instructions, and when the computer program or instructions are executed by a processor, the steps in the method designed in the first aspect are implemented.

[0019] The fifth aspect is a computer program product of the present application, comprising a computer program or instructions, wherein the computer program or instructions, when executed by a processor, implement the steps in the method designed in the first aspect above.

[0020] The beneficial effects brought about by the technical solutions of the third to fifth aspects can be referred to the technical effects brought about by the technical solution of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0022] Figure 1 It is a flowchart of a memory data compression method according to an embodiment of the present application;

[0023] Figure 2 It is a flowchart of an improved LZ4 compression algorithm according to an embodiment of the present application;

[0024] Figure 3It is a flowchart of an improved LSTD compression algorithm according to an embodiment of the present application;

[0025] Figure 4 It is a block diagram of the functional units of a memory data compression device according to an embodiment of the present application;

[0026] Figure 5 It is a structural schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0027] In order to better understand the technical solution of the present application by those skilled in the art, the technical solution in the embodiments of the present application is described below in conjunction with the drawings in the embodiments of the present application. It is obvious that the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. With respect to the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0028] It should be understood that the terms "first", "second", etc. involved in the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, software, product, or device that includes a series of steps or units is not limited to the listed steps or units, but also includes steps or units that are not listed, or also includes other steps or units inherent to these processes, methods, products, or devices.

[0029] The "embodiment" involved in the embodiments of the present application means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0030] The "and / or" in the embodiments of the present application describes the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. Among them, A and B can be singular or plural. The character " / " can indicate that the previous and next associated objects are in an "or" relationship. In addition, the symbol " / " can also represent a division sign, that is, performing a division operation.

[0031] In the embodiments of the present application, "at least one item" or similar expressions refer to any combination of these items, including any combination of single items or plural items, and refer to one or more, and multiple refers to two or more. For example, at least one item of a, b or c can represent the following seven situations: a, b, c, a and b, a and c, b and c, a, b and c. Among them, each of a, b, and c can be an element or a set containing one or more elements.

[0032] In order to avoid problems such as slow memory data calls when memory resources are tight (or limited), a memory compression algorithm can be used to compress part of the memory data to reduce memory usage. Then, when this part of the memory data is needed, it is decompressed by the memory compression algorithm to retrieve this part of the memory data. Therefore, when memory resources are tight (or limited), by compressing the memory data, the memory resource usage can be effectively reduced to improve system performance (such as system fluency).

[0033] In the memory compression algorithm, the data compression rate and data compression speed are two important measurement indicators. Among them, there is a certain correlation between the data compression rate and the data compression speed. For example, if the data compression rate increases, the data compression speed may decrease; if the data compression rate decreases, the data compression speed may increase.

[0034] In addition, when memory resources are tight (or limited), the memory compression algorithm may experience a slower compression speed due to the tight (or limited) memory resources, and may be unable to quickly compress memory data, quickly recycle memory resources, and effectively reduce the occupancy rate of memory resources, thereby causing further tension in memory resources and further reducing system performance (such as system fluency).

[0035] The present application analyzes the memory data to find out that the memory data is not composed of a single type of data, but is coupled (or combined) by data of different data types, and the compressibility of data of different data types (i.e., the compression rate of the data) may be different.

[0036] Currently, the compression speed of data in the memory compression algorithm may be fixed and cannot be dynamically adjusted in real time according to the compressibility of data of different data types (ie, the compression rate of the data).

[0037] Based on this, the present application can set the data block size in the memory data compression process, divide the memory data to be compressed into blocks according to the data block size, compress the blocks in sequence according to the data block method, calculate the compression rate of data blocks of different data types, and dynamically adjust the compression speed of the data blocks in real time according to the compression rate of data blocks of different data types.

[0038] Therefore, when memory resources are tight (or limited), the compression speed of data blocks is adjusted dynamically in real time according to the compression rates of data blocks of different data types, which is conducive to achieving the possibility of obtaining a larger compression speed with a smaller compression rate loss, achieving the possibility of rapid compression of memory data when memory resources are tight (or limited), increasing practicality when memory resources are tight (or limited), and ensuring that the occupancy rate of memory resources is within a reasonable range to ensure the good performance and smoothness of the system.

[0039] The technical solutions and related concepts involved in the embodiments of the present application are described in detail below.

[0040] 1. Electronic equipment

[0041] The electronic device of the embodiment of the present application may be a handheld device, a vehicle-mounted device, a wearable device, an augmented reality (AR) device, a virtual reality (VR) device, a projection device, a projector, or other devices connected to a wireless modem, or may be various specific forms of user equipment (UE), terminal device, terminal, mobile terminal, mobile phone, smart screen, smart TV, smart watch, laptop computer, smart speaker, camera, game controller, microphone, station (STA), access point (AP), mobile station (MS), personal digital assistant (PDA), personal computer (PC) or relay device, etc.

[0042] For example, the electronic device may be a wearable device. The wearable device may also be referred to as an intelligent wearable device, which is a general term for intelligent devices that use wearable technology to intelligently design and develop daily wearables, such as smart glasses, smart gloves, smart watches, smart bracelets for monitoring various specific features, smart jewelry, etc. The wearable device is a portable device that can be worn directly on the body or integrated into the user's clothing or accessories. The wearable device can be equipped with not only a dedicated hardware architecture, but also a dedicated software architecture for data interaction, cloud interaction, etc. The wearable intelligent device can achieve complete or partial functions without relying on other intelligent devices.

[0043] 1) Example of hardware structure of electronic equipment

[0044] Exemplarily, the hardware structure of the electronic device may include a processor, a sensor component, a display component, a camera component, an input driver, and the like.

[0045] ①Processor

[0046] In an embodiment of the present application, the electronic device may include a processor.

[0047] In some possible implementations, the processor can be used to run or load an operating system, which may be an Android operating system, an RTOS (real-time operating system) operating system, a UNIX operating system, a Linux operating system, a DOS operating system, a Windows operating system, a Mac operating system, etc.

[0048] In some possible implementations, the processor can be viewed as a complete system on chip (SOC).

[0049] In some possible implementations, the processor may include one or more processing units. For example, the processor may include at least one of a central processing unit (CPU), an application processor (AP), a microcontroller unit (MCU), a single chip microcomputer (SCM), a single chip microcomputer, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a digital signal processor (DSP), a field programmable gate array (FPGA), an application-specific integrated circuit (ASIC), a baseband processor, a neural network processing unit (NPU), etc. Among them, different processing units may be separated or integrated together.

[0050] In some possible implementations, a memory may also be provided in the processor for storing instructions and data.

[0051] For example, the processor may call a program stored in the memory to run an operating system.

[0052] For another example, the memory in the processor can store or cache instructions that the processor has just used or circulated. If the processor needs to use the instruction or data again, it can be directly called from the memory, thereby avoiding repeated access, reducing the waiting time of the processor and improving system efficiency.

[0053] For another example, the memory in the processor can also store or cache data, and synchronize or transmit the data to other processors for execution. The memory in the processor can be a high-speed cache memory.

[0054] In some possible implementations, the processor may include one or more communication interfaces, wherein the communication interface may include at least one of a serial peripheral interface (SPI), an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, a universal serial bus (USB) interface, and the like.

[0055] ②Sensor components

[0056] In an embodiment of the present application, the electronic device may include a sensing component.

[0057] In some possible implementations, the sensing component may be a sensor.

[0058] For example, the sensing component may include an inertial sensor (such as an inertial motion unit (IMU)), a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, an ultra-wideband UWB sensor, a near-field communication NFC sensor, a laser sensor and / or a visible light sensor, etc.

[0059] ③Display components

[0060] In an embodiment of the present application, an electronic device may include a display component. The display component may be used to display a user interface, user interface elements and features, user-selectable controls, various displayable objects, and the like.

[0061] In some possible implementations, the display component may be a display screen, a touch screen, etc.

[0062] For example, the display component may include a display panel, wherein the display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a quantum dot light-emitting diode (QLED), etc.

[0063] It should be noted that the electronic device can realize the display function through a GPU, a display component, and a processor. Among them, the GPU can be used to perform mathematical and geometric calculations and perform graphic rendering. In addition, the GPU can be a microprocessor for image processing and connect the display component and the processor. The processor may include one or more GPUs, which execute program instructions to generate or change display information.

[0064] ④Camera component

[0065] In an embodiment of the present application, the electronic device may include a camera component.

[0066] The camera component may be a camera or a camera module, which is used to capture (shoot / scan, etc.) static / dynamic images or videos.

[0067] The camera assembly may include a lens, a photosensitive element, etc., and the photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.

[0068] Therefore, the object can generate an optical image through the lens and project it onto the photosensitive element. The photosensitive element can convert the light signal in the optical image into an electrical signal, and then transmit the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format.

[0069] It should be noted that electronic devices can realize functions such as capturing (shooting / scanning, etc.) images through ISP, DSP, camera components, video codecs, GPU, display components and processors.

[0070] ISP can be used to process the data fed back by the camera component. For example, when taking a photo, the shutter is opened first, and then the light is transmitted through the lens of the camera component to the photosensitive element of the camera component to convert the light signal into an electrical signal, and finally the electrical signal is transmitted to the ISP through the photosensitive element to be converted into a digital image.

[0071] In addition, ISP can also perform algorithm optimization on image noise, brightness, and skin color.

[0072] ISP can also optimize parameters such as exposure and color temperature of the shooting scene.

[0073] In some possible examples, the ISP and / or DSP may be provided in the camera assembly.

[0074] ⑤Input driver

[0075] In an embodiment of the present application, the electronic device may include an input driver to process various inputs from a user operating the electronic device.

[0076] For example, when the display screen is a touch screen, the input driver can be operated to detect and process various touch inputs and / or touch events. Among them, the touch input or touch event on the touch screen can simultaneously indicate the area of ​​interest and start scanning the object (such as a document). The object can be displayed on the touch screen as a preview of the image to be scanned, and the touch event at a specific location on the touch screen indicates the image that should be scanned.

[0077] 2) Example of hardware and software structure of electronic equipment

[0078] Exemplarily, the hardware and software structure of the electronic device may include a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer.

[0079] In some possible implementations, the hardware layer may include hardware such as a processor, a memory management unit (MMU), and a memory (also called storage).

[0080] In some possible implementations, the memory can be used to store software programs / computer programs / computer instructions / data, etc., and can include a program storage area and a data storage area. Among them, the program storage area can be used to store the software programs / computer programs / computer instructions required for the operating system or at least one function, and the software programs / computer programs / computer instructions required for the at least one function can be used to execute the technical solutions involved in the embodiments of the present application; the data storage area can be used to store the data involved in the embodiments of the present application, etc.

[0081] In some possible implementations, the operating system may be any one or more computer operating systems that implement business processing through processes, such as Linux operating system, Unix operating system, Android operating system, iOS operating system, or Windows operating system.

[0082] It should be noted that the embodiments of the present application do not specifically limit the specific structure of the execution subject of the memory data compression method, as long as it can be processed by running a computer program or instruction that records the method provided by the embodiments of the present application, and according to the method provided by the embodiments of the present application. For example, the execution subject of the method provided by the embodiments of the present application can be an electronic device, or a processor / device / module / unit in an electronic device that can call and execute a computer program or instruction, and there is no specific limitation on this.

[0083] 2. Memory Compression Algorithm

[0084] In an embodiment of the present application, the memory compression algorithm may include an LZ77 compression algorithm, an LZ4 compression algorithm, a ZSTD compression algorithm, a SNAPPY compression algorithm, an LZO compression algorithm, a DEFLATE compression algorithm, and the like.

[0085] The LZ4 compression algorithm and the ZSTD compression algorithm are introduced below.

[0086] 1) LZ4 compression algorithm

[0087] The LZ4 compression algorithm is currently a more commonly used compression algorithm. The LZ4 compression algorithm is a compression algorithm that pursues extreme compression and decompression speed. It has the advantages of fast compression speed, fast decompression speed, and simple compression format. It is widely used in Linux operating systems and Android operating systems.

[0088] Compared with compression algorithms such as LZO, DEFLATE, and ZSTD, the compression rate of the LZ4 compression algorithm is relatively low.

[0089] The implementation concept of the LZ4 compression algorithm belongs to the traditional dictionary compression algorithm. In which, the dictionary compression algorithm encodes the content to be compressed according to the encoding format of literals, literal length, offset distance, and match length to complete the compression.

[0090] It should be noted that the literal can represent incompressible content (or incompressible part); the literal length can represent the length of the incompressible content (or incompressible part); the offset distance can represent the distance between the content to be compressed and the matching item corresponding to the content to be compressed; and the matching length can represent the length of the matching item corresponding to the content to be compressed.

[0091] 2) ZSTD compression algorithm

[0092] The ZSTD compression algorithm is an open source lossless compression algorithm developed by Facebook and is widely used in Linux operating systems and Android platform operating systems.

[0093] Compared with compression algorithms such as LZ4, the ZSTD compression algorithm provides a very strong compromise between compression speed, decompression speed, and compression ratio. It has a very high compression ratio at a small loss of compression speed and decompression speed.

[0094] The ZSTD compression algorithm is a hybrid compression algorithm, which uses a finite state entropy coding algorithm based on a dictionary compression algorithm to achieve fast compression.

[0095] 3. Memory data compression method

[0096] In an embodiment of the present application, by setting the data block size in the memory data compression process, the memory data to be compressed is divided into blocks according to the data block size and compressed in blocks, the compression rate of data blocks of different data types is calculated, and the compression speed of the data blocks is dynamically adjusted in real time according to the compression rate of data blocks of different data types.

[0097] The following is a detailed description of the relevant concepts involved in the memory data compression method of the embodiment of the present application, the beneficial effects that can be achieved, etc.

[0098] 1) Memory data to be compressed

[0099] In the embodiment of the present application, memory data may be data stored in the memory, that is, memory data is also a type of data.

[0100] It should be noted that the memory of the embodiment of the present application may be a storage device, which may be used to store software programs / computer programs / computer instructions / data, etc., and may include a program storage area and a data storage area. The program storage area may be used to store software programs / computer programs / computer instructions, etc. required for an operating system or at least one function, and the software programs / computer programs / computer instructions required for the at least one function may be used to execute the technical solutions involved in the embodiment of the present application; the data storage area may be used to store data involved in the embodiment of the present application, etc.

[0101] In the embodiment of the present application, the memory data to be compressed can be understood as the memory data that needs to be compressed but has not been compressed in the embodiment of the present application.

[0102] 2) Data Type

[0103] In the embodiment of the present application, the data type can be used to represent data, wherein the data type may include numbers, text, video, audio, image, animation, etc.

[0104] Therefore, in the embodiment of the present application, the memory data to be compressed may be a combination (or coupling) of data of different data types. For example, the memory data to be compressed may include video data, text data, image data, etc.

[0105] 3) Data Block

[0106] In the embodiment of the present application, a data block can be understood as a group of data obtained by dividing the memory data to be compressed according to a certain data block size, that is, a data block is also a type of data.

[0107] For example, the memory data to be compressed is divided into data blocks of 4 KB in size to obtain multiple groups of data with a size of 4 KB.

[0108] It should be noted that if the size of the memory data to be compressed is larger than the data block size, the memory data to be compressed can be divided; if the size of the memory data to be compressed is larger than the data block size, the memory data to be compressed does not need to be divided. For example, if the size of the memory data to be compressed is 3KB and the data block size is 4KB, no division is required.

[0109] Based on this, the embodiment of the present application can divide the memory data to be compressed into N data blocks, where N is a positive integer, wherein the N data blocks include the 1st data block, ..., the i-th data block, ..., the N-th data block.

[0110] In addition, the data blocks also have corresponding data types. Therefore, the N data blocks may have data blocks of different data types. For example, the data type corresponding to some data blocks is video, while the data type corresponding to other data blocks is image.

[0111] 4) Content to be compressed in the data block

[0112] It should be noted that when compressing a data block, the embodiment of the present application divides the data block into multiple contents to be compressed using the contents to be compressed in the data block as the granularity. In other words, the contents to be compressed can be part of the data block, that is, the contents to be compressed are also data.

[0113] For example, if the data block is a string of abcdef, a single symbol (such as a / b / c / d / e / f) may be the content to be compressed, or multiple symbols (such as ab / cd / ef / abc / def / abcd, etc.) may be the content to be compressed.

[0114] 5) Data

[0115] For the convenience of description, the data mentioned in the embodiments of the present application may be memory data to be compressed, a data block in the memory data to be compressed, or content to be compressed in a data block. Specifically, they can be distinguished according to the above context.

[0116] 6) Compress the data blocks one by one

[0117] In the example of the present application, the embodiment of the present application needs to divide the memory data to be compressed into blocks, and compress the blocks in sequence according to the data blocks.

[0118] For example, the embodiment of the present application divides the memory data to be compressed into N data blocks. Then, the embodiment of the present application first compresses the first data block of the N data blocks, and after the compression of the first data block is completed, the second data block of the N data blocks is compressed, and so on, until the compression of the last data block is completed, thereby completing the compression of the memory data to be compressed.

[0119] 7) Compression ratio of the data type to which the data block belongs

[0120] In the embodiment of the present application, the compression ratio may represent the ratio of the compressible content (or the incompressible part) in the content to be compressed.

[0121] It should be noted that, for the sake of distinction, the embodiments of the present application will use "first compression rate" and "second compression rate". Of course, other terms may also be used for description, and there is no specific limitation on this.

[0122] In the embodiment of the present application, since the data block has a corresponding data type, the compression rate of the data type to which the data block belongs can represent the compression rate under a certain data type, and data blocks of different data types may have different compression rates.

[0123] For example, for the i-th (1 ≤ i < N) data block and the (i + 1)-th data block among N data blocks, if the i-th data block belongs to the video data type and the (i + 1)-th data block belongs to the image data type, the compression ratio of the i-th data block may be different from that of the (i + 1)-th data block.

[0124] 8) Source memory address, destination memory address

[0125] It should be noted that the memory address is a data concept used in different levels such as software and hardware to access data in the memory.

[0126] In the embodiments of the present application, the memory address may include a source memory address and a destination memory address. Among them, the source memory address may represent the memory address for storing the memory data to be compressed (data block / content to be compressed in the data block, etc.); the destination memory address may represent the memory address for the memory data after compression coding (compressed data block / content to be compressed after compression coding, etc.).

[0127] It should be noted that for the sake of distinction, the embodiments of the present application will use "the first source memory address", "the second source memory address", "the third source memory address", "the fourth source memory address", "the first destination memory address", "the second destination memory address", "the third source destination memory address". Of course, other terms can also be used for description, and no specific limitation is made thereto.

[0128] 9) Compression acceleration parameter, scanning interval

[0129] In the process of compressing data using the memory compression algorithm in the embodiments of the present application, a compression acceleration parameter will be used. The compression acceleration parameter can be used to determine the scanning interval, the scanning interval can be used to determine the offset of the source memory address of the data currently being compressed, and the offset of the source memory address can be used to determine the compression speed of the data currently being compressed. That is to say, the compression acceleration parameter is associated (corresponds) with the scanning interval, the scanning interval is associated (corresponds) with the offset of the source memory address, and the offset of the source memory address is associated (corresponds) with the compression speed.

[0130] Based on this, in the association (correspondence) relationship between the compression acceleration parameter and the scanning interval, if the compression speed parameter increases, the scanning interval increases; if the compression speed parameter decreases, the scanning interval decreases.

[0131] In the association (correspondence) relationship between the scanning interval and the offset of the source memory address, if the scanning interval increases, the offset of the source memory address increases; if the scanning interval decreases, the offset of the source memory address decreases.

[0132] In the correlation (correspondence) relationship between the offset of the source memory address and the compression speed, if the offset of the source memory address increases, the compression speed increases; if the offset of the source memory address decreases, the compression speed decreases.

[0133] Therefore, when the embodiment of the present application dynamically adjusts the compression speed in real time according to the compression ratio of data of different data types, it can also be: dynamically adjusting the compression acceleration parameters in real time according to the compression ratio of data of different data types, and realizing real-time dynamic adjustment of the compression speed by dynamically adjusting the compression acceleration parameters in real time.

[0134] In some possible implementations, if the data types of two data are the same, the compression acceleration parameters used by the two data may remain unchanged, that is, there is no need to adjust the compression acceleration parameters, so that the compression ratio and compression speed of the two data may remain unchanged.

[0135] For example, if the memory data to be compressed is divided into N data blocks, and the data type of the i-th data block is video, and the data type of the i+1-th data block is also video, then the compression acceleration parameter used for the data type of the i-th data block is the same as the compression acceleration parameter used for the data type of the i+1-th data block.

[0136] In addition, for ease of distinction, the embodiments of the present application will use "first compression acceleration parameter", "second compression acceleration parameter", "first scanning spacing", and "second scanning spacing". Of course, other terms can also be used for description, and there is no specific limitation on this.

[0137] 10) Use the same compression acceleration parameters to compress data of different data types

[0138] In the embodiment of the present application, when the same compression acceleration parameter is used to compress data of different data types, there may be different compression rates or compression speeds.

[0139] For example, when video data and image data are compressed using the same compression acceleration parameters, the compression rate of the image data may be different than the compression rate of the video data, and the compression speed of the image data may be different than the compression speed of the video data.

[0140] Therefore, when the same compression acceleration parameters are used to perform block compression on memory data composed of data of multiple data types, there may be a continuous change in compression rate (such as from large to small, from small to large, from large to small and then to large, from small to large and then to small, etc.) or a continuous change in compression speed (such as from large to small, from small to large, from large to small and then to large, from small to large and then to small, etc.).

[0141] 11) Matching items corresponding to the data

[0142] In the embodiment of the present application, in the process of compressing data using the compression acceleration parameter, it is necessary to find whether there is a matching item in the data, wherein the matching item may be the same content as the data.

[0143] If a match for the data is found, the embodiment of the present application regards the data as a compressible portion and encodes the data to achieve compression.

[0144] If no matching item is found for the data, the embodiment of the present application regards the data as incompressible content and does not encode or compress the data.

[0145] 12) Hash Table

[0146] In the memory compression algorithm of the embodiment of the present application, a hash table is required, and the hash table is used to find the matching items corresponding to the data. Among them, the hash table can be used to store data and the source memory address corresponding to the data.

[0147] 13) Update the hash table

[0148] The embodiment of the present application can utilize the offset of the source memory address to update the source memory address, determine the updated data according to the updated source memory address, and store the updated data and the updated source memory address into the hash table to update the hash table.

[0149] 14) Preset source memory address limit value

[0150] The memory compression algorithm of the embodiment of the present application will use a preset source memory address limit value, which can be used to limit the number of source memory addresses of data that the memory compression algorithm needs to process, so as to determine whether it is incompressible content and whether further compression is required.

[0151] That is to say, the embodiment of the present application can determine whether other uncompressed data after the currently compressed data is incompressible content by presetting the source memory address limit value.

[0152] For example, if the source memory address corresponding to the currently compressed data exceeds the preset source memory address limit value, the remaining uncompressed data after the currently compressed data needs to be encoded as incompressible content without further compression.

[0153] If the source memory address corresponding to the currently compressed data does not exceed the preset source memory address limit value, it is necessary to compress the remaining uncompressed data after the currently compressed data.

[0154] 4. A memory data compression method

[0155] In combination with the above description, an example of a memory data compression method according to an embodiment of the present application is described below.

[0156] like Figure 1 As shown, Figure 1 This is a flow chart of a memory data compression method according to an embodiment of the present application, which can be applied to electronic devices, processors / processing units in electronic devices, etc. The method can specifically include the following steps:

[0157] S110. Obtain memory data to be compressed, where the memory data to be compressed is composed of data of different data types.

[0158] It should be noted that the “memory data to be compressed” and the like can be found in the above description in detail, and will not be elaborated on herein.

[0159] S120. Divide the memory data to be compressed into N data blocks, where N is a positive integer.

[0160] It should be noted that the “data block” and the like can be found in the above description in detail and will not be elaborated on here.

[0161] S130, when compressing the i-th data block among the N data blocks, determining the compression rate of the data type to which the i-th data block belongs to obtain a first compression rate, 1≤i <N。

[0162] It should be noted that the first compression rate may represent the compression rate of the data type to which the i-th data block belongs. Of course, the first compression rate may also be described by other terms, which are not specifically limited.

[0163] S140. Adjust a first compression speed required for compressing the (i+1)th data block among the N data blocks according to the first compression ratio.

[0164] It should be noted that the first compression speed may represent the compression speed of the (i+1)th data block. Of course, the first compression speed may also be described by other terms, which are not specifically limited.

[0165] It can be seen that the present application can divide the memory data to be compressed into blocks to obtain N data blocks, and compress the N data blocks in blocks in turn. When compressing the i-th data block among the N data blocks, determine the compression rate under the data type to which the i-th data block belongs to obtain a first compression rate, and adjust the first compression speed required for compressing the i+1-th data block among the N data blocks according to the first compression rate, so that in the case of tight (or limited) memory resources, the compression speed of the data blocks can be adjusted in real time and dynamically according to the compression rate of data blocks of different data types, which is conducive to achieving the possibility of obtaining a larger compression speed increase with a smaller compression rate loss, achieving the possibility of rapid compression of memory data under tight (or limited) memory resources, increasing the practicality under tight (or limited) memory resources, and ensuring that the occupancy rate of memory resources is within a reasonable range to ensure the goodness and fluency of system performance.

[0166] In some possible implementations, determining the compression ratio of the data type to which the i-th data block belongs to obtain a first compression ratio may include the following steps:

[0167] Obtaining a first compression acceleration parameter, the first compression acceleration parameter is used to determine a first scanning interval, the first scanning interval is used to determine an offset of a first source memory address for storing an i-th data block, and the offset of the first source memory address is used to determine a second compression speed required for compressing the i-th data block;

[0168] According to the first compression acceleration parameter, a matching item corresponding to the content to be compressed in the i-th data block is searched, where the matching item is the same content as the content to be compressed.

[0169] When a matching item is found, the content to be compressed is encoded to achieve compression of the content to be compressed;

[0170] When all contents to be compressed in the ith data block are compressed, a compression ratio of the data type to which the ith data block belongs is calculated to obtain a first compression ratio.

[0171] It should be noted that the first source memory address can be used to store the i-th data block. Of course, the first source memory address can also be described by other terms, which is not specifically limited.

[0172] In combination with the content in the above “9) Compression acceleration parameter, scanning interval”, the embodiment of the present application uses the first compression acceleration parameter to compress the i-th data block.

[0173] Combined with the content in the above “11) Matching items corresponding to data”, in the process of compressing the i-th data block, the embodiment of the present application needs to sequentially search whether there is a matching item for each content to be compressed in the i-th data block, and encode and compress the content to be compressed for which the matching item is found. Finally, when all the content to be compressed in the i-th data block is compressed, the first compression ratio is calculated.

[0174] It can be seen that the embodiment of the present application can determine the compression rate of the data type to which the i-th data block belongs based on the first compression acceleration parameter.

[0175] In some possible implementations, searching for a matching item corresponding to content to be compressed in the i-th data block according to a first compression acceleration parameter may include the following steps: storing the content to be compressed in the i-th data block and a second source memory address for storing the content to be compressed in a hash table; searching for a matching item corresponding to the content to be compressed in the hash table according to the first compression acceleration parameter.

[0176] It should be noted that, in combination with the content in the above-mentioned "12) hash table", the embodiment of the present application can use a hash table to store the content to be compressed and the second source memory address for storing the content to be compressed, so that the matching items corresponding to the content to be compressed can be searched in the hash table according to the first compression acceleration parameter to realize the search for the matching items.

[0177] In some possible implementations, the method may further include the following steps:

[0178] determining a first scanning distance according to a first compression acceleration parameter;

[0179] Determine an updated second source memory address according to the offset determined by the first scanning interval;

[0180] Determining updated content to be compressed according to the updated second source memory address;

[0181] The updated second source memory address and the updated content to be compressed are stored in the hash table to update the hash table.

[0182] It should be noted that, combined with the content in the above "13) Update hash table", it can be seen that the embodiment of the present application can determine the updated second source memory address and the updated content to be compressed according to the first compression acceleration parameter, and store the updated second source memory address and the updated content to be compressed into the hash table to update the hash table.

[0183] In some possible implementations, encoding the content to be compressed to achieve compression of the content to be compressed may include the following steps:

[0184] Encoding the content to be compressed in a coding format of literal, literal length, offset distance and matching length by using a dictionary compression algorithm, and storing the encoded content to be compressed in a first destination memory address to achieve compression of the content to be compressed;

[0185] Literal, indicating that the content to be compressed is incompressible;

[0186] Literal length, indicating the length of the incompressible content;

[0187] The offset distance indicates the distance between the content to be compressed and the matching item corresponding to the content to be compressed;

[0188] Match length, which indicates the length of the matching item corresponding to the content to be compressed.

[0189] It should be noted that the embodiment of the present application can utilize the i-th data block to encode the content to be compressed to achieve compression.

[0190] In some possible implementations, encoding the content to be compressed to achieve compression of the content to be compressed may include the following steps:

[0191] The content to be compressed is encoded by using a dictionary compression algorithm in a coding format of a literal length, a literal, an offset distance and a matching length to achieve compression of the content to be compressed; when all the content to be compressed in the i-th data block is compressed, the literal is encoded by using a Harman coding algorithm to be stored in a second destination memory address; the literal length, the offset distance and the matching length are encoded by using a finite state entropy coding algorithm to be stored in a third destination memory address;

[0192] Literal, indicating that the content to be compressed is incompressible;

[0193] Literal length, indicating the length of the incompressible content;

[0194] The offset distance indicates the distance between the content to be compressed and the matching item corresponding to the content to be compressed;

[0195] Match length, which indicates the length of the matching item corresponding to the content to be compressed.

[0196] It should be noted that the embodiment of the present application can use a dictionary compression algorithm to encode the i-th data block to achieve compression, and when all the content to be compressed in the i-th data block is compressed, the Harman coding algorithm is used to encode the literal, and the finite state entropy coding algorithm is used to encode the literal length, offset distance and matching length, so as to achieve further compression.

[0197] In some possible implementations, the method may further include the following steps:

[0198] If the first source memory address exceeds the preset source memory address limit value, the remaining data blocks after the i-th data block need to be encoded as incompressible content to complete the compression of the memory data to be compressed;

[0199] If the first source memory address does not exceed the preset source memory address limit value, the i+1th data block needs to be compressed.

[0200] It should be noted that, in combination with the content in "14) preset source memory address limit value", the embodiment of the present application can determine whether the source memory address exceeds the preset source memory address limit value, thereby determining whether the remaining data blocks are required for encoding.

[0201] In some possible implementations, the first compression speed can be determined by the offset of the third source memory address used to store the i+1th data block; the offset of the third source memory address is determined by the second scanning interval; and the second scanning interval is determined by the second compression acceleration parameter required for compressing the i+1th data block.

[0202] In combination with the content in the above “9) Compression acceleration parameter, scanning interval”, the embodiment of the present application uses the second compression acceleration parameter to compress the i+1th data block.

[0203] In addition, if the data type of the i-th data block is the same as the data type of the i+1-th data block, the first compression acceleration parameter and the second compression acceleration parameter may be the same. Correspondingly, the first scanning interval and the second scanning interval may be the same, and the offset of the first source memory address and the offset of the third source memory address may be the same.

[0204] If the data type of the i-th data block is different from the data type of the i+1-th data block, the first compression acceleration parameter and the second compression acceleration parameter may be different. Correspondingly, the first scanning interval and the second scanning interval may be different, and the offset of the first source memory address and the offset of the third source memory address may be different.

[0205] In some possible implementations, if i=1, adjusting the first compression speed required for compressing the i+1th data block among the N data blocks according to the first compression rate may include the following steps:

[0206] If the first compression rate is greater than a preset threshold, the first compression speed needs to be increased;

[0207] If the first compression rate is less than or equal to the preset threshold, the first compression speed needs to be reduced;

[0208] If the first compression rate is equal to the preset threshold, the first compression speed needs to be kept unchanged.

[0209] It can be understood that if the compression ratio of the first data block among the N data blocks is greater than the preset threshold, it is necessary to increase the compression speed required for compressing the second data block, and the compression ratio of the corresponding second data block may decrease; if the compression ratio of the first data block is less than the preset threshold, it is necessary to decrease the compression speed required for compressing the second data block, and the compression ratio of the corresponding second data block may increase; if the compression ratio of the first data block is equal to the preset threshold, it is necessary to keep the compression speed required for compressing the second data block unchanged, and the compression ratio of the corresponding second data block may remain unchanged.

[0210] It can be seen that the embodiments of the present application can adjust the compression speed required for the second data block according to the magnitude relationship between the compression ratio of the first data block and the preset threshold.

[0211] In some possible implementations, if 1 < i ≤ N, adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression ratio may include the following steps:

[0212] Adjust the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the magnitude relationship between the first compression ratio and the second compression ratio, where the second compression ratio is the compression ratio under the data type to which the (i - 1)-th data block among the N data blocks belongs.

[0213] It can be seen that the embodiments of the present application can adjust the compression speed required for the (i + 1)-th data block according to the magnitude relationship between the compression ratio of the i-th data block and the compression ratio of the (i - 1)-th data block.

[0214] In some possible implementations, if adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the magnitude relationship between the first compression ratio and the second compression ratio, it may include the following steps:

[0215] If the first compression ratio is greater than the second compression ratio, it is necessary to increase the first compression speed;

[0216] If the first compression ratio is less than the second compression ratio, it is necessary to decrease the first compression speed;

[0217] If the first compression ratio is equal to the second compression ratio, it is necessary to keep the first compression speed unchanged.

[0218] It should be noted that if the compression rate of the i-th data block is greater than the compression rate of the i-1th data block, it means that the data type of the i-th data block may be different from the data type of the i-1th data block. Therefore, it can be assumed that the data type of the i-th data block may also be different from the data type of the i+1th data block. In this regard, the compression speed required for the i+1th data block can be increased, and the compression rate of the corresponding i+1th data block is reduced.

[0219] Similarly, if the compression rate of the i-th data block is less than that of the i-1-th data block, it means that the data type of the i-th data block may be different from that of the i-1-th data block. Therefore, it can be assumed that the data type of the i-th data block may also be different from that of the i+1-th data block. In this regard, the compression speed required for the i+1-th data block can be reduced, and the compression rate of the corresponding i+1-th data block increases.

[0220] If the compression rate of the i-th data block is equal to the compression rate of the i-1-th data block, it means that the data type of the i-th data block may be the same as the data type of the i-1-th data block. Therefore, it can be assumed that the data type of the i-th data block may be the same as the data type of the i+1-th data block. In this regard, the compression speed required for the i+1-th data block can be kept unchanged, and the corresponding compression rate of the i+1-th data block remains unchanged.

[0221] 5. A memory data compression method

[0222] The following embodiments of the present application provide an exemplary description of the above “4. A method for compressing memory data”.

[0223] Example 1:

[0224] In "Example 1", the embodiment of the present application proposes an improved LZ4 compression algorithm, and the general process is as follows:

[0225] (1) Obtain the memory data to be compressed, divide the memory data to be compressed into blocks of 4 KB in size, and read 4 KB data blocks each time and send them to the memory compression algorithm;

[0226] (2) determining the scanning interval according to the compression acceleration parameter;

[0227] (3) Searching for a 4KB data block at a certain scanning interval, encoding the content to be compressed in the 4KB data block using the encoding format of the dictionary compression algorithm in the LZ4 compression algorithm, and writing it into the destination memory to achieve compression of the content to be compressed;

[0228] (4) Calculate the compression ratio of the data type to which the 4KB data block belongs, and dynamically adjust the compression acceleration parameter based on the compression ratio to achieve dynamic adjustment of the scanning interval;

[0229] a) If the compression rate is lower than the compression rate of the previous 4KB data block, the compression acceleration parameter is reduced to reduce the scanning interval in the memory compression algorithm, so that the compression speed of the next 4KB data block is slowed down and the compression rate is improved;

[0230] b) If the compression rate is greater than the compression rate of the previous 4KB memory data, the compression acceleration parameter is increased to increase the scanning interval in the memory compression algorithm, so that the compression speed of the next 4KB data block becomes faster and the compression rate is reduced;

[0231] c) If the compression rate is equal to the compression rate of the previous 4KB memory data, the compression acceleration parameter remains unchanged, and the scanning interval in the memory compression algorithm remains unchanged, so that the compression speed and compression rate of the next 4KB data block remain unchanged;

[0232] (5) Determine whether the source memory address of the 4KB data block exceeds the limit value for the source memory address in the memory compression algorithm.

[0233] a) If the source memory address does not exceed the limit value of the source memory address, the compression acceleration parameter is adjusted, and the scanning interval is adjusted to prepare for compressing the next 4KB data block;

[0234] b) If the source memory address exceeds the limit value of the source memory address, the remaining data block is encoded as incompressible content and written into the destination memory;

[0235] (6) Output the data size of the memory data to be compressed after compression, and end the compression process.

[0236] Specific implementation process, such as Figure 2 described. Figure 2 : is a flowchart of an improved LZ4 compression algorithm according to an embodiment of the present application, which may include the following steps:

[0237] Step 1: Get the memory data to be compressed.

[0238] It should be noted that the embodiment of the present application can obtain memory data that needs to be compressed from the memory and read the memory data.

[0239] Step 2: Set the data block size to 4KB.

[0240] It should be noted that the embodiment of the present application can divide the memory data to be compressed into N data blocks of 4KB in size, so that the data blocks are sequentially sent to the memory compression algorithm for compression in units of 4KB.

[0241] Step 3: Read 4KB blocks of data.

[0242] It should be noted that the following description is based on reading a current 4KB data block and compressing the current 4KB data block.

[0243] In addition, the embodiment of the present application also needs to obtain the source memory address for storing the current 4KB data block and the destination memory address for storing the encoded current 4KB data block, and initialize the hash table used for searching.

[0244] Step 4: Obtain the current compression acceleration parameter, and determine the current scanning interval according to the current compression acceleration parameter.

[0245] Step 5: In the hash table, search for a matching item corresponding to the content to be compressed in the current 4KB data block.

[0246] It should be noted that the embodiment of the present application can store the content to be compressed in the current 4KB data block into the hash table, update the hash table and the source memory address, and simultaneously search for matching items corresponding to the content to be compressed in the current 4KB data block.

[0247] In addition, the offset of the source memory address is determined according to the current scanning interval to update the source memory address, and the updated source memory address and the content to be compressed corresponding to the updated source memory address are stored in the hash table, thereby updating the hash table.

[0248] Step 6: Determine whether a match is found.

[0249] It should be noted that if no matching item is found, the process returns to step 5 within the current 4KB data block to continue searching for matching items.

[0250] If a match is found, go to step 7.

[0251] Step 7: Encode the content to be compressed.

[0252] It should be noted that the embodiment of the present application can use the dictionary compression algorithm in the LZ4 compression algorithm to encode the compressed content in the encoding format of literals, literal length, offset distance, and match length, and write it into the destination memory address.

[0253] Step 8: Determine whether the current 4KB data block has been compressed.

[0254] It should be noted that if the compression of the current 4KB data block is not completed, the process returns to step 5.

[0255] If the compression of the current 4KB data block is completed, return to step 9.

[0256] Step 9: Calculate the compression ratio of the data type of the current 4KB data block.

[0257] Step 10: Determine whether the current compression rate is greater than the previous compression rate.

[0258] It should be noted that the current compression rate is the compression rate of the current 4KB data block, and the previous compression rate is the compression rate of the previous 4KB data block of the current 4KB data block.

[0259] If the current compression rate is less than the previous compression rate, the compression acceleration parameter is reduced to reduce the current scanning interval, reduce the compression speed required for compressing the next 4KB data block, and increase the compression rate required for compressing the next 4KB data block.

[0260] If the compression rate this time is greater than the previous compression rate, the compression acceleration parameter is increased to increase the current scanning interval, increase the compression speed required for compressing the next 4KB data block, and thus reduce the compression rate required for compressing the next 4KB data block.

[0261] If the compression rate difference this time is equal to the last compression rate, the compression acceleration parameter is kept unchanged, so that the current scanning interval remains unchanged, the compression speed required for compressing the next 4KB data block remains unchanged, and the compression rate required for compressing the next 4KB data block remains unchanged.

[0262] Step 11: Determine whether the source memory address exceeds the limit value of the source memory address in the memory compression algorithm, that is, the preset source memory address limit value.

[0263] It should be noted that if the source memory address does not exceed the preset source memory address limit value, the process returns to step 3.

[0264] If the source memory address exceeds the preset source memory address limit value, execute step 12.

[0265] Step 12: Encode the remaining data blocks as incompressible content.

[0266] It should be noted that the embodiment of the present application can encode the remaining data blocks as incompressible content and write them into the memory to execute step 13.

[0267] Step 13: Output the size of the memory data to be compressed after compression.

[0268] It should be noted that the embodiment of the present application can output the size of the memory data to be compressed after being compressed by the memory compression algorithm, thereby ending the algorithm process.

[0269] It can be seen that the embodiments of the present application can utilize the improved LZ4 compression algorithm to realize real-time dynamic adjustment of the compression acceleration parameters according to the compression ratio of the data blocks of different data types, and realize real-time dynamic adjustment of the compression speed of the data blocks through the real-time dynamic adjustment of the compression acceleration parameters, thereby facilitating the possibility of obtaining a larger compression speed improvement with a smaller compression ratio loss, realizing the possibility of rapid compression of memory data when memory resources are tight (or limited), increasing the practicality when memory resources are tight (or limited), and ensuring that the occupancy rate of memory resources is within a reasonable range to ensure the goodness and smoothness of system performance.

[0270] Example 2:

[0271] In "Example 2", the embodiment of the present application proposes an improved LSTD compression algorithm, and the general process is as follows:

[0272] (1) Obtain the memory data to be compressed, divide the memory data to be compressed into blocks of 4 KB in size, and read 4 KB data blocks each time and send them to the memory compression algorithm;

[0273] (2) determining the scanning interval according to the compression acceleration parameter;

[0274] (3) Searching for a 4KB data block at a certain scanning interval, the encoding format of the dictionary compression algorithm encodes the content to be compressed in the 4KB data block;

[0275] (4) using Huffman coding to encode the incompressible content, and using finite state entropy coding to encode the length, offset distance, and matching length of the incompressible content;

[0276] (5) Calculate the compression ratio of the data type to which the 4KB data block belongs, and dynamically adjust the compression acceleration parameter based on the compression ratio to achieve dynamic adjustment of the scanning interval;

[0277] a) If the compression rate is lower than the compression rate of the previous 4KB data block, the compression acceleration parameter is reduced to reduce the scanning interval in the memory compression algorithm, so that the compression speed of the next 4KB data block is slowed down and the compression rate is improved;

[0278] b) If the compression rate is greater than the compression rate of the previous 4KB memory data, the compression acceleration parameter is increased to increase the scanning interval in the memory compression algorithm, so that the compression speed of the next 4KB data block becomes faster and the compression rate is reduced;

[0279] c) If the compression rate is equal to the compression rate of the previous 4KB memory data, the compression acceleration parameter remains unchanged, and the scanning interval in the memory compression algorithm remains unchanged, so that the compression speed and compression rate of the next 4KB data block remain unchanged;

[0280] (6) Determine whether the source memory address of the 4KB data block exceeds the limit value for the source memory address in the memory compression algorithm.

[0281] a) If the source memory address does not exceed the limit value of the source memory address, the compression acceleration parameter is adjusted, and the scanning interval is adjusted to prepare for compressing the next 4KB data block;

[0282] b) If the source memory address exceeds the limit value of the source memory address, the remaining data block is encoded as incompressible content and written into the destination memory;

[0283] (7) Output the data size of the memory data to be compressed after compression, and end the compression process.

[0284] Specific implementation process, such as Figure 3 described. Figure 3 Schematic diagram of a flow chart of an improved LSTD compression algorithm according to an embodiment of the present application, which may include the following steps:

[0285] Step 1: Get the memory data to be compressed.

[0286] It should be noted that the embodiment of the present application can obtain memory data that needs to be compressed from the memory and read the memory data.

[0287] Step 2: Set the data block size to 4KB.

[0288] It should be noted that the embodiment of the present application can divide the memory data to be compressed into N data blocks of 4KB in size, so that the data blocks are sequentially sent to the memory compression algorithm for compression in units of 4KB.

[0289] Step 3: Read 4KB blocks of data.

[0290] It should be noted that the following description is based on reading a current 4KB data block and compressing the current 4KB data block.

[0291] In addition, the embodiment of the present application also needs to obtain the source memory address for storing the current 4KB data block and the destination memory address for storing the encoded current 4KB data block, and initialize the hash table used for searching.

[0292] Step 4: Obtain the current compression acceleration parameter, and determine the current scanning interval according to the current compression acceleration parameter.

[0293] Step 5: In the hash table, search for a matching item corresponding to the content to be compressed in the current 4KB data block.

[0294] It should be noted that the embodiment of the present application can store the content to be compressed in the current 4KB data block into the hash table, update the hash table and the source memory address, and simultaneously search for matching items corresponding to the content to be compressed in the current 4KB data block.

[0295] In addition, the offset of the source memory address is determined according to the current scanning interval to update the source memory address, and the updated source memory address and the content to be compressed corresponding to the updated source memory address are stored in the hash table, thereby updating the hash table.

[0296] Step 6: Determine whether a match is found.

[0297] It should be noted that if no matching item is found, the process returns to step 5 within the current 4KB data block to continue searching for matching items.

[0298] If a match is found, go to step 7.

[0299] Step 7: Encode the content to be compressed.

[0300] It should be noted that the embodiment of the present application can use the dictionary compression algorithm in the LZ4 compression algorithm to encode the compressed content in the encoding format of literals, literal length, offset distance, and match length, and write it into the destination memory address.

[0301] Among them, the literal can indicate that the content to be compressed is incompressible content; the literal length can indicate the length of the incompressible content; the offset distance can indicate the distance between the content to be compressed and the matching item corresponding to the content to be compressed; and the matching length can indicate the length of the matching item corresponding to the content to be compressed.

[0302] Step 8: Determine whether the current 4KB data block has been compressed.

[0303] It should be noted that if the compression of the current 4KB data block is not completed, the process returns to step 5.

[0304] If the compression of the current 4KB data block is completed, return to step 9.

[0305] Step 9: Encode the literal (ie, incompressible content) using the Harman coding algorithm.

[0306] Step 10: Encode the literal length, offset distance and matching length using a finite state entropy coding algorithm.

[0307] Step 11: Calculate the compression ratio of the data type of the current 4KB data block.

[0308] Step 12: Determine whether the current compression rate is greater than the previous compression rate.

[0309] It should be noted that the current compression rate is the compression rate of the current 4KB data block, and the previous compression rate is the compression rate of the previous 4KB data block of the current 4KB data block.

[0310] If the current compression rate is less than the previous compression rate, the compression acceleration parameter is reduced to reduce the current scanning interval, reduce the compression speed required for compressing the next 4KB data block, and increase the compression rate required for compressing the next 4KB data block.

[0311] If the compression rate this time is greater than the previous compression rate, the compression acceleration parameter is increased to increase the current scanning interval, increase the compression speed required for compressing the next 4KB data block, and thus reduce the compression rate required for compressing the next 4KB data block.

[0312] If the compression rate difference this time is equal to the last compression rate, the compression acceleration parameter is kept unchanged, so that the current scanning interval remains unchanged, the compression speed required for compressing the next 4KB data block remains unchanged, and the compression rate required for compressing the next 4KB data block remains unchanged.

[0313] Step 13: Determine whether the source memory address exceeds the limit value of the source memory address in the ZSTD compression algorithm, that is, the preset source memory address limit value.

[0314] It should be noted that if the source memory address does not exceed the preset source memory address limit value, the process returns to step 3.

[0315] If the source memory address exceeds the preset source memory address limit value, execute step 14.

[0316] Step 14: Output the size of the memory data to be compressed after compression.

[0317] It should be noted that the embodiment of the present application can output the size of the memory data to be compressed after being compressed by the memory compression algorithm, thereby ending the algorithm process.

[0318] It can be seen that the embodiments of the present application can utilize the improved LSTD compression algorithm to realize real-time dynamic adjustment of the compression acceleration parameters according to the compression rates of data blocks of different data types, and realize real-time dynamic adjustment of the compression speed of the data blocks through the real-time dynamic adjustment of the compression acceleration parameters, thereby facilitating the possibility of obtaining a larger compression speed improvement with a smaller compression rate loss, realizing the possibility of rapid compression of memory data when memory resources are tight (or limited), increasing the practicality when memory resources are tight (or limited), and ensuring that the occupancy rate of memory resources is within a reasonable range to ensure the goodness and smoothness of system performance.

[0319] 6. Exemplary description of a memory data compression device

[0320] The above mainly introduces the scheme of the embodiment of the present application from the perspective of the execution process of the method side. It is understandable that, in order to realize the above functions, the device includes a hardware structure and / or software module corresponding to each function. Those skilled in the art should know that, in combination with the methods, functions, modules, units or steps of each example described in the embodiments provided herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain method, function, module, unit or step is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described methods, functions, modules, units or steps for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0321] The embodiment of the present application can divide the electronic device into functional units / modules according to the above method example. For example, each functional unit / module can be divided according to each function, or two or more functions can be integrated into one functional unit / module. The above integrated functional unit / module can be implemented in hardware or in software program. It should be noted that the division of functional units / modules in the embodiment of the present application is schematic, which is only a logical function division, and there may be other division methods in actual implementation.

[0322] In the case of an integrated unit, Figure 4 The present invention is a block diagram of the functional units of a memory data compression device. The memory data compression device 400 comprises: an acquisition unit 410 , a block division unit 420 , a determination unit 430 and an adjustment unit 440 .

[0323] It should be noted that the acquisition unit 410 may be a module unit for acquiring or processing signals, data, information, etc., and there is no specific limitation on this.

[0324] The blocking unit 420 may be a module unit for processing signals, data, information, etc., and is not specifically limited thereto.

[0325] The determination unit 430 may be a module unit for processing signals, data, information, etc., and is not specifically limited thereto.

[0326] The adjustment unit 440 may be a module unit for processing signals, data, information, etc., and is not specifically limited thereto.

[0327] In some possible implementations, the acquisition unit 410, the blocking unit 420, the determination unit 430, and the adjustment unit 440 may be separate from each other or may be integrated into the same unit.

[0328] For example, if the acquisition unit 410, the blocking unit 420, the determination unit 430 and the adjustment unit 440 are integrated into the same unit, the acquisition unit 410, the blocking unit 420, the determination unit 430 and the adjustment unit 440 may be integrated into a processing unit.

[0329] It should be noted that the processing unit can be a processor or a controller, for example, a central processing unit (CPU), a general processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processing unit can also be a combination that implements a computing function, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0330] For another example, the acquisition unit 410 may be integrated into the communication unit, and the blocking unit 420 , the determination unit 430 , and the adjustment unit 440 may be integrated into the processing unit.

[0331] It should be noted that the communication unit may be a communication interface, a transceiver, a transceiver circuit, etc.

[0332] In some possible implementations, the memory data compression device 400 may further include a storage unit for storing computer programs or instructions executed by the memory data compression device 400 .

[0333] For example, the storage unit may be a memory.

[0334] In some possible implementations, the memory data compression apparatus 400 may be a chip / chip module / processor / device / operating system.

[0335] In specific implementation, the acquisition unit 410, the block division unit 420, the determination unit 430 and the adjustment unit 440 are used to perform the steps described in the above method embodiment.

[0336] The acquisition unit 410 is used to acquire memory data to be compressed, where the memory data to be compressed is composed of data of different data types;

[0337] The block division unit 420 is used to divide the memory data to be compressed into N data blocks, where N is a positive integer;

[0338] The determining unit 430 is configured to determine the compression ratio of the data type to which the i-th data block belongs to obtain a first compression ratio when compressing the i-th data block among the N data blocks, 1≤i <N;

[0339] The adjusting unit 440 is configured to adjust a first compression speed required for compressing the (i+1)th data block among the N data blocks according to the first compression rate.

[0340] It should be noted that the specific implementation of each operation performed by the memory data compression device 400 can refer to the corresponding description of the above-mentioned method embodiment, which will not be repeated here.

[0341] It can be seen that when memory resources are tight (or limited), the embodiments of the present application can dynamically adjust the compression speed of data blocks in real time according to the compression rates of data blocks of different data types, thereby facilitating the possibility of achieving a larger compression speed improvement with a smaller compression rate loss, achieving the possibility of rapid compression of memory data when memory resources are tight (or limited), increasing practicality when memory resources are tight (or limited), and ensuring that the occupancy rate of memory resources is within a reasonable range to ensure the goodness and smoothness of system performance.

[0342] In some possible implementations, in determining the compression ratio of the data type to which the i-th data block belongs to obtain the first compression ratio, the determining unit 430 is configured to:

[0343] Obtaining a first compression acceleration parameter, the first compression acceleration parameter is used to determine a first scanning interval, the first scanning interval is used to determine an offset of a first source memory address for storing an i-th data block, and the offset of the first source memory address is used to determine a second compression speed required for compressing the i-th data block;

[0344] According to the first compression acceleration parameter, a matching item corresponding to the content to be compressed in the i-th data block is searched, where the matching item is the same content as the content to be compressed.

[0345] When a matching item is found, the content to be compressed is encoded to achieve compression of the content to be compressed;

[0346] When all contents to be compressed in the ith data block are compressed, a compression ratio of the data type to which the ith data block belongs is calculated to obtain a first compression ratio.

[0347] It should be noted that the first source memory address can be used to store the i-th data block. Of course, the first source memory address can also be described by other terms, which is not specifically limited.

[0348] In combination with the content in the above “9) Compression acceleration parameter, scanning interval”, the embodiment of the present application uses the first compression acceleration parameter to compress the i-th data block.

[0349] Combined with the content in the above “11) Matching items corresponding to data”, in the process of compressing the i-th data block, the embodiment of the present application needs to sequentially search whether there is a matching item for each content to be compressed in the i-th data block, and encode and compress the content to be compressed for which the matching item is found. Finally, when all the content to be compressed in the i-th data block is compressed, the first compression ratio is calculated.

[0350] It can be seen that the embodiment of the present application can determine the compression rate of the data type to which the i-th data block belongs based on the first compression acceleration parameter.

[0351] In some possible implementations, in searching for a matching item corresponding to the content to be compressed in the i-th data block according to the first compression acceleration parameter, the determination unit 430 is configured to:

[0352] The content to be compressed in the i-th data block and the second source memory address for storing the content to be compressed are stored in the hash table;

[0353] According to the first compression acceleration parameter, a matching item corresponding to the content to be compressed is searched in the hash table.

[0354] It should be noted that, in combination with the content in the above-mentioned "12) hash table", the embodiment of the present application can use a hash table to store the content to be compressed and the second source memory address for storing the content to be compressed, so that the matching items corresponding to the content to be compressed can be searched in the hash table according to the first compression acceleration parameter to realize the search for the matching items.

[0355] In some possible implementations, the memory data compression device 400 may further include an updating unit, and the updating unit is used to:

[0356] determining a first scanning distance according to a first compression acceleration parameter;

[0357] Determine an updated second source memory address according to the offset determined by the first scanning interval;

[0358] Determining updated content to be compressed according to the updated second source memory address;

[0359] The updated second source memory address and the updated content to be compressed are stored in the hash table to update the hash table.

[0360] It should be noted that, combined with the content in the above "13) Update hash table", it can be seen that the embodiment of the present application can determine the updated second source memory address and the updated content to be compressed according to the first compression acceleration parameter, and store the updated second source memory address and the updated content to be compressed into the hash table to update the hash table.

[0361] In some possible implementations, in encoding the content to be compressed to achieve compression of the content to be compressed, the determining unit 430 is configured to:

[0362] Encoding the content to be compressed in a coding format of literal, literal length, offset distance and matching length using a dictionary compression algorithm, and storing the encoded content to be compressed in a first destination memory address to achieve compression of the content to be compressed; or,

[0363] Using a dictionary compression algorithm to encode the content to be compressed in a coding format of literal length, literal, offset distance and matching length to achieve compression of the content to be compressed; when all the content to be compressed in the i-th data block is compressed, using a Harman coding algorithm to encode the literal to store in a second destination memory address; using a finite state entropy coding algorithm to encode the literal length, offset distance and matching length to store in a third destination memory address;

[0364] Literal, indicating that the content to be compressed is incompressible;

[0365] Literal length, indicating the length of the incompressible content;

[0366] The offset distance indicates the distance between the content to be compressed and the matching item corresponding to the content to be compressed;

[0367] Match length, which indicates the length of the matching item corresponding to the content to be compressed.

[0368] It should be noted that the embodiment of the present application can use the i-th data block to encode the content to be compressed to achieve compression. Alternatively, the embodiment of the present application can use a dictionary compression algorithm to encode the i-th data block to achieve compression, and when all the content to be compressed in the i-th data block is compressed, the Harman coding algorithm is used to encode the literal, and the finite state entropy coding algorithm is used to encode the literal length, offset distance and matching length, so as to achieve further compression.

[0369] In some possible implementations, the memory data compression device 400 may further include an address determination unit, and the address determination unit is used to:

[0370] If the first source memory address exceeds the preset source memory address limit value, the remaining data blocks after the i-th data block need to be encoded as incompressible content to complete the compression of the memory data to be compressed;

[0371] If the first source memory address does not exceed the preset source memory address limit value, the i+1th data block needs to be compressed.

[0372] It should be noted that, in combination with the content in "14) preset source memory address limit value", the embodiment of the present application can determine whether the source memory address exceeds the preset source memory address limit value, thereby determining whether the remaining data blocks are required for encoding.

[0373] In some possible implementations, the first compression speed is determined by an offset of a third source memory address for storing the (i+1)th data block;

[0374] The offset of the third source memory address is determined by the second scanning interval;

[0375] The second scanning interval is determined by a second compression acceleration parameter required for compressing the (i+1)th data block.

[0376] In combination with the content in the above “9) Compression acceleration parameter, scanning interval”, the embodiment of the present application uses the second compression acceleration parameter to compress the i+1th data block.

[0377] In addition, if the data type of the i-th data block is the same as the data type of the i+1-th data block, the first compression acceleration parameter and the second compression acceleration parameter may be the same. Correspondingly, the first scanning interval and the second scanning interval may be the same, and the offset of the first source memory address and the offset of the third source memory address may be the same.

[0378] If the data type of the i-th data block is different from that of the (i + 1)-th data block, the first compression acceleration parameter and the second compression acceleration parameter may be different. Correspondingly, the first scanning pitch and the second scanning pitch may be different, and the offset of the first source memory address and the offset of the third source memory address may be different.

[0379] In some possible implementations, if i = 1, in terms of adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression ratio, the adjustment unit 440 is configured to:

[0380] If the first compression ratio is greater than the preset threshold, it is necessary to increase the first compression speed;

[0381] If the first compression ratio is less than the preset threshold, it is necessary to decrease the first compression speed;

[0382] If the first compression ratio is equal to the preset threshold, it is necessary to keep the first compression speed unchanged.

[0383] It can be understood that if the compression ratio of the first data block among the N data blocks is greater than the preset threshold, it is necessary to increase the compression speed required for compressing the second data block. Correspondingly, the compression ratio of the second data block may decrease; if the compression ratio of the first data block is less than the preset threshold, it is necessary to decrease the compression speed required for compressing the second data block. Correspondingly, the compression ratio of the second data block may increase; if the compression ratio of the first data block is equal to the preset threshold, it is necessary to keep the compression speed required for compressing the second data block unchanged. Correspondingly, the compression ratio of the second data block may remain unchanged.

[0384] It can be seen that the embodiments of the present application can adjust the compression speed required for the second data block according to the magnitude relationship between the compression ratio of the first data block and the preset threshold.

[0385] In some possible implementations, if 1 < i ≤ N, in terms of adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression ratio, the adjustment unit 440 is configured to:

[0386] Adjust the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the magnitude relationship between the first compression ratio and the second compression ratio, where the second compression ratio is the compression ratio under the data type of the (i - 1)-th data block among the N data blocks.

[0387] It can be seen that the embodiments of the present application can adjust the compression speed required for the (i + 1)-th data block according to the magnitude relationship between the compression ratio of the i-th data block and the compression ratio of the (i - 1)-th data block.

[0388] In some possible implementations, in adjusting the first compression speed required for compressing the (i+1)th data block among the N data blocks according to the magnitude relationship between the first compression rate and the second compression rate, the adjusting unit 440 is configured to:

[0389] If the first compression ratio is greater than the second compression ratio, the first compression speed needs to be increased;

[0390] If the first compression rate is less than the second compression rate, the first compression speed needs to be reduced;

[0391] If the first compression rate is equal to the second compression rate, the first compression rate needs to be kept unchanged.

[0392] It should be noted that if the compression rate of the i-th data block is greater than the compression rate of the i-1th data block, it means that the data type of the i-th data block may be different from the data type of the i-1th data block. Therefore, it can be assumed that the data type of the i-th data block may also be different from the data type of the i+1th data block. In this regard, the compression speed required for the i+1th data block can be increased, and the compression rate of the corresponding i+1th data block is reduced.

[0393] Similarly, if the compression rate of the i-th data block is less than that of the i-1-th data block, it means that the data type of the i-th data block may be different from that of the i-1-th data block. Therefore, it can be assumed that the data type of the i-th data block may also be different from that of the i+1-th data block. In this regard, the compression speed required for the i+1-th data block can be reduced, and the compression rate of the corresponding i+1-th data block increases.

[0394] If the compression rate of the i-th data block is equal to the compression rate of the i-1-th data block, it means that the data type of the i-th data block may be the same as the data type of the i-1-th data block. Therefore, it can be assumed that the data type of the i-th data block may be the same as the data type of the i+1-th data block. In this regard, the compression speed required for the i+1-th data block can be kept unchanged, and the corresponding compression rate of the i+1-th data block remains unchanged.

[0395] 7. Exemplary description of an electronic device

[0396] The following is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 5 The electronic device 500 includes a processor 510 , a memory 520 , and at least one communication bus for connecting the processor 510 and the memory 520 .

[0397] In some possible implementations, the processor 510 may be one or more central processing units (CPUs). In the case where the processor 510 is a CPU, the CPU may be a single-core CPU or a multi-core CPU. The memory 520 includes, but is not limited to, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), or a portable read-only memory (CD-ROM), and the memory 520 is used to store computer programs or instructions.

[0398] In some possible implementations, the electronic device 500 further includes a communication interface, which is used to receive and send data.

[0399] In some possible implementations, the processor 510 in the electronic device 500 is used to execute the computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0400] Obtain memory data to be compressed, where the memory data to be compressed consists of data of different data types;

[0401] Divide the memory data to be compressed into N data blocks, where N is a positive integer;

[0402] When compressing the i-th data block among N data blocks, determine the compression rate of the data type to which the i-th data block belongs to obtain a first compression rate, 1≤i <N;

[0403] According to the first compression rate, a first compression speed required for compressing the (i+1)th data block among the N data blocks is adjusted.

[0404] It can be seen that when memory resources are tight (or limited), the compression speed of data blocks is dynamically adjusted in real time according to the compression rates of data blocks of different data types, which is conducive to achieving the possibility of obtaining a larger compression speed increase with a smaller compression rate loss, and achieving the possibility of rapid compression of memory data when memory resources are tight (or limited), increasing practicality when memory resources are tight (or limited), and ensuring that the occupancy rate of memory resources is within a reasonable range to ensure the good performance and smoothness of the system.

[0405] It should be noted that the specific implementation of each operation performed by the electronic device 500 can refer to the corresponding description of the method embodiment in the above figure, which will not be repeated here.

[0406] In some possible implementations, in determining the compression rate of the data type to which the i-th data block belongs to obtain a first compression rate, the processor 510 in the electronic device 500 is used to execute the computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0407] Obtaining a first compression acceleration parameter, the first compression acceleration parameter is used to determine a first scanning interval, the first scanning interval is used to determine an offset of a first source memory address for storing an i-th data block, and the offset of the first source memory address is used to determine a second compression speed required for compressing the i-th data block;

[0408] According to the first compression acceleration parameter, a matching item corresponding to the content to be compressed in the i-th data block is searched, where the matching item is the same content as the content to be compressed.

[0409] When a matching item is found, the content to be compressed is encoded to achieve compression of the content to be compressed;

[0410] When all contents to be compressed in the ith data block are compressed, a compression ratio of the data type to which the ith data block belongs is calculated to obtain a first compression ratio.

[0411] In some possible implementations, in terms of searching for a matching item corresponding to the content to be compressed in the i-th data block according to the first compression acceleration parameter, the processor 510 in the electronic device 500 is used to execute a computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0412] The content to be compressed in the i-th data block and the second source memory address for storing the content to be compressed are stored in the hash table;

[0413] According to the first compression acceleration parameter, a matching item corresponding to the content to be compressed is searched in the hash table.

[0414] In some possible implementations, the processor 510 in the electronic device 500 is further configured to execute a computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0415] determining a first scanning distance according to a first compression acceleration parameter;

[0416] Determine an updated second source memory address according to the offset determined by the first scanning interval;

[0417] Determining updated content to be compressed according to the updated second source memory address;

[0418] The updated second source memory address and the updated content to be compressed are stored in the hash table to update the hash table.

[0419] In some possible implementations, in encoding the content to be compressed to achieve compression of the content to be compressed, the processor 510 in the electronic device 500 is used to execute the computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0420] Encoding the content to be compressed in a coding format of literal, literal length, offset distance and matching length using a dictionary compression algorithm, and storing the encoded content to be compressed in a first destination memory address to achieve compression of the content to be compressed; or,

[0421] Using a dictionary compression algorithm to encode the content to be compressed in a coding format of literal length, literal, offset distance and matching length to achieve compression of the content to be compressed; when all the content to be compressed in the i-th data block is compressed, using a Harman coding algorithm to encode the literal to store in a second destination memory address; using a finite state entropy coding algorithm to encode the literal length, offset distance and matching length to store in a third destination memory address;

[0422] Literal, indicating that the content to be compressed is incompressible;

[0423] Literal length, indicating the length of the incompressible content;

[0424] The offset distance indicates the distance between the content to be compressed and the matching item corresponding to the content to be compressed;

[0425] Match length, which indicates the length of the matching item corresponding to the content to be compressed.

[0426] In some possible implementations, the processor 510 in the electronic device 500 is further configured to execute a computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0427] If the first source memory address exceeds the preset source memory address limit value, the remaining data blocks after the i-th data block need to be encoded as incompressible content to complete the compression of the memory data to be compressed;

[0428] If the first source memory address does not exceed the preset source memory address limit value, the i+1th data block needs to be compressed.

[0429] In some possible implementations, the first compression speed is determined by an offset of a third source memory address for storing the (i+1)th data block;

[0430] The offset of the third source memory address is determined by the second scanning interval;

[0431] The second scanning interval is determined by a second compression acceleration parameter required for compressing the (i+1)th data block.

[0432] In some possible implementations, if i = 1, with respect to adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression ratio, the processor 510 in the electronic device 500 is configured to execute the computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0433] If the first compression ratio is greater than the preset threshold, it is necessary to increase the first compression speed;

[0434] If the first compression ratio is less than the preset threshold, it is necessary to decrease the first compression speed;

[0435] If the first compression ratio is equal to the preset threshold, it is necessary to keep the first compression speed unchanged.

[0436] In some possible implementations, if 1 < i ≤ N, with respect to adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression ratio, the processor 510 in the electronic device 500 is configured to execute the computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0437] Adjust the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the magnitude relationship between the first compression ratio and the second compression ratio, where the second compression ratio is the compression ratio under the data type to which the (i - 1)-th data block among the N data blocks belongs.

[0438] In some possible implementations, with respect to adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the magnitude relationship between the first compression ratio and the second compression ratio, the processor 510 in the electronic device 500 is configured to execute the computer program or instruction 521 stored in the memory 520 to implement the following steps:

[0439] If the first compression ratio is greater than the second compression ratio, it is necessary to increase the first compression speed;

[0440] If the first compression ratio is less than the second compression ratio, it is necessary to decrease the first compression speed;

[0441] If the first compression ratio is equal to the second compression ratio, it is necessary to keep the first compression speed unchanged.

[0442] 8. Other Exemplary Descriptions

[0443] The embodiments of the present application further provide a computer-readable storage medium, where a computer program or instruction is stored on the computer-readable storage medium, and when the computer program or instruction is executed by a processor, the steps described in the above embodiments are implemented.

[0444] The present application also provides a computer program product, including a computer program or instructions, wherein the computer program or instructions are executed by a processor to implement the steps described in the above embodiment. Exemplarily, the computer program product may be a software installation package.

[0445] In addition, a computer program product should be understood as a software product that mainly implements the technical solution of the present application through computer programs or instructions.

[0446] It should be noted that, for the above-mentioned various embodiments, for the sake of simple description, they are all expressed as a series of action combinations. Those skilled in the art should be aware that the present application is not limited by the described order of actions, because some steps in the embodiments of the present application can be performed in other orders or simultaneously. In addition, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions, steps, modules or units involved are not necessarily required by the embodiments of the present application.

[0447] In the above embodiments, the embodiments of the present application have different focuses on the description of each embodiment. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0448] Those skilled in the art should be aware that the methods, steps or functions of related modules / units described in the embodiments of the present application can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product, or it can be implemented by a processor executing a computer program instruction. Wherein, the computer program product includes at least one computer program instruction, and the computer program instruction can be composed of corresponding software modules, and the software module can be stored in RAM, flash memory, ROM, EPROM, EEPROM, register, hard disk, mobile hard disk, read-only compact disk (CD-ROM) or any other form of storage medium known in the art. The computer program instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer program instruction can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium, or a semiconductor medium (eg, an SSD), etc.

[0449] The modules / units included in the devices or products described in the above embodiments may be software modules / units, hardware modules / units, or may be partially software modules / units and partially hardware modules / units. For example, for each device or product applied to or integrated in a chip, each module / unit included therein may be implemented in the form of hardware such as circuits; or, a portion of the modules / units included therein may be implemented in the form of a software program, which runs on a processor integrated inside the chip, while a portion of the modules / units of another portion (if any) may be implemented in the form of hardware such as circuits. The same is true for each device or product applied to or integrated in a chip module, or each device or product applied to or integrated in a terminal.

[0450] The above specific implementation methods further describe the purpose, technical solutions and beneficial effects of the embodiments of the present application in detail. It should be understood that the above are only specific implementation methods of the embodiments of the present application and are not intended to limit the protection scope of the embodiments of the present application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the embodiments of the present application shall be included in the protection scope of the embodiments of the present application.

Claims

1. A memory data compression method, characterized in that: include: Acquire memory data to be compressed, wherein the memory data to be compressed is composed of data of different data types; Divide the memory data to be compressed into N data blocks, where N is a positive integer; In the case of compressing an i-th data block among the N data blocks, obtaining a first compression acceleration parameter, the first compression acceleration parameter is used to determine a first scanning interval, the first scanning interval is used to determine an offset of a first source memory address for storing the i-th data block, and the offset of the first source memory address is used to determine a second compression speed required for compressing the i-th data block; According to the first compression acceleration parameter, searching for a matching item corresponding to the content to be compressed in the i-th data block, the matching item being the same content as the content to be compressed; When the matching item is found, encoding the content to be compressed to achieve compression of the content to be compressed; When all the contents to be compressed in the i-th data block are compressed, the compression ratio of the data type to which the i-th data block belongs is calculated to obtain a first compression ratio, 1≤i <N; According to the first compression rate, a first compression speed required for compressing the (i+1)th data block among the N data blocks is adjusted.

2. The method according to claim 1, characterized in that The searching, according to the first compression acceleration parameter, for a matching item corresponding to the content to be compressed in the i-th data block includes: Storing the content to be compressed in the i-th data block and the second source memory address for storing the content to be compressed in a hash table; According to the first compression acceleration parameter, a matching item corresponding to the content to be compressed is searched in the hash table.

3. The method according to claim 2, characterized in that Also includes: determining the first scanning distance according to the first compression acceleration parameter; Determine an updated second source memory address according to the offset determined by the first scanning interval; Determining the updated content to be compressed according to the updated second source memory address; The updated second source memory address and the updated content to be compressed are stored in the hash table to update the hash table.

4. The method according to claim 1, characterized in that: The step of encoding the content to be compressed to achieve compression of the content to be compressed includes: Encoding the content to be compressed in a coding format of literal, literal length, offset distance and matching length using a dictionary compression algorithm, and storing the encoded content to be compressed in a first destination memory address to compress the content to be compressed; or, The dictionary compression algorithm is used to encode the content to be compressed in the coding format of the literal length, the literal, the offset distance and the matching length to achieve compression of the content to be compressed; when all the content to be compressed in the i-th data block is compressed, the literal is encoded by the Harman coding algorithm to be stored in the second destination memory address; the literal length, the offset distance and the matching length are encoded by the finite state entropy coding algorithm to be stored in the third destination memory address; The literal meaning is that the content to be compressed is incompressible content; The literal length represents the length of the incompressible content; The offset distance represents the distance between the content to be compressed and the corresponding matching item of the content to be compressed; The matching length represents the length of the matching item corresponding to the content to be compressed.

5. The method according to any one of claims 1 to 4, characterized in that: It further includes: If the first source memory address exceeds the preset source memory address limit value, the remaining data blocks after the i-th data block need to be encoded as incompressible content to complete the compression of the memory data to be compressed; If the first source memory address does not exceed the preset source memory address limit value, the (i + 1)-th data block needs to be compressed.

6. The method according to claim 1, characterized in that The first compression speed is determined by the offset of the third source memory address for storing the (i + 1)-th data block; The offset of the third source memory address is determined by the second scanning interval; The second scanning interval is determined by the second compression acceleration parameter required for compressing the (i + 1)-th data block.

7. The method according to claim 1, characterized in that If i = 1, the adjustment of the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression rate includes: If the first compression rate is greater than the preset threshold, the first compression speed needs to be increased; If the first compression rate is less than the preset threshold, the first compression speed needs to be decreased; If the first compression rate is equal to the preset threshold, the first compression speed needs to be kept unchanged.

8. The method according to claim 1, characterized in that If 1 < i ≤ N, the adjustment of the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression rate includes: Adjust the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the magnitude relationship between the first compression rate and the second compression rate, where the second compression rate is the compression rate under the data type to which the (i - 1)-th data block among the N data blocks belongs.

9. The method according to claim 8, characterized in that The adjustment of the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the magnitude relationship between the first compression rate and the second compression rate includes: If the first compression rate is greater than the second compression rate, the first compression speed needs to be increased; If the first compression rate is less than the second compression rate, the first compression speed needs to be decreased; If the first compression rate is equal to the second compression rate, the first compression speed needs to be kept unchanged.

10. A memory data compression device, characterized in that: It includes: An acquisition unit for acquiring memory data to be compressed, where the memory data to be compressed is composed of data of different data types; A block division unit for dividing the memory data to be compressed into N data blocks, where N is a positive integer; A determination unit for determining the compression rate under the data type to which the i-th data block belongs to obtain the first compression rate when compressing the i-th data block among the N data blocks, where 1 ≤ i < N; An adjustment unit for adjusting the first compression speed required for compressing the (i + 1)-th data block among the N data blocks according to the first compression rate; In determining the compression rate of the data type to which the i-th data block belongs to obtain a first compression rate, the determining unit is used to: Obtaining a first compression acceleration parameter, where the first compression acceleration parameter is used to determine a first scanning interval, where the first scanning interval is used to determine an offset of a first source memory address for storing the i-th data block, where the offset of the first source memory address is used to determine a second compression speed required for compressing the i-th data block; According to the first compression acceleration parameter, searching for a matching item corresponding to the content to be compressed in the i-th data block, the matching item being the same content as the content to be compressed; When the matching item is found, encoding the content to be compressed to achieve compression of the content to be compressed; When all the contents to be compressed in the i-th data block are compressed, a compression ratio of the data type to which the i-th data block belongs is calculated to obtain a first compression ratio.

11. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program or instructions stored in the memory, wherein the processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or instructions, and when the computer program or instructions are executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Method and system for self-adaptation data compression and decompression and storage device

    CN103516369A

  • FPGA code stream data compression method and device and storage medium

    CN112713899A