Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage: limit complexity of compaction backlog calculation
This was an O(N^2) loop, which is gratuitously expensive for something that is only used to adjust I/O priorities. Clamp the number of segments that each segment will be compared to. This will have identical results in the typical case where the number of segments in a compacted topic term is low (because compaction itself keeps the number of segments low), while preventing O(N^2) runtime in the worst case of a user creating many segments in a single term. A realistic scenario would be for a user to write many thousands of segments to a topic while importing data, and then enable compaction at the end. Previously, this would have resulted in ~64M pow() calls for a partition with a terabyte of data in 128MiB segments.
- Loading branch information