Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

SpinLock.TryEnter fail fast for timeout 0#6911

Closed
benaadams wants to merge 4 commits into
dotnet:masterfrom
benaadams:spinlock-failfast
Closed

SpinLock.TryEnter fail fast for timeout 0#6911
benaadams wants to merge 4 commits into
dotnet:masterfrom
benaadams:spinlock-failfast

Conversation

@benaadams
Copy link
Copy Markdown
Member

@benaadams benaadams commented Aug 25, 2016

Passes corefx tests

1M iters (single thread, uncontended but locked) for code

bool lockTaken = false;
var s = new SpinLock(false);
s.Enter(ref lockTaken);
method pre (ms) post (ms) improvement
s.TryEnter(0, ref lockTaken) 24.55 6.09 x 4.0

Need to do the threadpool timing tests I have (on a couple environments), as TrySteal uses this path; and they introduce parallel contention. Hopefully will improve, but will see.

Also corrected some strange spellings.

// Lock owned, haven't acquired the lock
if (millisecondsTimeout == 0)
{
// If timeout is zero fail fast, don't update waiters, don't spin to attempt acquire, exit
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: missing comma after "If timeout is zero"

@benaadams
Copy link
Copy Markdown
Member Author

Closing for now while I work through the flow a bit more.

@benaadams benaadams closed this Aug 25, 2016
@benaadams benaadams reopened this Aug 26, 2016
@benaadams benaadams changed the title SpinLock.TryEnter fail fast for timeout 0 [NoMerge] SpinLock.TryEnter fail fast for timeout 0 Aug 26, 2016
@benaadams benaadams changed the title [NoMerge] SpinLock.TryEnter fail fast for timeout 0 SpinLock.TryEnter fail fast for timeout 0 Aug 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants