-
Notifications
You must be signed in to change notification settings - Fork 899
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
Logbuffer metadata extra fields #1700
Conversation
/** | ||
* Offset within the log metadata where the term offset is stored. | ||
*/ | ||
public static final int LOG_TERM_OFFSET_OFFSET; |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@pveentjer Please define new fields in the same order and using the same names as defined in the |
…stem_tests_c_media_driver doesn't fail
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
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.