[Pipe] Fairly limit concurrent TsFile parsers#18260
Conversation
jt2594838
left a comment
There was a problem hiding this comment.
The default per-pipe limit may need further discussion.
For single-pipe-multi-region scenario, the performance downgrade may be considerable.
| public synchronized boolean tryReserveTsFileParserMemory( | ||
| final String pipeName, final long creationTime, final Object reservationKey) { | ||
| if (reservationKey == null) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
I wonder if it would be better to let the caller wait on reservationKey when allocation fails.
And this method notify the next-to-wait reservationKey to reduce cases where the callers call this method only to find that the caller does not have the priority.
There was a problem hiding this comment.
Applied in 043f798. Each waiting event now blocks on a dedicated sticky reservation key instead of polling every 10 ms. The manager signals only the next eligible key after admission, parser release, cancellation, memory release, or a hot-reloaded limit increase. The concurrent fairness test now waits on these directed notifications without polling.
| if (reservedCountOfPipe <= 0) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Is this normal? If not, may print a warn log to help debugging.
There was a problem hiding this comment.
Agreed, this is not expected. Applied in 043f798: an unmatched release now emits a WARN with the Pipe name, creation time, and DataRegion. The message was added to both English and Chinese locale sources.
| config.setPipeTsFileParserInFlightMaxNum( | ||
| Integer.parseInt( | ||
| properties.getProperty( | ||
| "pipe_tsfile_parser_in_flight_max_num", | ||
| String.valueOf(config.getPipeTsFileParserInFlightMaxNum())))); | ||
| config.setPipeTsFileParserInFlightMaxNumPerPipe( | ||
| Integer.parseInt( | ||
| properties.getProperty( | ||
| "pipe_tsfile_parser_in_flight_max_num_per_pipe", | ||
| String.valueOf(config.getPipeTsFileParserInFlightMaxNumPerPipe())))); |
There was a problem hiding this comment.
Add to the template. Better to support hot-reload, in case that a single pipe is too slow due to the limitation.
There was a problem hiding this comment.
Applied in 043f798. Both properties are now documented in iotdb-system.properties.template with effectiveMode: hot_reload. The existing Pipe hot-reload path updates the values, and it now also wakes the next eligible queued reservation so an increased limit takes effect immediately.
|
Regarding the single-Pipe/multi-region concern: addressed in f75b6c6. The local limit is now scoped by |
Description
This is the parser admission and fairness part of the Pipe resilience work.
Global and per-Pipe-region limits
pipe_tsfile_parser_in_flight_max_num, defaulting to half of the available processors with a minimum of 1.pipe_tsfile_parser_in_flight_max_num_per_pipe_region, defaulting to 1.pipe_tsfile_parser_memory, the per-Pipe-region limit also provides an approximate parser memory quota.(pipeName, creationTime, dataRegionId), so different regions of one Pipe can parse concurrently while TsFiles from the same Pipe region remain bounded.iotdb-system.properties.templateand support hot reload. Increasing either limit wakes the next eligible queued reservation immediately.Hierarchical fair admission
PipeMemoryManagerschedules waiting requests in three levels:After a Pipe obtains one parser, its remaining requests move behind other waiting Pipes. After a region obtains one parser, its remaining requests move behind other waiting regions of the same Pipe. A multi-region Pipe therefore keeps region parallelism without receiving extra weight in the cross-Pipe fairness queue.
Each TsFile event owns a stable reservation key and carries its stable DataRegion identity through reservation, cancellation, release, and resource finalization. Timeout, explicit close, and resource finalization cancel pending reservations so an abandoned request cannot block a queue head.
Waiting events block on their reservation keys instead of polling every 10 ms. Admission, parser release, request cancellation, memory release, and parser-limit hot reload signal only the next eligible reservation. The signal is retained until consumed, avoiding a lost wake-up between the failed reservation attempt and the wait.
When only hard-threshold memory headroom remains, the selector skips Pipes that already own a parser and admits a waiting Pipe with no parser first.
Diagnostics
An unmatched TsFile parser memory release is treated as an invariant violation and emits a WARN containing the Pipe identity and DataRegion.
Tests
This PR has:
Key changed/added classes
PipeMemoryManagerPipeTsFileInsertionEventPipeMemoryManagerTestPropertiesTest