-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #61: Add Phaser in favor of a custom count and lock solution to Access and BufferLeaseImpl classes #70
Conversation
…se> and Supplier<Lease>.
…re than 1 instead of zero as Phaser inits at 1, not 0.
phaser.arriveAndDeregister(); | ||
} | ||
|
||
public boolean closed() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is closed() extra?
finally { | ||
lock.unlock(); | ||
} | ||
phaser.arriveAndDeregister(); | ||
} | ||
|
||
@Override | ||
public boolean isRefCountZero() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this must be changed so that it checks if the phaser isTerminated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix 334d130
@@ -28,13 +29,8 @@ public long id() { | |||
|
|||
@Override | |||
public long refs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be removed or at least marked as unreliable because phaser is a lock free structure so ref count should be only used for debug logging
public final class Rental implements AutoCloseable, Consumer<Lease>, Supplier<Lease> { | ||
|
||
private final Phaser phaser; | ||
private boolean closed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is extra, should return phaser.isTerminated() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return phaser.isTerminated: 334d130
@@ -1,12 +1,12 @@ | |||
package com.teragrep.rlp_03.context.frame.access; | |||
package com.teragrep.rlp_03.context.frame.rental; | |||
|
|||
public class Lease implements AutoCloseable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be refactored so that it uses a sub-phaser that is registered to the parent?
currently is broken, buffer is likely to be contaminated accross the threads:
i suspect the attemptRelease() is broken because clear() is not ensured by happens-before relationship of phaser.isTerminated() |
…rk BufferLeaseImpl.refs as unreliable, change Rental.closed() to return phaser.isTerminated
there are test failures now |
Note: RentalTest contains IllegalStateException assert that does not seem to happen, commented out for now.
seem to pass tests locally, however "RentalTest contains IllegalStateException assert that does not seem to happen, commented out for now." in 38ec3d0 add sub phaser to Lease |
Regarding BufferLeaseImpl, it might be appropriate to store cleared buffers
in the pool and take new Leases (with new phasers) for them when taking out
from the pool because phasers are terminated when returning.
pe 23. helmik. 2024 klo 10.52 eemhu ***@***.***> kirjoitti:
… seem to pass tests locally, however "RentalTest contains
IllegalStateException assert that does not seem to happen, commented out
for now." in 38ec3d0
<38ec3d0>
add sub phaser to Lease
—
Reply to this email directly, view it on GitHub
<#70 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGX2OTGWTTALPQULM5SL4LYVBKFRAVCNFSM6AAAAABDQYGTNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQHE2DEMZSHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@kortemik |
… with the pre-existing buffer and id.
I think it might be appropriate to use the decorator pattern for solving
this. One would have a decorator class with the phaser and do new
PhaserDecoratedBufferLeaseImpl(BufferLease bl) implements BufferLease.
Please create it so that only the terminated ones return the encapsulated
BufferLeaseImpl, otherwise a static stub is returned. This way I think the
code retains the responsibility assignment principle. I wonder if you think
this way too?
ma 26. helmik. 2024 klo 12.44 eemhu ***@***.***> kirjoitti:
… Regarding BufferLeaseImpl, it might be appropriate to store cleared
buffers in the pool and take new Leases (with new phasers) for them when
taking out from the pool because phasers are terminated when returning. pe
23. helmik. 2024 klo 10.52 eemhu *@*.
*> kirjoitti: … <#m_-7089496626781693482_> seem to pass tests locally,
however "RentalTest contains IllegalStateException assert that does not
seem to happen, commented out for now." in 38ec3d0
<38ec3d0>
<38ec3d0
<38ec3d0>>
add sub phaser to Lease — Reply to this email directly, view it on GitHub
<#70 (comment)
<#70 (comment)>>, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAGX2OTGWTTALPQULM5SL4LYVBKFRAVCNFSM6AAAAABDQYGTNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQHE2DEMZSHE
<https://github.com/notifications/unsubscribe-auth/AAGX2OTGWTTALPQULM5SL4LYVBKFRAVCNFSM6AAAAABDQYGTNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQHE2DEMZSHE>
. You are receiving this because you commented.Message ID: @.*>
Should BufferLeasePool.take() check the polled BufferLease for terminated
Phaser and create a new BufferLeaseImpl in that case as well? Currently
there is a null-check only.
—
Reply to this email directly, view it on GitHub
<#70 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGX2OQGEGMVRE4QFY63BODYVRRPPAVCNFSM6AAAAABDQYGTNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRTHAZDCNJYGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
…rnalOffer, add stub unless phaser was terminated explicitly
moved phaser to use decorator pattern |
Does it differ much from the Rental+Lease? If we'd generify Rental would it
fit?
ti 27. helmik. 2024 klo 15.47 eemhu ***@***.***> kirjoitti:
… moved phaser to use decorator pattern PhaserDecoratedBufferLease which
contains the phaser-related ops and BufferLeaseImplcontains the buffer
itself.
—
Reply to this email directly, view it on GitHub
<#70 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGX2OWL3FXV75F327DJ3ILYVXPWTAVCNFSM6AAAAABDQYGTNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRWGU4DQMJYHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
TODO:
Possibly:
|
removed comparisons from phaser related classes, added synchronized keyword to bufferLeaseImpl.buffer() and removed lock. Add phaser decoration when polling from queue and remove when adding back to queue. |
Perhaps the offer() method should take in type of PhaserDecoratedBufferLease so we can get rid of instanceof check? |
Yes, this could be changed so that it accepts only decorated ones, as they
are the only type out there:
public void offer(BufferLease bufferLease) {
to 29. helmik. 2024 klo 10.28 eemhu ***@***.***> kirjoitti:
… Perhaps the queue should take in type of PhaserDecoratedBufferLease so we
can get rid of instanceof check?
—
Reply to this email directly, view it on GitHub
<#70 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGX2OU4FI3IY3T76IRQKWLYV3TBXAVCNFSM6AAAAABDQYGTNSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZQGY2DGNRRG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
…Lease to BufferContainer. Pool holds BufferContainers and wraps them in BufferLeases while out of the queue.
Changed PhaserDecoratedBufferLease to be simply called BufferLease, and changed previous BufferLease to be BufferContainer. Now the pool will only contain BufferContainers, and they are wrapped in BufferLeases when taking them out of the pool. |
please separate the Access -> Rental to different pr, close this one and open new ones for these both. |
running with the a1534ed following agains the ManualPerformanceTest:
gives
while main branch does not. @StrongestNumber9 please check the rlp_09 pr tests so that they will reproduce this. @eemhu please check why this differs from main branch. this utility is provided from rsyslog project via fail-safe-rsyslog-8.2102.2-1558.fc34.x86_64.rpm, one can obtain it from nexus. |
adding |
would make sense considering the main branch version uses a lock there. |
… to fix dirty buffer in pool.
Is this still relevant as
|
#61
Note: This PR is a draft