Skip to content

Add GetLatestSlot and GetLatestSample functionality - #208

Merged
bemerybmw merged 3 commits into
eclipse-score:mainfrom
muhseth:muse_skeleton_get
Jul 17, 2026
Merged

Add GetLatestSlot and GetLatestSample functionality#208
bemerybmw merged 3 commits into
eclipse-score:mainfrom
muhseth:muse_skeleton_get

Conversation

@muhseth

@muhseth muhseth commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@castler castler changed the title Muse skeleton get Add GetLatestSlot and GetLatestSample functionality Mar 19, 2026
@LittleHuba

Copy link
Copy Markdown
Contributor

@muhseth please fix conflicts.

@LittleHuba
LittleHuba marked this pull request as draft March 24, 2026 09:27
@@ -38,6 +38,55 @@ EventDataControlCompositeImpl<AtomicIndirectorType>::EventDataControlCompositeIm
CheckForValidDataControls();
}

template <template <class> class AtomicIndirectorType>
score::cpp::optional<SlotIndexType> EventDataControlCompositeImpl<AtomicIndirectorType>::FindLatestReadableSlotIndex(

@crimson11 crimson11 Mar 26, 2026

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.

You should instead change existing EventDataControlCompositeImpl::GetLatestTimestamp()! You are mostly duplicating code here. The new/refactored function should be named GetLatestSlot and it should return the index PLUS the timestamp!

And please take into account, what I have written here: Ticket-253464

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.
I have removed GetLatestTimeStamp function and corresponding upper layer code.
As I see it is not used any where.

slot_index < static_cast<SlotIndexType>(control.state_slots_.size());
++slot_index)
{
SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD(static_cast<std::size_t>(slot_index) < control.state_slots_.size());

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.

? Why this assert? I do not get it.

@muhseth muhseth Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have removed it. As I see it there is no needed of it.
I have kept it as it was the part of previous code.

@muhseth
muhseth force-pushed the muse_skeleton_get branch 3 times, most recently from c4ffb3a to f0c0b32 Compare April 2, 2026 09:58
@muhseth
muhseth marked this pull request as ready for review April 2, 2026 14:14
@muhseth
muhseth requested a review from crimson11 April 7, 2026 07:44
@@ -39,6 +39,53 @@ EventDataControlComposite<AtomicIndirectorType>::EventDataControlComposite(Event
CheckForValidDataControls();
}

template <template <class> class AtomicIndirectorType>

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.

You have to be aware, that you have to align your changes with Brenbdans massive change here: #268

I.e. imho it makes sense, that you base your work on Brendans PR!

@Tejveerpratap2803 Tejveerpratap2803 May 19, 2026

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.

Already Done

@@ -39,6 +39,53 @@ EventDataControlComposite<AtomicIndirectorType>::EventDataControlComposite(Event
CheckForValidDataControls();
}

template <template <class> class AtomicIndirectorType>
score::cpp::optional<SlotIndexType> EventDataControlComposite<AtomicIndirectorType>::FindLatestReadableSlotIndex(

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.

What does "readable" mean?
Just: FindNewestSlot ?

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 think what Wahaj means is "FindLatestReferencedSlotIndex". I think it makes sense because just "newest" could also mean newest available slot to allocate in which isn't what we want.

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.

Already Done

@@ -43,7 +40,7 @@ auto EventSlotStatus::GetTimeStamp() const noexcept -> EventTimeStamp

auto EventSlotStatus::IsInvalid() const noexcept -> bool
{
return data_ == INVALID_EVENT;
return data_ == static_cast<value_type>(InvalidTimestamp);

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.

This cast looks "odd" to me!
Our EventSlotStatus::value_type is an uint64 ... the timestamp is a uint32!
An invalid event-slot status technically means:
The timestamp part is 0 (upper32 bit)
the ref-count part is 0 (lower 32 bit)
Just casting the timestamp part does miss this a bit ... if you want to be more "expressive" you could write something like:
constexpr EventSlotStatus::value_type INVALID_EVENT = (InvalidTimestamp <<32) | ZeroRefCount)

but this is "overdone" -> you could simply document INVALID_EVENT = 0u means an invalid timestamp and zero refcount ...

@muhseth muhseth Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i have made the changes as suggested.

@@ -58,7 +55,7 @@ auto EventSlotStatus::MarkInWriting() noexcept -> void

auto EventSlotStatus::MarkInvalid() noexcept -> void
{
data_ = INVALID_EVENT;
data_ = static_cast<value_type>(InvalidTimestamp);

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.

see above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread score/mw/com/impl/bindings/lola/event_slot_status.h Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h Outdated
@@ -251,6 +250,38 @@ Result<impl::SampleAllocateePtr<SampleType>> SkeletonEvent<SampleType>::Allocate
}
}

template <typename SampleType>
Result<SampleType> SkeletonEvent<SampleType>::GetLatestSample() noexcept

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.

Ouch. Why are you returning the sample by value here??? We never do this. A sample can be several megabytes in size ... so why are you copying it here - all our zero-copy architecture goes through the roof then ... and applications may crash, because the value will end up on stack, which will overflow ...

I guess you will use/need this functionality, when implementing the Skeleton-side get() method? Or even/also the set-method, where you need to work on the latest existing sample ...?

But then you need to apply SamplePtr logic!
I.e. you refcount the latest sample ... and create a SamplPtr from it, which you return from here ...
At your caller-side (your get/set impl) you then copy the data from the SamplePtr to your method ReturnType/InArg and once you are done with the copying, you destroy the SamplPtr freeing the slot.

This way you have just ONE copy! With your approach taken here, you copy TWICE! You copy out from shm to your sampl variable and then you copy from that variable back intro the call-queue! And this already expects, that you have RVO (which I guess is mandatory right now) ... but again - your caller side will crash, because the returned value (with RVO) will land most likely on stack and might explode there (if it is large).

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.

Done

{
const auto sample = event_data_storage_->at(static_cast<std::uint64_t>(slot.GetIndex()));

if (slot.IsValidQM())

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.

OK - so here you are doing "manually", what should be the job of the SamplePtr dtor

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.

Done

Comment thread score/mw/com/impl/bindings/lola/event_slot_status.h Outdated
Comment thread score/mw/com/impl/bindings/lola/event_slot_status.h
Comment thread score/mw/com/impl/bindings/lola/event_slot_status.h Outdated
Comment thread score/mw/com/impl/bindings/lola/event_slot_status.h Outdated
Comment thread score/mw/com/impl/bindings/lola/event_slot_status.h Outdated
Comment thread score/mw/com/impl/bindings/lola/event_data_control_composite.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/event_data_control_composite.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/event_data_control_composite.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/event_data_control_composite.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event.h Outdated
@muhseth
muhseth force-pushed the muse_skeleton_get branch from f0c0b32 to a65dc2c Compare April 16, 2026 14:43
@muhseth
muhseth marked this pull request as draft April 16, 2026 14:44
@muhseth
muhseth force-pushed the muse_skeleton_get branch from a65dc2c to 636762e Compare April 16, 2026 15:24
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.cpp Outdated
@muhseth
muhseth force-pushed the muse_skeleton_get branch 2 times, most recently from 85d878a to 4f7e4d4 Compare May 5, 2026 12:40
@Tejveerpratap2803
Tejveerpratap2803 force-pushed the muse_skeleton_get branch 3 times, most recently from 7dbf113 to e29d097 Compare May 25, 2026 09:09
Comment thread score/mw/com/impl/bindings/lola/event_slot_status.h Outdated
Comment thread score/mw/com/impl/bindings/lola/event_data_control_composite.cpp
@@ -236,7 +236,7 @@ template <template <class> class AtomicIndirectorType>
// coverity[autosar_cpp14_a15_5_3_violation : FALSE]
EventSlotStatus::EventTimeStamp EventDataControlComposite<AtomicIndirectorType>::GetLatestTimestamp() const noexcept
{
EventSlotStatus::EventTimeStamp latest_time_stamp{1U};
EventSlotStatus::EventTimeStamp latest_time_stamp{EventSlotStatus::UNINITIALIZED_TIMESTAMP};

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.

SWP-253464

Comment thread score/mw/com/impl/skeleton_event_binding.h Outdated
Comment thread score/mw/com/impl/skeleton_event_binding.h Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event.h
Comment thread score/mw/com/impl/bindings/lola/skeleton_event.h
@bemerybmw bemerybmw self-assigned this Jul 6, 2026
@Tejveerpratap2803
Tejveerpratap2803 force-pushed the muse_skeleton_get branch 4 times, most recently from 6b35406 to 0c33ec5 Compare July 8, 2026 07:11
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event.h
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h Outdated
Comment thread score/mw/com/impl/bindings/lola/transaction_log_set.h
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common.h Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_test.cpp
Comment thread score/mw/com/impl/plumbing/skeleton_service_element_binding_factory_impl.h Outdated
Comment thread score/mw/com/impl/skeleton_event_test.cpp Outdated
Comment thread score/mw/com/impl/skeleton_event_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_tracing_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_tracing_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common_test.cpp Outdated
Comment thread score/mw/com/impl/bindings/lola/skeleton_event_common_test.cpp Outdated
@Tejveerpratap2803
Tejveerpratap2803 force-pushed the muse_skeleton_get branch 3 times, most recently from 4f9d931 to ba5411b Compare July 16, 2026 11:55
@bemerybmw
bemerybmw enabled auto-merge July 16, 2026 13:16
@Tejveerpratap2803 Tejveerpratap2803 self-assigned this Jul 16, 2026
@bemerybmw
bemerybmw dismissed crimson11’s stale review July 16, 2026 15:28

All comments were addressed.

@bemerybmw
bemerybmw added this pull request to the merge queue Jul 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 16, 2026
@bemerybmw
bemerybmw added this pull request to the merge queue Jul 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 16, 2026
@bemerybmw
bemerybmw added this pull request to the merge queue Jul 17, 2026
Merged via the queue into eclipse-score:main with commit c8a018d Jul 17, 2026
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.

6 participants