Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Added pause to core.atomic#2819

Merged
dlang-bot merged 4 commits intodlang:masterfrom
TurkeyMan:pause_function
Oct 8, 2019
Merged

Added pause to core.atomic#2819
dlang-bot merged 4 commits intodlang:masterfrom
TurkeyMan:pause_function

Conversation

@TurkeyMan
Copy link
Contributor

So that other architectures can add their special sauce.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @TurkeyMan! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + druntime#2819"

*/
bool casWeak(MemoryOrder succ = MemoryOrder.seq,MemoryOrder fail = MemoryOrder.seq,T,V)(T* here, T* ifThis, V writeThis) pure nothrow @nogc @trusted
if (!is(T == shared S, S) && !is(V == shared U, U))
if (!is(T == shared S, S) && !is(V == shared U, U))
Copy link
Contributor

@wilzbach wilzbach Oct 6, 2019

Choose a reason for hiding this comment

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

Before your change this was the official DStyle (https://dlang.org/dstyle).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was inconsistent with the rest of the file... I would always favour internal consistency :/

Copy link
Contributor

@wilzbach wilzbach Oct 8, 2019

Choose a reason for hiding this comment

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

We have a style guide for a reason :/

@CyberShadow
Copy link
Member

Maybe refactor the one in core.internal.spinlock to use your implementation?

@TurkeyMan
Copy link
Contributor Author

TurkeyMan commented Oct 6, 2019

Those spinlock backoff counters look sus; they're very small numbers.
With backoff set to 4/16 cycles, it's not really a spinlock at all! It's just a sleep-lock.
NT kernel uses ~4000 cycles before backoff... and it probably shouldn't even be called a "spin lock" if it backs off.

@CyberShadow
Copy link
Member

Those spinlock backoff counters look sus; they're very small numbers.

Yes, I ran into issues with that too.

@TurkeyMan
Copy link
Contributor Author

Yeah, it's not a spin-lock... and it's also really bad >_<

@TurkeyMan
Copy link
Contributor Author

Is this controversial?

@@ -1,4 +1,4 @@
Added overloads for `core.atomic.cas` which don't discard their result.
Added overloads for `core.atomic : cas` which don't discard their result
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated style change
Ditto for all other changelogs and template constraints

* loads and stores after the call.
*/
void atomicFence(MemoryOrder order = MemoryOrder.seq)() nothrow @nogc @safe
void atomicFence(MemoryOrder order = MemoryOrder.seq)() pure nothrow @nogc @safe
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to pause(), please move this into another PR
Ditto for all other pure additions

import core.time;
if (k < pauseThresh)
return pause();
return core.atomic.pause();
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct if im wrong but this is more than a simple refactoring as the new inline assembly differs:
Old:

rep
nop

New:

naked
rep
nop
ret

ret;
}
}
else version (D_InlineAsm_X86_64)
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep the old enum/version declaration instead of duplicating the assembly? Or should there be different implementations according to your comment regarding the pause opcode?

@dlang-bot dlang-bot merged commit 0dfe3e9 into dlang:master Oct 8, 2019
@TurkeyMan TurkeyMan deleted the pause_function branch October 9, 2019 00:50
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.

6 participants

Comments