Skip to content

LB write returns iterator to the element#106

Open
denizergonul wants to merge 1 commit into
developfrom
dte/lb_write_returns_iterator
Open

LB write returns iterator to the element#106
denizergonul wants to merge 1 commit into
developfrom
dte/lb_write_returns_iterator

Conversation

@denizergonul
Copy link
Copy Markdown
Contributor

@denizergonul denizergonul commented Oct 13, 2025

Immediate postprocessing was being done for buffer->back() assuming that is the last written element into the buffer. Although it is correct for queues, it is false for skip list since skip list is a sorted buffer; meaning that, if elements arrive out-of-order, back() can remain the same.

With the current API there was no way to get the last written element to skip list. Actually, folly's skip list insert function does return an iterator but we were not making use of it.

With this change, our latency buffer write functions now return an iterator as well. Then postprocessing is called with the correct element.

Unit tests are added for IterableQueueModel and SkipListLatencyBufferModel to test simple scenarios.

The main change:
Before:
bool write(T&& element);

After:
std::pair<const T*, bool> write(T&& element);

Side change: IterableQueueModel's constructor which only takes size parameter does not compile (because the other constructor has the following parameters defaulted which causes ambiguity) so it is removed.

@denizergonul
Copy link
Copy Markdown
Contributor Author

(Self) CPU times for base:
queue::write: 7.515s
skiplist::write: 0.025s
process_item with queue: 1.074s
process_item with skip list: 0.054s

(Self) CPU times for development:
queue::write: 5.503s
skiplist::write: 0.022s
process_item with queue: 0.588s
process_item with skip list: 0.055s

Profiling results show that performance is mostly improved.

@denizergonul
Copy link
Copy Markdown
Contributor Author

image

Base automatically changed from dte/pprocsched_timeout_logic to develop November 13, 2025 17:01
@roland-sipos
Copy link
Copy Markdown
Member

My main worry is the IterableQueueModel's new write implementation at very high insertion rates. I would like to see a profile run with high insertion rates.
During your profile runs, I see something strange. Did you run the profile for the exact amount of time? And at what insertion rates?

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.

Post-processing inconsistency with Default datahandlingmodel, using SkipList, and delays

3 participants