Skip to content
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

Read-only cown v2 #45

Merged
merged 19 commits into from
Sep 25, 2024
Merged

Read-only cown v2 #45

merged 19 commits into from
Sep 25, 2024

Conversation

vishalgupta97
Copy link
Contributor

No description provided.

@vishalgupta97 vishalgupta97 changed the title Read-only cown Read-only cown v2 Aug 19, 2024
Copy link
Member

@mjp41 mjp41 left a comment

Choose a reason for hiding this comment

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

Here are some initial comments on the PR. I'll do comments on the rest later

src/rt/sched/threadpool.h Outdated Show resolved Hide resolved
src/rt/sched/threadpool.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
Copy link
Member

@mjp41 mjp41 left a comment

Choose a reason for hiding this comment

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

Some more comments

src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
src/rt/sched/behaviourcore.h Outdated Show resolved Hide resolved
@mjp41 mjp41 mentioned this pull request Sep 17, 2024
}

// True means I can write,
Copy link
Member

Choose a reason for hiding this comment

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

Add comment that "Only one writer can call this."

Copy link
Collaborator

@marioskogias marioskogias left a comment

Choose a reason for hiding this comment

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

Here are some comments

*/
bool set_next_slot_reader(Slot* n)
{
// Check that the last two bits are zero
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to explain the semantic assertion you want to do and not the practical one.

* Assumption - Cowns are allocated at 4 byte boundary. Last 2 bits are
* zero.
*/
std::atomic<uintptr_t> _cown;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to change the naming convention? Would a wrapper type work better here?

status.store(0, std::memory_order_relaxed);
return (
(status.load(std::memory_order_acquire) &
STATUS_NEXT_SLOT_READER_FLAG) == STATUS_NEXT_SLOT_READER_FLAG);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need the equality check?

bool is_wait_2pl()
{
return (_cown.load(std::memory_order_acquire) & COWN_2PL_READY_FLAG) !=
COWN_2PL_READY_FLAG;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above. Do you need the check?

return true;
}

uintptr_t old_status_val =
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably need some more comments here. It is not clear why you add. Maybe say that this effectively is a fetch and or.

@@ -392,20 +666,30 @@ namespace verona::rt
// Sort the indexing array so we make the requests in the correct order
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need more comments in the schedule_many behaviour for the read only part

Copy link
Member

Choose a reason for hiding this comment

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

I think this comment is going to massively restructured by #49, so I would sooner leave that to there.

std::get<0>(i) < std::get<0>(j) :
std::get<1>(i)->cown < std::get<1>(j)->cown;
if (std::get<1>(i)->cown() == std::get<1>(j)->cown())
if (std::get<0>(i) == std::get<0>(j))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I understand the comparison. Add a comment that describes the corner case with one bahaviour with the same cown once with read and once with write accesses.

*/
std::atomic<uintptr_t> status;

Slot(Cown* cown) : cown(cown), status(0) {}
static constexpr uintptr_t STATUS_SLOT_ACTIVE_FLAG = 0x1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The term active needs better explanation and probably a different name. How about READ_RESOLVED?


if (is_ready())
if (next_slot() == nullptr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe explain what this means since next_slot is overloaded, or use a method call? Maybe a no_successor() call?

Copy link
Member

Choose a reason for hiding this comment

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

Added a no_successors and used throughout.

Aal::pause();
}
}

assert(is_behaviour());
// Wake up the next behaviour.
if (is_read_only())
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is complicated and duplicates code. Would it be possible to simplify? Maybe add methodo to finish the read_only to remove duplicates.

Copy link
Member

Choose a reason for hiding this comment

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

Add a drop_read to slot to remove duplication.

vishalgupta97 and others added 6 commits September 25, 2024 12:51
* Add Data race detection to the example

* Alter notification of next_writer

Use the read_ref_count to carry whether there is a writer that is expected to be woken up once the readers complete.
@mjp41 mjp41 enabled auto-merge (squash) September 25, 2024 11:52
@mjp41 mjp41 merged commit a90afaf into microsoft:main Sep 25, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants