Skip to content

Commit dc5cff3

Browse files
author
Grok Compression
committed
TLM: add memory backpressure
1 parent 946524c commit dc5cff3

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.vscode/launch.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@
164164
"program": "/usr/bin/time",
165165
"args": [
166166
"-v",
167-
"${workspaceFolder}/build/bin/core_decompress",
167+
"${workspaceFolder}/build/bin/grk_decompress",
168168
"-i",
169-
"$HOME/temp/IMG_SPOT6_PMS_201305251604372_ORT_816009101_R1C1_TLM.JP2"
169+
"$HOME/temp/IMG_SPOT6_PMS_201305251604372_ORT_816009101_R1C1_TLM.JP2",
170+
"-o",
171+
"$HOME/temp/spot6_tlm.tif"
170172
],
171173
"cwd": "${workspaceFolder}",
172174
"environment": [

src/lib/core/codestream/decompress/CodeStreamDecompress.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,17 @@ void CodeStreamDecompress::decompressTLM(const std::set<uint16_t>& pendingTiles)
572572
{
573573
for(const auto& tileIndex : pendingTiles)
574574
{
575+
// Backpressure for strip-based band callback: block if this tile's row
576+
// is too far ahead of the row currently being drained, matching the
577+
// sequential path's throttle in sequentialParseAndSchedule().
578+
if(ioBandCallback_ && tileCompletion_)
579+
{
580+
uint16_t numTileCols = tileCompletion_->getNumTileCols();
581+
uint16_t tileY = tileIndex / numTileCols;
582+
std::unique_lock<std::mutex> lock(bandOrderMutex_);
583+
while(!(tileY < nextBandTileY_ + 2 || !success_))
584+
bandDrainCV_.wait_for(lock, std::chrono::milliseconds(100));
585+
}
575586
if(!schedule(getTileProcessor(tileIndex), true))
576587
break;
577588
}

0 commit comments

Comments
 (0)