Skip to content

Operation counter for IndexShard#15956

Closed
ywelsch wants to merge 1 commit intoelastic:masterfrom
ywelsch:feature/releasable-fair-semaphore
Closed

Operation counter for IndexShard#15956
ywelsch wants to merge 1 commit intoelastic:masterfrom
ywelsch:feature/releasable-fair-semaphore

Conversation

@ywelsch
Copy link
Copy Markdown
Contributor

@ywelsch ywelsch commented Jan 13, 2016

Relates to the request in #15900.

Container that represents a resource with reference counting capabilities. Provides operations to suspend acquisition of new references. Useful for resource management when resources are intermittently unavailable.

Using a fair semaphore is based on the following (tested) observations:

  • as long as permits can be freely acquired, no noticeable performance difference between fair and non-fair version of semaphore.
  • when suspending acquisition of new references, it is important that the process acquiring all locks does not starve. This can only be guaranteed by fair semaphore.
  • the given implementation does 10 million (acquire, release) operations per second on my laptop (tested with 50 concurrent threads). Should be fast enough ;-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this correct, but can we use semaphore.tryAcquire(1,0,TimeUnits.SECONDS) - It got me worried that we ask for 0 permits :)

@bleskes
Copy link
Copy Markdown
Contributor

bleskes commented Jan 15, 2016

Thanks @ywelsch. I left some very minor comments.

@ywelsch
Copy link
Copy Markdown
Contributor Author

ywelsch commented Jan 15, 2016

Pushed a new change set addressing comments. Please have another look @bleskes.

@bleskes
Copy link
Copy Markdown
Contributor

bleskes commented Jan 17, 2016

LGTM

Adds a container that represents a resource with reference counting capabilities. Provides operations to suspend acquisition of new references. Useful for resource management when resources are intermittently unavailable.

Closes elastic#15956
@ywelsch ywelsch force-pushed the feature/releasable-fair-semaphore branch from 3f06f5b to 600521e Compare January 18, 2016 09:42
@ywelsch ywelsch closed this in e1006ea Feb 2, 2016
@ywelsch ywelsch added :Distributed/Recovery Anything around constructing a new shard, either from a local or a remote source. v5.0.0-alpha1 labels Feb 2, 2016
@ywelsch ywelsch deleted the feature/releasable-fair-semaphore branch February 2, 2016 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Recovery Anything around constructing a new shard, either from a local or a remote source. >enhancement v5.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants