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

Option to drop oldest message when msg limit on pipe reached (keep newest) #541

Open
skliper opened this issue Mar 4, 2020 · 4 comments

Comments

@skliper
Copy link
Contributor

skliper commented Mar 4, 2020

Is your feature request related to a problem? Please describe.
Looks like SB rejects newest message when message limit reached

/* if Msg limit exceeded, log event, increment counter */
/* and go to next destination */
if(DestPtr->BuffCount >= DestPtr->MsgId2PipeLim){
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].PipeId = DestPtr->PipeId;
SBSndErr.EvtBuf[SBSndErr.EvtsToSnd].EventId = CFE_SB_MSGID_LIM_ERR_EID;
SBSndErr.EvtsToSnd++;
CFE_SB.HKTlmMsg.Payload.MsgLimitErrorCounter++;
PipeDscPtr->SendErrors++;
continue;
}/* end if */

In some cases newest message is of higher priority

Describe the solution you'd like
Add option (maybe part of QOS?) to remove oldest message from queue when limit reached. Easy if the message limit is 1, likely need trade study if more than one (reorder queue? Replace oldest w/ newest would put them out of order, add new to queue remove oldest and remove gap? etc). Performance cost to find/replace/reorder/etc.

Describe alternatives you've considered
Just subscribe with enough space to hold all, and chew through entire pipe to get the latest then process.

Additional context
Requested by 587

Requester Info
Jacob Hageman - NASA/GSFC

@skliper
Copy link
Contributor Author

skliper commented Mar 4, 2020

Preference is to keep unique pipe processing on app side where possible to avoid general performance hits or added SB complexity, but entered here as it's worth discussion.

@jphickey
Copy link
Contributor

jphickey commented Mar 4, 2020

Keeping the oldest message and discarding the new one is normal FIFO queue behavior and it is dictated by the OSAL queue implementation that underpins SB pipes.

The contract of a FIFO queue says that if it is accepted at the sender side (i.e. successfully placed into the queue) then it is guaranteed to be delivered at the receiver side.

OSAL does not implement priority queues, partly because they aren't widely/consistently implemented across RTOS's.

Maybe another reason to push ahead and implement nasa/osal#73, as this could offer all of the behavior options (Basic FIFO, Priority, Ring buffer).

@iamthad
Copy link

iamthad commented Mar 4, 2020

For some applications, it may be sufficient to have some sort of interface that exposes only the latest value. I imagine this may be easier to support than a general LIFO capability.

@jphickey
Copy link
Contributor

jphickey commented Mar 4, 2020

For some applications, it may be sufficient to have some sort of interface that exposes only the latest value. I imagine this may be easier to support than a general LIFO capability.

Totally agree - but then this would no longer be a queue at all, its more like a table.

In projects I support we employ an intermediate library that implements a software bus listener that subscribes to and captures all telemetry, and presents an API where other applications can get the current/latest value of each telemetry point. It implements a scheduler-based page flipping so all values are coherent with each other and various (configurable) filtering/scrubbing/unit normalization features.

The good news is though this can all be done with a CFE library, one doesn't need to replace queues to get it. The regular software bus does not need to be aware of the extra layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants