You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/api-guides/performance/speed.rst
+11-6Lines changed: 11 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -299,15 +299,20 @@ Improving Network Speed
299
299
Improving I/O Performance
300
300
-------------------------
301
301
302
-
Using standard C library functions like ``fread`` and ``fwrite`` instead of platformspecific unbuffered syscalls such as ``read`` and ``write`` can be slow.These functions are designed to be portable, so they are not necessarily optimized for speed, have a certain overhead and are buffered.
302
+
Using standard C library functions like ``fread`` and ``fwrite`` instead of platform-specific unbuffered syscalls such as ``read`` and ``write``, may result in slower performance.
303
303
304
-
:doc:`/api-reference/storage/fatfs` specific information and tips:
304
+
The ``fread`` and ``fwrite`` functions are designed for portability rather than speed, introducing some overhead due to their buffered nature. Check the example :example:`storage/fatfsgen` to see how to use these two functions.
305
+
306
+
In contrast, the ``read`` and ``write`` functions are standard POSIX APIs that can be used directly when working with FatFs through VFS, with ESP-IDF handling the underlying implementation. Check the example :example:`storage/perf_benchmark` to see how to use the two functions.
307
+
308
+
Additional tips are provided below, and further details can be found in :doc:`/api-reference/storage/fatfs`.
305
309
306
310
.. list::
307
311
308
-
- Maximum size of the R/W request = FatFS cluster size (allocation unit size).
309
-
- Use ``read`` and ``write`` instead of ``fread`` and ``fwrite``.
310
-
- To increase speed of buffered reading functions like ``fread`` and ``fgets``, you can increase a size of the file buffer (Newlib's default is 128 bytes) to a higher number like 4096, 8192 or 16384. This can be done locally via the ``setvbuf`` function used on a certain file pointer or globally applied to all files via modifying :ref:`CONFIG_FATFS_VFS_FSTAT_BLKSIZE`.
312
+
- The maximum size of a read/write request is equal to the FatFS cluster size (allocation unit size).
313
+
- For better performance, prefer using ``read`` and ``write`` over ``fread`` and ``fwrite``.
314
+
- To improve the speed of buffered reading functions like ``fread`` and ``fgets``, consider increasing the file buffer size. The default size in Newlibis 128 bytes, but you can increase it to 4096, 8192, or 16384 bytes. This can be made locally using the ``setvbuf`` function for a specific file pointer or globally by modifying the ``CONFIG_FATFS_VFS_FSTAT_BLKSIZE`` setting.
311
315
312
316
.. note::
313
-
Setting a bigger buffer size also increases the heap memory usage.
317
+
318
+
Increasing the buffer size will also increase heap memory usage.
0 commit comments