You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "g2gps (via GitHub)" <gi...@apache.org> on 2023/08/23 05:36:45 UTC

[GitHub] [nuttx] g2gps opened a new pull request, #10358: libc/libfread: Use memcpy to copy read-ahead buffer to caller buffer.

g2gps opened a new pull request, #10358:
URL: https://github.com/apache/nuttx/pull/10358

   ## Summary
   
   This change improves the performance when using larger CONFIG_STDIO_BUFFER_SIZE values as it allows architecture specific, or optimized memcpy algorithms to be utilized.
   
   ## Impact
   
   Improved fread performance when using larger CONFIG_STDIO_BUFFER_SIZE. 
   
   Using our platform, based on the arty-a7, and a stdio buffer of 4096:
   
   Before this change:
   ```
   Operation              Variant          Size         Mean         Max          Min          Throughput(s)    Repetitions  Handles      Status
   file_write             sequential       1.00B        361.16us     1.18ms       352.02us     2.70KB           100          1            0
   file_read              sequential       1.00B        448.54us     8.97ms       358.58us     2.18KB           100          1            0
   file_write             sequential       64.00B       374.41us     1.77ms       358.52us     166.93KB         100          1            0
   file_read              sequential       64.00B       501.63us     9.02ms       407.98us     124.59KB         100          1            0
   file_write             sequential       512.00B      1.13ms       24.45ms      373.62us     442.94KB         100          1            0
   file_read              sequential       512.00B      1.32ms       17.50ms      759.34us     379.96KB         100          1            0
   file_write             sequential       4.00KB       6.89ms       32.57ms      701.91us     580.49KB         32           1            0
   file_read              sequential       4.00KB       6.84ms       20.34ms      4.00ms       584.47KB         32           1            0
   ```
   
   With this change:
   ```
   Operation              Variant          Size         Mean         Max          Min          Throughput(s)    Repetitions  Handles      Status
   file_write             sequential       1.00B        353.59us     430.28us     352.02us     2.76KB           100          1            0
   file_read              sequential       1.00B        455.58us     8.99ms       367.40us     2.14KB           100          1            0
   file_write             sequential       64.00B       373.31us     1.67ms       358.52us     167.42KB         100          1            0
   file_read              sequential       64.00B       464.97us     8.99ms       372.56us     134.42KB         100          1            0
   file_write             sequential       512.00B      1.12ms       24.47ms      373.62us     447.83KB         100          1            0
   file_read              sequential       512.00B      939.14us     17.13ms      390.22us     532.40KB         100          1            0
   file_write             sequential       4.00KB       6.89ms       31.25ms      701.91us     580.52KB         32           1            0
   file_read              sequential       4.00KB       3.75ms       17.27ms      920.49us     1.04MB           32           1            0
   ```
   
   ## Testing
   
   - sim:ostest. Exits with status 0.
   - sim:nsh with `CONFIG_TESTING_SMART_TEST` enabled
   
   ```
   nsh> smart_test -c 2000 /tmp/test
   Creating file /tmp/test for write mode
   Writing test data.  128 lines to write
   127
   Done.
   
   Append test failed
   Performing 128 random seek with write tests
   127
   Pass
   Creating circular log with 40000 records
   Performing 2000 circular log record update tests
   1999
   Pass
   ```
   
   Note: The append test fails before and after this commit. I don't believe it's related to this change. 
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] g2gps commented on a diff in pull request #10358: libc/libfread: Use memcpy to copy read-ahead buffer to caller buffer.

Posted by "g2gps (via GitHub)" <gi...@apache.org>.
g2gps commented on code in PR #10358:
URL: https://github.com/apache/nuttx/pull/10358#discussion_r1303618443


##########
libs/libc/stdio/lib_libfread.c:
##########
@@ -121,12 +122,25 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
             {
               /* Is there readable data in the buffer? */
 
-              while (remaining > 0 && stream->fs_bufpos < stream->fs_bufread)
+              gulp_size = stream->fs_bufread - stream->fs_bufpos;
+
+              /* Avoid empty buffers or read requests greater than the size
+               *  buffer remaining
+               */
+
+              if (gulp_size <= CONFIG_STDIO_BUFFER_SIZE || count < gulp_size)

Review Comment:
   Thanks, that's a good change.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 merged pull request #10358: libc/libfread: Use memcpy to copy read-ahead buffer to caller buffer.

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #10358:
URL: https://github.com/apache/nuttx/pull/10358


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #10358: libc/libfread: Use memcpy to copy read-ahead buffer to caller buffer.

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #10358:
URL: https://github.com/apache/nuttx/pull/10358#discussion_r1303249802


##########
libs/libc/stdio/lib_libfread.c:
##########
@@ -51,6 +51,7 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
   size_t remaining = count;
 #ifndef CONFIG_STDIO_DISABLE_BUFFERING
   int ret;
+  size_t gulp_size;

Review Comment:
   move before line 53



##########
libs/libc/stdio/lib_libfread.c:
##########
@@ -121,12 +122,25 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
             {
               /* Is there readable data in the buffer? */
 
-              while (remaining > 0 && stream->fs_bufpos < stream->fs_bufread)
+              gulp_size = stream->fs_bufread - stream->fs_bufpos;
+
+              /* Avoid empty buffers or read requests greater than the size
+               *  buffer remaining
+               */
+
+              if (gulp_size <= CONFIG_STDIO_BUFFER_SIZE || count < gulp_size)

Review Comment:
   ```suggestion
                 if (gulp_size > 0)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] pkarashchenko commented on pull request #10358: libc/libfread: Use memcpy to copy read-ahead buffer to caller buffer.

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on PR #10358:
URL: https://github.com/apache/nuttx/pull/10358#issuecomment-1690534498

   Please rebase changes on top of the latest master


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org