perf: skip unnecessary main data read in _lx_nand_flash_sector_read#65
perf: skip unnecessary main data read in _lx_nand_flash_sector_read#65borlandong wants to merge 2 commits intoeclipse-threadx:devfrom
Conversation
Merge changes ahead of the 202504 release
3a761e5 to
d5e9ecf
Compare
d5e9ecf to
58dc81e
Compare
|
Hi @borlandong , |
|
just one point, |
|
Hi @rahmanih, Done! I've changed the base branch to Thank you for reviewing! |
|
Hi @rahmanih Driver Implementation Requirement: This performance improvement depends on the LevelX NAND driver properly handling NULL pointers in the Specifically, the driver must:
Example implementation pattern: UINT lx_nand_flash_driver_pages_read(/* parameters */)
{
// Only read main data area if buffer is provided
if (main_buffer != NULL)
{
// Read main data area
}
// Only read spare data area if buffer is provided
if (spare_buffer != NULL)
{
// Read spare data area
}
return LX_SUCCESS;
}Why this matters: The optimization works by passing NULL for Testing: My implementation has been tested on W25N01GV with a driver that properly handles NULL pointers, which is why I achieved the 3.5x read performance improvement. Could you please verify if the reference NAND driver implementation in the test environment handles NULL pointers correctly? If not, I can help update the driver implementation or provide additional documentation on this requirement. Thank you! |
|
Hi @borlandong, working on it! |
|
Hi @rahmanih That's great news! Thank you for testing on STM32 + W25N01GV and confirming it works correctly. I appreciate you taking the time to update the simulator driver to support this change. Please let me know if you need any assistance or clarification during the implementation. Looking forward to seeing this merged! |
Related Issue
Fixes #64
Problem Description
The
_lx_nand_flash_sector_readfunction currently reads both main data area and spare data area when matching logical sector numbers. This is unnecessary since only spare area data is needed for sector matching, resulting in severe performance degradation.Solution
This PR optimizes the sector read logic to:
Implementation Details
Modified function:
_lx_nand_flash_sector_readKey changes:
Driver requirement:
NAND flash drivers must check if the main data area pointer is NULL and skip reading the main data area in that case.
Performance Results
Tested on W25N01GV NAND Flash with LevelX + FileX stack:
Summary:
Testing
Breaking Changes
None. This is a pure performance optimization that maintains backward compatibility.
Additional Notes
This optimization is especially important for read-intensive applications. The 3.5x read performance improvement significantly enhances user experience.