New buffers performance tuning option added.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12456 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
Giovanni Di Sirio 2018-12-02 15:09:24 +00:00
parent 559b4aa2d3
commit 0f8c6b90f7
2 changed files with 24 additions and 10 deletions

View File

@ -33,10 +33,24 @@
/* Driver pre-compile time settings. */ /* Driver pre-compile time settings. */
/*===========================================================================*/ /*===========================================================================*/
/**
* @brief Maximum size of blocks copied in critical sections.
* @note Increasing this value increases performance at expense of
* IRQ servicing efficiency.
* @note It must be a power of two.
*/
#if !defined(BUFFERS_CHUNKS_SIZE) || defined(__DOXYGEN__)
#define BUFFERS_CHUNKS_SIZE 64
#endif
/*===========================================================================*/ /*===========================================================================*/
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*===========================================================================*/
#if (BUFFERS_CHUNKS_SIZE & (BUFFERS_CHUNKS_SIZE - 1)) != 0
#error "BUFFERS_CHUNKS_SIZE must be a power of two"
#endif
/*===========================================================================*/ /*===========================================================================*/
/* Driver data structures and types. */ /* Driver data structures and types. */
/*===========================================================================*/ /*===========================================================================*/

View File

@ -388,12 +388,12 @@ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
/* Smaller chunks in order to not make the critical zone too long, /* Smaller chunks in order to not make the critical zone too long,
this impacts throughput however.*/ this impacts throughput however.*/
if (size > 64U) { if (size > (size_t)BUFFERS_CHUNKS_SIZE) {
/* Giving the compiler a chance to optimize for a fixed size move.*/ /* Giving the compiler a chance to optimize for a fixed size move.*/
memcpy(bp, ibqp->ptr, 64U); memcpy(bp, ibqp->ptr, BUFFERS_CHUNKS_SIZE);
bp += 64U; bp += (size_t)BUFFERS_CHUNKS_SIZE;
ibqp->ptr += 64U; ibqp->ptr += (size_t)BUFFERS_CHUNKS_SIZE;
r += 64U; r += (size_t)BUFFERS_CHUNKS_SIZE;
} }
else { else {
memcpy(bp, ibqp->ptr, size); memcpy(bp, ibqp->ptr, size);
@ -751,12 +751,12 @@ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
/* Smaller chunks in order to not make the critical zone too long, /* Smaller chunks in order to not make the critical zone too long,
this impacts throughput however.*/ this impacts throughput however.*/
if (size > 64U) { if (size > (size_t)BUFFERS_CHUNKS_SIZE) {
/* Giving the compiler a chance to optimize for a fixed size move.*/ /* Giving the compiler a chance to optimize for a fixed size move.*/
memcpy(obqp->ptr, bp, 64U); memcpy(obqp->ptr, bp, (size_t)BUFFERS_CHUNKS_SIZE);
bp += 64U; bp += (size_t)BUFFERS_CHUNKS_SIZE;
obqp->ptr += 64U; obqp->ptr += (size_t)BUFFERS_CHUNKS_SIZE;
w += 64U; w += (size_t)BUFFERS_CHUNKS_SIZE;
} }
else { else {
memcpy(obqp->ptr, bp, size); memcpy(obqp->ptr, bp, size);