<div dir="ltr">Hi<div><br></div><div>In some recent discussions, the maximum file size supported </div><div>by the IMFS came up. I proposed increasing the allowed block</div><div>size from the maximum of 512. When asked what the impact</div><div>on maximum file size would be, I decided to hack the imfs.h</div><div>macros into a simple test program. When I ran that program</div><div>natively, it didn't produce the same maximum file sizes in</div><div>imfs.h. After some investigation, it occurred to me that the</div><div>native pointer was 64-bits and the maximum file sizes were</div><div>computed based on 32-bit pointers to the malloc'ed blocks.</div><div><br></div><div><div>$ ./imfs_size    # source attached</div><div><br></div><div>=========== Pointer = 4 bytes ===========</div><div>16 ==> 1328 or < 1MB</div><div>32 ==> 18656 or < 1MB</div><div>64 ==> 279488 or < 1MB</div><div>128 ==> 4329344 or 4MB</div><div>256 ==> 68173568 or 65MB</div><div>512 ==> 1082195456 or 1032MB</div><div>1024 ==> 17247239168 or 16448MB</div><div>2048 ==> 275415824384 or 262656MB</div><div><br></div><div>=========== Pointer = 8 bytes ===========</div><div>16 ==> 208 or < 1MB</div><div>32 ==> 2656 or < 1MB</div><div>64 ==> 37312 or < 1MB</div><div>128 ==> 558976 or < 1MB</div><div>256 ==> 8658688 or 8MB</div><div>512 ==> 136347136 or 130MB</div><div>1024 ==> 2164390912 or 2064MB</div><div>2048 ==> 34494478336 or 32896MB</div></div><div><br></div><div>What this means is that on target architectures with 64-bit pointers</div><div>the maximum file size is much smaller.</div><div><br></div><div>I am proposing two things:</div><div><br></div><div>(1) that the default block size (128 now) be dependent on </div><div>whether __SIZEOF_POINTER__ is 4 or 8.</div><div><br></div><div>(2) that the maximum block size be increased from 512 to at</div><div>least 2048. On 32-bit pointer targets, this is ridiculously large and </div><div>on 64-bit targets, it should be large enough for any foreseeable </div><div>use case.</div><div><br></div><div>At the risk of increased complexity, the maximum block size could</div><div>be conditional on pointer size also. 512 for 32-bit pointers and</div><div>2K for 64-bit pointers. But I think 2K blocks has efficiency improvements</div><div>because it reduces the number of allocations and per allocation</div><div>overhead so I don't want to do this.</div><div><br></div><div>I am prone to even allow 4K blocks based on allocation efficiency.</div><div>The maximum filesize is likely larger than available RAM on many </div><div>boards anyway.</div><div><br></div><div>Thanks.</div><div><br></div><div>--joel</div></div>