littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
4.9k stars 771 forks source link

Add inline_max, to optionally limit the size of inlined files #914

Closed geky closed 5 months ago

geky commented 6 months ago

Inlined files live in metadata and decrease storage requirements, but may be limited to improve metadata-related performance. This is especially important given the current plague of metadata performance.

Though decreasing inline_max may make metadata more dense and increase block usage, so it's important to benchmark if optimizing for speed.

The underlying limits of inlined files haven't changed:

  1. Inlined files need to fit in RAM, so <= cache_size
  2. Inlined files need to fit in a single attr, so <= attr_max
  3. Inlined files need to fit in 1/8 of a block to avoid metadata overflow issues, this is after limiting by metadata_max, so <= min(metadata_max, block_size)/8

By default, the largest possible inline_max is used. This preserves backwards compatibility and is probably a good default for most use cases.

This does have the awkward effect of requiring inline_max=-1 to indicate disabled inlined files, but I don't think there's a good way around this.

geky-bot commented 6 months ago
Tests passed ✓, Code: 16812 B (-0.0%), Stack: 1448 B (+0.0%), Structs: 808 B (+1.0%) | | Code | Stack | Structs | | Coverage | |:--|-----:|------:|--------:|:--|---------:| | Default | 16812 B (-0.0%) | 1448 B (+0.0%) | 808 B (+1.0%) | Lines | 2362/2538 lines (+0.0%) | | Readonly | 6186 B (+0.9%) | 448 B (+0.0%) | 808 B (+1.0%) | Branches | 1215/1546 branches (-0.1%) | | Threadsafe | 17680 B (-0.0%) | 1448 B (+0.0%) | 816 B (+1.0%) | | **Benchmarks** | | Multiversion | 16876 B (-0.0%) | 1448 B (+0.0%) | 812 B (+1.0%) | Readed | 29369693876 B (+0.0%) | | Migrate | 18504 B (+0.0%) | 1752 B (+0.0%) | 812 B (+1.0%) | Proged | 1482874766 B (+0.0%) | | Error-asserts | 17496 B (+0.1%) | 1440 B (+0.0%) | 808 B (+1.0%) | Erased | 1568888832 B (+0.0%) |
geky-bot commented 5 months ago
Tests passed ✓, Code: 16964 B (-0.0%), Stack: 1432 B (+0.0%), Structs: 812 B (+1.0%) | | Code | Stack | Structs | | Coverage | |:--|-----:|------:|--------:|:--|---------:| | Default | 16964 B (-0.0%) | 1432 B (+0.0%) | 812 B (+1.0%) | Lines | 2385/2564 lines (-0.0%) | | Readonly | 6186 B (+0.9%) | 448 B (+0.0%) | 812 B (+1.0%) | Branches | 1236/1574 branches (-0.1%) | | Threadsafe | 17828 B (-0.0%) | 1432 B (+0.0%) | 820 B (+1.0%) | | **Benchmarks** | | Multiversion | 17028 B (-0.0%) | 1432 B (+0.0%) | 816 B (+1.0%) | Readed | 29369693876 B (+0.0%) | | Migrate | 18656 B (+0.0%) | 1736 B (+0.0%) | 816 B (+1.0%) | Proged | 1482874766 B (+0.0%) | | Error-asserts | 17652 B (+0.1%) | 1424 B (+0.0%) | 812 B (+1.0%) | Erased | 1568888832 B (+0.0%) |