Skip to content

KAFKA-9373: Improve shutdown performance via lazy accessing the offset and time indices#7900

Closed
efeg wants to merge 2 commits intoapache:trunkfrom
efeg:fix/shutdownPerformance
Closed

KAFKA-9373: Improve shutdown performance via lazy accessing the offset and time indices#7900
efeg wants to merge 2 commits intoapache:trunkfrom
efeg:fix/shutdownPerformance

Conversation

@efeg
Copy link
Contributor

@efeg efeg commented Jan 7, 2020

KAFKA-7283 enabled lazy mmap on index files by initializing indices on-demand rather than performing costly disk/memory operations when creating all indices on broker startup. This helped reducing the startup time of brokers. However, segment indices are still created on closing segments, regardless of whether they need to be closed or not.

This patch:

  • Improves shutdown performance via lazy accessing the offset and time indices.
  • Eliminates redundant disk accesses and memory mapped operations while deleting or renaming files that back segment indices.
  • Prevents illegal accesses to underlying indices of a closed segment, which would lead to memory leaks due to recreation of the underlying memory mapped objects.

In our evaluations in a cluster with 31 brokers, where each broker has 13K to 20K segments, we observed up to 2 orders of magnitude faster LogManager shutdown times with this patch -- i.e. dropping the LogManager shutdown time of each broker from 10s of seconds to 100s of milliseconds.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

…ndices.

KAFKA-7283 enabled lazy mmap on index files by initializing indices on-demand rather than performing costly disk/memory operations when creating all indices on broker startup. This helped reducing the startup time of brokers. However, segment indices are still created on closing segments, regardless of whether they needs to be closed or not.

This patch:
* Improves shutdown performance via lazy accessing the offset and time indices.
* Eliminates redundant disk accesses and memory mapped operations while deleting or renaming files that back segment indices.
* Prevents illegal accesses to underlying indices of a closed segment, which would lead to memory leaks due to recreation of the underlying memory mapped objects.
* leaks due to recreation of underlying memory mapped object.
*
* Methods of this class are thread safe. Make sure to check `AbstractIndex` subclasses documentation
* to establish their thread safety.
Copy link
Member

Choose a reason for hiding this comment

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

Why has the thread safety comment been removed?

@ijuma
Copy link
Member

ijuma commented Jan 7, 2020

Nice optimization. I think we should consider delegating to the underlying implementations instead of adding logic to the wrapper.

@ijuma
Copy link
Member

ijuma commented Jan 28, 2020

@efeg Any thoughts on the above?

@efeg
Copy link
Contributor Author

efeg commented Jan 29, 2020

@ijuma Thanks for the review and sorry for the delay on addressing the comments! -- I will try to update the PR by next week.

@ijuma
Copy link
Member

ijuma commented Jan 29, 2020

@efeg thanks, looking forward to it.

@ijuma
Copy link
Member

ijuma commented Mar 25, 2020

@efeg Seems like you have been busy. Since this is a very useful change, I went ahead and submitted a new pull request with the approach I suggested (with you as co-author):

#8346

ijuma added a commit to ijuma/kafka that referenced this pull request Mar 26, 2020
…ndexes

KAFKA-7283 enabled lazy mmap on index files by initializing indices
on-demand rather than performing costly disk/memory operations when
creating all indices on broker startup. This helped reducing the startup
time of brokers. However, segment indices are still created on closing
segments, regardless of whether they need to be closed or not.

This is a cleaned up version of apache#7900, which was submitted by @efeg. It
eliminates unnecessary disk accesses and memory map operations while
deleting, renaming or closing offset and time indexes.

In a cluster with 31 brokers, where each broker has 13K to 20K segments,
@efeg and team observed up to 2 orders of magnitude faster LogManager
shutdown times - i.e. dropping the LogManager shutdown time of each
broker from 10s of seconds to 100s of milliseconds.

To avoid confusion between `renameTo` and `setFile`, I replaced the
latter with the more restricted updateParentDir` (it turns out that's
all we need).

Co-authored-by: Adem Efe Gencer <[email protected]>
Co-authored-by: Ismael Juma <[email protected]>
ijuma added a commit that referenced this pull request Mar 26, 2020
…ndexes (#8346)

KAFKA-7283 enabled lazy mmap on index files by initializing indices
on-demand rather than performing costly disk/memory operations when
creating all indices on broker startup. This helped reducing the startup
time of brokers. However, segment indices are still created on closing
segments, regardless of whether they need to be closed or not.

This is a cleaned up version of #7900, which was submitted by @efeg. It
eliminates unnecessary disk accesses and memory map operations while
deleting, renaming or closing offset and time indexes.

In a cluster with 31 brokers, where each broker has 13K to 20K segments,
@efeg and team observed up to 2 orders of magnitude faster LogManager
shutdown times - i.e. dropping the LogManager shutdown time of each
broker from 10s of seconds to 100s of milliseconds.

To avoid confusion between `renameTo` and `setFile`, I replaced the
latter with the more restricted updateParentDir` (it turns out that's
all we need).

Reviewers: Jun Rao <[email protected]>, Andrew Choi <[email protected]>

Co-authored-by: Adem Efe Gencer <[email protected]>
Co-authored-by: Ismael Juma <[email protected]>
@ijuma
Copy link
Member

ijuma commented Mar 26, 2020

Thanks for the PR, we merged it via #8346.

@ijuma ijuma closed this Mar 26, 2020
@efeg
Copy link
Contributor Author

efeg commented Mar 26, 2020

Thanks for the updated PR @ijuma!

efeg pushed a commit to linkedin/kafka that referenced this pull request Jun 1, 2020
…ng unnecessary loading of indexes (apache#8346)

TICKET =
LI_DESCRIPTION =

KAFKA-7283 enabled lazy mmap on index files by initializing indices
on-demand rather than performing costly disk/memory operations when
creating all indices on broker startup. This helped reducing the startup
time of brokers. However, segment indices are still created on closing
segments, regardless of whether they need to be closed or not.

This is a cleaned up version of apache#7900, which was submitted by @efeg. It
eliminates unnecessary disk accesses and memory map operations while
deleting, renaming or closing offset and time indexes.

In a cluster with 31 brokers, where each broker has 13K to 20K segments,
@efeg and team observed up to 2 orders of magnitude faster LogManager
shutdown times - i.e. dropping the LogManager shutdown time of each
broker from 10s of seconds to 100s of milliseconds.

To avoid confusion between `renameTo` and `setFile`, I replaced the
latter with the more restricted updateParentDir` (it turns out that's
all we need).

Reviewers: Jun Rao <[email protected]>, Andrew Choi <[email protected]>

Co-authored-by: Adem Efe Gencer <[email protected]>
Co-authored-by: Ismael Juma <[email protected]>

EXIT_CRITERIA = HASH [222726d]
gitlw pushed a commit to linkedin/kafka that referenced this pull request Jun 12, 2020
…ng unnecessary loading of indexes (apache#8346)

TICKET =
LI_DESCRIPTION =

KAFKA-7283 enabled lazy mmap on index files by initializing indices
on-demand rather than performing costly disk/memory operations when
creating all indices on broker startup. This helped reducing the startup
time of brokers. However, segment indices are still created on closing
segments, regardless of whether they need to be closed or not.

This is a cleaned up version of apache#7900, which was submitted by @efeg. It
eliminates unnecessary disk accesses and memory map operations while
deleting, renaming or closing offset and time indexes.

In a cluster with 31 brokers, where each broker has 13K to 20K segments,
@efeg and team observed up to 2 orders of magnitude faster LogManager
shutdown times - i.e. dropping the LogManager shutdown time of each
broker from 10s of seconds to 100s of milliseconds.

To avoid confusion between `renameTo` and `setFile`, I replaced the
latter with the more restricted updateParentDir` (it turns out that's
all we need).

Reviewers: Jun Rao <[email protected]>, Andrew Choi <[email protected]>

Co-authored-by: Adem Efe Gencer <[email protected]>
Co-authored-by: Ismael Juma <[email protected]>

EXIT_CRITERIA = HASH [222726d]
gitlw pushed a commit to linkedin/kafka that referenced this pull request Jun 13, 2020
…ng unnecessary loading of indexes (apache#8346)

TICKET =
LI_DESCRIPTION =

KAFKA-7283 enabled lazy mmap on index files by initializing indices
on-demand rather than performing costly disk/memory operations when
creating all indices on broker startup. This helped reducing the startup
time of brokers. However, segment indices are still created on closing
segments, regardless of whether they need to be closed or not.

This is a cleaned up version of apache#7900, which was submitted by @efeg. It
eliminates unnecessary disk accesses and memory map operations while
deleting, renaming or closing offset and time indexes.

In a cluster with 31 brokers, where each broker has 13K to 20K segments,
@efeg and team observed up to 2 orders of magnitude faster LogManager
shutdown times - i.e. dropping the LogManager shutdown time of each
broker from 10s of seconds to 100s of milliseconds.

To avoid confusion between `renameTo` and `setFile`, I replaced the
latter with the more restricted updateParentDir` (it turns out that's
all we need).

Reviewers: Jun Rao <[email protected]>, Andrew Choi <[email protected]>

Co-authored-by: Adem Efe Gencer <[email protected]>
Co-authored-by: Ismael Juma <[email protected]>

EXIT_CRITERIA = HASH [222726d]
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.

2 participants