You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/05/11 13:14:52 UTC

[GitHub] [cassandra] pkolaczk opened a new pull request, #1617: Make LongBufferPoolTest insensitive to timing

pkolaczk opened a new pull request, #1617:
URL: https://github.com/apache/cassandra/pull/1617

   This commit changes the way how LongBufferPoolTest verifies
   that all buffers were freed and recycled. Now, the delay between
   rounds can be arbitrarily short and timing does not affect the
   validity of checks.
   
   Details:
   
   1. LongBufferPoolTest forces all local buffers to be released and
      recycled to the global pool after all buffers had been freed.
      This ensures all allocated and freed buffers will get their lastRecycled
      counter updated. Earlier it was theoretically possible (although
      unlikely) a chunk got stuck in the local pool and never got recycled.
      The test returns many buffers on a different thread than the one that
      allocated them, so the bufferPool cannot recycle such buffers until
      they are evicted from the local pool.
   
   2. LongBufferTest burner thread announces freeing memory not earlier
      than all buffers are really returned to the bufferPool.
      Originally it announced freeing memory immediately
      after all buffers had been taken from the queue, which was not
      equivalent to freeing them. There was a tiny race window where the
      main check of the test (in Debug.check) thought all buffers were
      freed, where in fact they were not.
   
   3. DebugChunk now registers the number of the round when the chunk was
      acquired from the global pool. We have no guarantee all chunks from
      the global pool would be ever acquired by the test - e.g. the global
      pool creates more chunks than needed internally, and they might never
      be given to the test code during a single test round (again:
      unlikely, but possible). Now we only verify "if a chunk was acquired,
      then it is released".
   
   4. The test suspends all threads after they freed the memory completely,
      do the recycling check and then resume all threads. This change has
      many advantages:
   
      * The bufferPool is brought to a consistent, predictable state
        at the moment of the check. It makes it very easy to verify the
        correctness of that state with a debugger.
   
      * We can add a new assertion on memoryInUse == 0, to check if all
        buffers were truly returned to the pool. This makes it more explicit
        that the test is doing the right thing.
        BTW: adding this check uncovered a bug in memoryInUse tracking
        (fixed by a separate commit).
   
      * We don't need the code checking for stalled threads.
        CyclicBarriers do that for us.
   
      * The worker thread code for freeing memory completely was separated
        from the other test code, and it is way easier to reason about.


-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic closed pull request #1617: CASSANDRA-16681: Make LongBufferPoolTest insensitive to timing

Posted by GitBox <gi...@apache.org>.
smiklosovic closed pull request #1617: CASSANDRA-16681: Make LongBufferPoolTest insensitive to timing
URL: https://github.com/apache/cassandra/pull/1617


-- 
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: pr-unsubscribe@cassandra.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org