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

SB memory pool misleading reporting and ES API confusing #2558

Open
skliper opened this issue May 9, 2024 · 1 comment
Open

SB memory pool misleading reporting and ES API confusing #2558

skliper opened this issue May 9, 2024 · 1 comment
Labels

Comments

@skliper
Copy link
Contributor

skliper commented May 9, 2024

Describe the bug
SB isn't reporting the peak and current memory pool use correctly.

To Reproduce
Inspect MemInUse and PeakMemInUse from SB (or UnmarkedMem which is max size - the peak in use) and compare to what's reported from ES from a status call in NumFreeBytes.

For example I just ran a test with the following results:

MemInUse = 30739
PeakMemInUse = 35418
Where the max size is set to 524288
But as reported from ES the NumFreeBytes is 459824

So the peak of blocks that were ever allocated is almost double the SB reported peak at 64464.

CFE_ES_GetPoolBufInfo claims to return "size of the buffer", but it returns ActualSize, not BlockSize. This could just be user confusion, but then CFE_ES_GetPoolGetBlockSize is the underlying call, and it also returns ActualSize,,not BlockSize.

I'd think the common use case of tracking the peak/unmarked memory in the pool is to manage margin. Since SB is just reporting a sum of the ActualSize's (aka the requested sizes) and not the actual used block sizes the real margin could be significantly less than what's implied by the SB reporting.

Expected behavior
There doesn't seem to be an API to show the peak for actual memory in use from ES, it's just the unmarked pool memory so I don't know that there's a way to really show exactly total used w/ current APIs but providing back the unmarked amount of memory seems more useful.

Code snips
SB tracking:

/* Add the size of the actual buffer to the memory-in-use ctr and */
/* adjust the high water mark if needed */
CFE_SB_Global.StatTlmMsg.Payload.MemInUse += AllocSize;
if (CFE_SB_Global.StatTlmMsg.Payload.MemInUse > CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse)
{
CFE_SB_Global.StatTlmMsg.Payload.PeakMemInUse = CFE_SB_Global.StatTlmMsg.Payload.MemInUse;
}

CFE_ES_GetPoolBufInfo calls CFE_ES_GenPoolGetBlockSize:

Status = CFE_ES_GenPoolGetBlockSize(&PoolRecPtr->Pool, &DataSize, DataOffset);

But CFE_ES_GenPoolGetBlockSize returns the actual size:

*BlockSizePtr = BdPtr->ActualSize;

System observed on:

  • Hardware: Docker on PC
  • OS: Ubuntu 22
  • Versions: Close to main... project code

Additional context
NA

Reporter Info
Jacob Hageman - NASA/GSFC

@skliper skliper added bug CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels May 9, 2024
@jphickey
Copy link
Contributor

jphickey commented May 9, 2024

I concur that the TLM stats reported for pool usage is not great. They are hard to interpret and the common problems (i.e. fragmentation) are not apparent by looking at the numbers reported.

@skliper skliper removed the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label May 9, 2024
RichLandau added a commit to RichLandau/cFE that referenced this issue Nov 12, 2024
…ead of requested size, using that in SB buffer reporting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants