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

Logbuffer metadata extra fields #1700

Merged

Conversation

pveentjer
Copy link
Contributor

@pveentjer pveentjer commented Dec 20, 2024

Adding extra fields to the metadata section of the logbuffers for Aeron Insights.

This PR is a replacement for the following one:

#1697

Which isn't going to be merged because it will break backwards compatibility.

@pveentjer pveentjer requested a review from vyazelenko December 20, 2024 05:26
@pveentjer pveentjer changed the title [WIP]] logbuffer metadata enhancements [WIP] logbuffer metadata extra fields Dec 20, 2024
/**
* Offset within the log metadata where the term offset is stored.
*/
public static final int LOG_TERM_OFFSET_OFFSET;
Copy link
Contributor

Choose a reason for hiding this comment

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

A natural place to store this information would the default frame header, i.e.:

        defaultDataHeader.sessionId(sessionId).streamId(streamId).termId(initialTermId).termOffset(termOffset);
        storeDefaultFrameHeader(logMetaData, defaultDataHeader);

Copy link
Contributor Author

@pveentjer pveentjer Dec 30, 2024

Choose a reason for hiding this comment

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

Ok. I'll set the term offset on the default frame header and will drop it from the LogBufferDescriptor

throw new Error("Bad alignment: offset=" + offset);
}

LOG_SOCKET_RCVBUF_LENGTH_OFFSET = offset;
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try to use available space after the page_size field (LOG_PAGE_SIZE_OFFSET + SIZE_OF_INT) where we still have 36 bytes before the default header starts.
That should be enough to fit 6 ints or 5 ints + 6 booleans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@vyazelenko
Copy link
Contributor

vyazelenko commented Dec 20, 2024

@pveentjer Please define new fields in the same order and using the same names as defined in the aeron_logbuffer_metadata_t (see 306dfe8).

@pveentjer pveentjer changed the title [WIP] logbuffer metadata extra fields Logbuffer metadata extra fields Jan 3, 2025
@@ -71,6 +71,7 @@ typedef struct aeron_logbuffer_metadata_stct
uint8_t signal_eos;
uint8_t spies_simulate_connection;
uint8_t tether;
uint8_t pad_end[32]; // Padding to align the structure size to 512 bytes (9x AERON_CACHE_LINE_LENGTH)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why add trailing padding? The entire metadata section is 4KB and is cache line aligned. We are going to read only the fields we need, i.e. consume up to 480 bytes.

Copy link
Contributor Author

@pveentjer pveentjer Jan 6, 2025

Choose a reason for hiding this comment

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

The original code also had padding at the end of the struct:

uint8_t pad3[(AERON_CACHE_LINE_LENGTH) - (7 * sizeof(int32_t))];

My guess is that it was done to prevent false sharing.

Copy link
Contributor Author

@pveentjer pveentjer Jan 6, 2025

Choose a reason for hiding this comment

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

I had another look. I think I understand what is happening.

The padding is needed to position the defaultHeader. It isn't needed to prevent false sharing.

Since the empty space (the pad3) is now filled with the extra fields, the padding isn't relevant any longer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, so no extra padding is needed. The definition on the C side was correct after the 9eb689f commit.

@@ -71,6 +71,7 @@ typedef struct aeron_logbuffer_metadata_stct
uint8_t signal_eos;
uint8_t spies_simulate_connection;
uint8_t tether;
uint8_t pad_end[32]; // Padding to align the structure size to 512 bytes (9x AERON_CACHE_LINE_LENGTH)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, so no extra padding is needed. The definition on the C side was correct after the 9eb689f commit.

@vyazelenko vyazelenko merged commit 4e2428b into real-logic:master Jan 8, 2025
34 checks passed
@pveentjer pveentjer deleted the feature/logbuffer-metadata-enhancements branch January 8, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants