Compression Slowness Issue

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
angad
Posts: 112
Joined: Thu, 2010-02-18, 09:54

Compression Slowness Issue

#1 Post by angad »

Hi All,

We have written one multi-threaded application to parallely compress the dicom files(using multi-threaded dcmtk). I found it somehow slow. Following is the code :

DcmDataset *dataset = fileformat->getDataset();
DcmXfer original_xfer(dataset->getOriginalXfer());
DcmXfer opt_oxferSyn(opt_oxfer);

dataset->loadAllDataIntoMemory();

if(original_xfer.isEncapsulated())
{
chooseRepresentationStatus = dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL);
}

// create representation parameters for lossy and lossless
DJ_RPLossless rp_lossless((int)opt_selection_value, (int)opt_point_transform);
DJ_RPLossy rp_lossy((int)opt_quality);


const DcmRepresentationParameter *rp = &rp_lossy;

if ((opt_oxfer == EXS_JPEGProcess14SV1TransferSyntax)||
(opt_oxfer == EXS_JPEGProcess14TransferSyntax))
rp = &rp_lossless;

if(opt_oxfer == EXS_LittleEndianExplicit)
rp = NULL;

chooseRepresentationStatus = dataset->chooseRepresentation(opt_oxfer, rp);

// force meta-header to refresh SOP Class/Instance UIDs. Deleting Meta Header info.

fileformat->loadAllDataIntoMemory();

error = fileformat->saveFile(outputFile.c_str(), opt_oxfer, opt_oenctype, opt_oglenc,
opt_opadenc, (Uint32) opt_filepad, (Uint32) opt_itempad, EWM_updateMeta);


Q-1: I am running 5 parallel threads to compress the dicom files. Are above functions reentrant and execute parallely. Or Multiple threads execute these function in serialized fashion?

Q-2: If above code is reentrant: then should we call loadAllDataIntoMemory() API for both dataset and fileformat ?

Thanks,
Angad Nath

angad
Posts: 112
Joined: Thu, 2010-02-18, 09:54

Re: Compression Slowness Issue

#2 Post by angad »

Hi,

Any luck with my previous post. Waiting for response.

Thanks in advance !!!!

Thanks,
Angad Nath

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Compression Slowness Issue

#3 Post by Michael Onken »

Hi,

I think this should work in parallel threads, though I did not try and cannot guarantee it. The second loadAllIntoMemory() is not required, is it? The update of meta header is done as far as I remember in any case if you call saveFile() (though it will not do much harm since all should be in memory).

You should make sure: a) that you have enough memory to have multiple large(?) files in it for compression. b) that you have enough cpu cores to take care of a file, each (also, look whether they are all put under stress and not only a single core).

How long does compressino of files take compared to the same files being compressed in a loop?

Best,
Michael

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest