Method, system and device for optimizing SSD log record and medium
By removing descriptive characters and formatting strings from SSD log printing functions, establishing mapping relationships, and generating a log retrieval table, the problem of log space consumption is solved, achieving efficient log utilization and lossless restoration.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU XINSHENG INTELLIGENT TECH CO LTD
- Filing Date
- 2026-04-09
- Publication Date
- 2026-05-12
AI Technical Summary
In existing technologies, SSD logging occupies a large amount of code space and log space, and always-on characters lead to logging risks and wasted space, which cannot be effectively solved by existing methods.
By removing descriptive characters and format strings from the log printing function, retaining key parameters, and establishing a mapping relationship between descriptive characters and format strings, a log retrieval table is generated. The retrieval table is then used to parse and simplify the logs to restore the true logs.
It reduces the code space of the compiled executable file, improves log space utilization, achieves lossless compression and restoration of logs, and improves the efficiency of log analysis.
Smart Images

Figure CN122019330A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of solid-state drive (SSD) log management technology, specifically to a method, system, device, and medium for optimizing SSD log recording. Background Technology
[0002] In SSD (Solid State Drive) systems, it's common practice to log important processes and points of failure, especially exception handling. Logs are also a crucial tool for analyzing disk issues. However, with the introduction of new features and increased system complexity, the space occupied by logs also increases significantly. Since logs are generated alongside the executable file during compilation, especially constant characters containing descriptors and format strings, they require a certain amount of code space, typically around 15% of the total code space. Furthermore, log descriptors are also printed and recorded in the logging system, with constant characters accounting for approximately 50%. Over extended system operation, this further encroaches on log space.
[0003] This approach presents several problems. First, printing constant strings from functions will occupy code space. Second, printing these constant strings reduces the number of log entries, posing a risk of overwriting logs. Third, if invalid characters are too long, the logging system limits the length of a single log entry, potentially causing the log to be interrupted.
[0004] Typically, reducing the number of constant log entries or limiting the use of log printing functions can shorten the descriptive characters, but this increases readability. Limiting log printing means omitting print statements in unnecessary processes, but this makes it difficult to determine whether removing a particular entry is appropriate, and it's not advisable to blindly remove log entries containing location information. None of these methods fundamentally solve the problems of code space usage and log space consumption. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method, system, device and medium for optimizing SSD logging.
[0006] The objective of this invention is achieved through the following technical solution: Firstly, this application discloses a method for optimizing SSD logging, including: Remove the description characters and format strings from the original log printing function, retain the key parameters, and add search fields; Print simplified logs containing search fields and key parameters; Establish a mapping relationship between description characters, format strings, and search fields to generate a log search table; Based on the log retrieval table, simplified logs are parsed using tools or scripts to restore the true log output.
[0007] Based on the first aspect, the log retrieval table is used to implement bidirectional retrieval of retrieval fields and descriptive characters / format strings.
[0008] Based on the first aspect, the bidirectional retrieval includes: Searching for fields based on description characters / format strings allows for quick identification of whether certain logs of interest exist in simplified logs, enabling rapid problem delimitation. The system searches for descriptive characters / format strings based on search fields. It retrieves the descriptive characters from the original log using the search fields, then parses and processes the found format strings to restore the actual log output.
[0009] Based on the first aspect, the parsing of the simplified log specifically includes: Based on the retrieval fields of the simplified log, search the log retrieval table for the description characters and format strings in the original log printing function; The key parameters are parsed based on the format string to make them conform to the printing format of a real log. The key parameters are parsed according to the format string and then concatenated with the description characters to ensure that the semantics are the same as the actual log printout.
[0010] Secondly, this application discloses a system for optimizing SSD logging, and the method for optimizing SSD logging described above includes: The log simplification module is used to optimize the original SSD log printing function, removing its description characters and format strings, retaining key parameters, and adding search fields to generate simplified logs; The retrieval table generation module is used to generate a log retrieval table based on the mapping relationship between the log description characters / format strings and the retrieval fields in the original code. The log retrieval table supports bidirectional retrieval between the retrieval fields and the description characters / format strings. Log restoration module: Used to parse and restore simplified logs using tools or scripts based on the log retrieval table to obtain the real logs.
[0011] Thirdly, this application discloses a computer storage medium storing a computer program, which is executed by a processor to implement the method described above.
[0012] Fourthly, this application discloses an electronic device, the electronic device comprising: Memory, which stores executable instructions; A processor that executes the executable instructions in the memory to implement the method described above.
[0013] The beneficial effects of this invention are: 1) This application prints only the key parameters during printing, omitting the rest of the descriptive characters (including format strings), thereby achieving the effect of not compiling the descriptive characters during the compilation stage, reducing the code space of the compiled executable file, reducing the code space consumption of the logging function, improving the utilization rate of the logging space, and at the same time, the logging is compressed and restored without loss. Attached Figure Description
[0014] Figure 1 This is a flowchart illustrating a method for optimizing SSD logging according to an embodiment of the present invention. Figure 2 This is a schematic diagram of the retrieval method of the log retrieval table in an embodiment of the present invention. Detailed Implementation
[0015] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0016] This application discloses a method for optimizing SSD logging, the flowchart of which is shown below. Figure 1 As shown, the specific steps include: The descriptive characters and format strings in the original log printing function are removed, while key parameters are retained, and a search field is added. The descriptive characters describe the context of the log entry and uniquely locate its position in the source code. The format strings control the printing format, making the log easier for analysts and debuggers to read. Key parameters record crucial parameters from the context, helping analysts understand the logical relationships within the context. For a single log entry, it's important for analysis engineers to know the source code location of the log and the key parameters printed in the runtime context. Therefore, only the key parameters and the log's location in the source code are needed for problem analysis, but such logs are not easy to read. By printing only key parameters and omitting the remaining descriptive characters (including format strings), the descriptive characters are not compiled during the compilation phase, reducing the code space of the compiled executable file. This field is only available for viewing or searching in the source code, thus reducing the code space occupied by log printing. The simplified log containing the search fields and key parameters is printed. Since the simplified log does not have description characters and format strings during compilation and printing, the description characters and format strings need to participate in the compilation as string constants. Removing this part saves about 10% of the code space. The logs recorded on SSD and stored in NAND also do not have this constant character, which greatly improves the utilization of log space. Considering that strings account for about 50%, the log space utilization is improved by about 50% compared to before optimization. Since the simplified log lacks descriptive character parsing, a mapping relationship is established between descriptive characters, format strings, and search fields to generate a log retrieval table. By searching the log retrieval table, the actual log print can be restored. That is, the original descriptive characters can be found through the simplified log based on the mapping relationship, and the actual log print (including descriptive characters) can be parsed based on the key parameters. The simplified log only contains retrieval fields and key parameter fields, which is inconvenient to read. It needs to be parsed and restored according to the original printing format. The parsing method is to first retrieve the description field in the source file through the mapping relationship, and then parse and restore the log based on the description field.
[0017] For example, a mapping relationship between description characters / format strings and search fields can be implemented, such as searching by function plus line number, searching by unique ID, searching by file plus line number, etc. That is, the original description characters (including format strings) can be found by searching the search fields. The specific search method can be adjusted according to the specific implementation.
[0018] For example, the generated log retrieval table is shown in Table 1. The log retrieval table can be used to implement bidirectional retrieval of retrieval fields and description characters / format strings.
[0019] Table 1: Log Retrieval Table
[0020] For example, a schematic diagram of the retrieval method for the log retrieval table is shown below. Figure 2 As shown, the bidirectional retrieval includes: Searching for fields based on description characters / format strings allows for quick identification of whether certain logs of interest exist in simplified logs, enabling rapid problem delimitation; such as confirming critical logs such as assertions and dumps. The system searches for descriptive characters / formatted strings based on search fields. It then retrieves the descriptive characters from the original log, parses the found formatted strings, and reconstructs the actual log output. Furthermore, the log retrieval table is generated by a tool and operates independently of the compiled code, ensuring uninterrupted system stability.
[0021] For example, the actual log printout is restored by parsing the log retrieval table using tools or scripts. Since simplified logs only print the search fields and key parameters, lacking descriptive characters and format strings, and the simplified log printout format may differ from the original log printout format, making it inconvenient to read, it is necessary to query the log retrieval table for each log entry based on the search fields to obtain the original log's descriptor and format string. Then, simple format parsing and character concatenation are performed to restore the actual log. The specific parsing of simplified logs includes: Based on the retrieval fields of the simplified log, search the log retrieval table for the description characters and format strings in the original log printing function; The key parameters of the simplified log printing may differ from the printing format in the original log. The key parameters are parsed based on the format string to make them conform to the printing format of the real log. The key parameters are parsed according to the format string and then concatenated with the description characters to ensure that the semantics are the same as the actual log printout.
[0022] For example, if the simplified logs are printed in hexadecimal for convenience, while the original log format needs to be displayed in decimal, the key parameters are parsed according to the original format string format to make them conform to the actual log printing format.
[0023] For example, the original log was printed as: Printf(“This is a very important Param1 0x%xParam2 0x%x while exception occur!”, para1, para2); According to the log printing format, the original log should be stored as: "This is a very important Param10x1234 Param2 0x5678 while exception occurs!"; Simplify log storage and print the simplified log. The log only contains the search fields and key parameters. The actual recorded log is "search field + 0x1234 0x5678". Log retrieval: Based on the search fields in the simplified log, the constant string in the original log can be retrieved as "This is a very important Param1 0x%x Param2 0x%x while exception occurs!"; Log parsing and restoration: Parse the simplified log based on the retrieved string; "Search field + 0x12340x5678" ===> "This is a very important Param1 0x1234 Param2 0x5678 while exception occurs!".
[0024] For example, this application discloses a system for optimizing SSD logging, and the method for optimizing SSD logging described above includes: The log simplification module is used to optimize the original SSD log printing function, removing its description characters and format strings, retaining key parameters, and adding search fields to generate simplified logs; The retrieval table generation module is used to generate a log retrieval table based on the mapping relationship between the log description characters / format strings and the retrieval fields in the original code. The log retrieval table supports bidirectional retrieval between the retrieval fields and the description characters / format strings. Log restoration module: Used to parse and restore simplified logs using tools or scripts based on the log retrieval table to obtain the real logs.
[0025] For example, this application discloses a computer storage medium storing a computer program that is executed by a processor to implement the method described above.
[0026] For example, this application discloses an electronic device, the electronic device comprising: Memory, which stores executable instructions; A processor that executes the executable instructions in the memory to implement the method described above.
[0027] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.
Claims
1. A method for optimizing SSD logging, characterized in that, include: Remove the description characters and format strings from the original log printing function, retain the key parameters, and add search fields; Print simplified logs containing search fields and key parameters; Establish a mapping relationship between description characters, format strings, and search fields to generate a log search table; Based on the log retrieval table, simplified logs are parsed using tools or scripts to restore the true log output.
2. The method for optimizing SSD logging according to claim 1, characterized in that: The log retrieval table is used to enable bidirectional retrieval of search fields and description characters / format strings.
3. The method for optimizing SSD logging according to claim 2, characterized in that: The bidirectional retrieval includes: Searching for fields based on description characters / format strings allows for quick identification of whether certain logs of interest exist in simplified logs, enabling rapid problem delimitation. The system searches for descriptive characters / format strings based on search fields. It retrieves the descriptive characters from the original log using the search fields, then parses and processes the found format strings to restore the actual log output.
4. The method for optimizing SSD logging according to claim 1, characterized in that: The parsing of simplified logs specifically includes: Based on the retrieval fields of the simplified log, search the log retrieval table for the description characters and format strings in the original log printing function; The key parameters are parsed based on the format string to make them conform to the printing format of a real log. The key parameters are parsed according to the format string and then concatenated with the description characters to ensure that the semantics are the same as the actual log printout.
5. A system for optimizing SSD logging, employing the method for optimizing SSD logging as described in any one of claims 1-4, characterized in that, include: The log simplification module is used to optimize the original SSD log printing function, removing its description characters and format strings, retaining key parameters, and adding search fields to generate simplified logs; The retrieval table generation module is used to generate a log retrieval table based on the mapping relationship between the log description characters / format strings and the retrieval fields in the original code. The log retrieval table supports bidirectional retrieval between the retrieval fields and the description characters / format strings. Log restoration module: Used to parse and restore simplified logs using tools or scripts based on the log retrieval table to obtain the real logs.
6. An electronic device, characterized in that, The electronic device includes: Memory, which stores executable instructions; A processor that executes the executable instructions in the memory to implement the method of any one of claims 1-4.
7. A computer storage medium, characterized in that, The medium stores a computer program, which is executed by a processor to implement the method described in any one of claims 1-4.