[fpc-pascal] Patch/Test BlobSegmentSize was: IBConnection blobsegmentsize irrelevant & performance

Michael Van Canneyt michael at freepascal.org
Sat Nov 19 23:36:13 CET 2011



On Sat, 19 Nov 2011, Reinier Olislagers wrote:

> On 19-11-2011 13:28, Reinier Olislagers wrote:
>> Hi list,
>>
>> The Firebird/Interbase ibconnection.pp code has this code in its
>> SetParameters procedure to upload blobs in segments (BlobSegmentSize
>> property is set to 80 on object creation):
>>       while BlobBytesWritten < (BlobSize-BlobSegmentSize) do
>>         begin
>>         isc_put_segment(@FStatus[0], @blobHandle, BlobSegmentSize,
>> @s[(i*BlobSegmentSize)+1]);
>>         inc(BlobBytesWritten,BlobSegmentSize);
>>         inc(i);
>>         end;
>>       if BlobBytesWritten <> BlobSize then
>>         isc_put_segment(@FStatus[0], @blobHandle,
>> BlobSize-BlobBytesWritten, @s[(i*BlobSegmentSize)+1]);
>>
>> I've asked the Firebird list whether we need to upload in segments and
>> the answer is no, you can upload in chunks of up to 65535 bytes (see below).
>>
>> Would getting rid of the BlobSegmentSize property and replacing it by a
>> BlobSegmentSize const set at 65535 make sense (e.g. for performance)?
>
> Did a small performance test:
> - once with 80, once with 65535
> - 10MB blobs
> - Firebird 2.5 server
> - on a virtual machine (just restored from snapshot before each run)
> The difference seems fairly big: 395 seconds versus 260 seconds
>
> Hope I'm testing correctly.
>
> Test code is attached; I'd appreciate confirmation.
>
> Also attached is a patch for ibconnection.pp against FPC fixes_2_6.
> I set the BlobSegmentSize property to deprecated and basically ignored
> the underlying variable when writing blobs.

I applied the patch, thank you.  revision 19659.

>
> I wonder whether/what changes are required for reading blobs...

The following function needs adapting:

function TIBConnection.getMaxBlobSize(blobHandle : TIsc_Blob_Handle) : longInt;
var
   iscInfoBlobMaxSegment : byte = isc_info_blob_max_segment;
   blobInfo : array[0..50] of byte;

begin
   if isc_blob_info(@Fstatus[0], @blobHandle, sizeof(iscInfoBlobMaxSegment), pchar(@iscInfoBlobMaxSegment), sizeof(blobInfo)
     CheckError('isc_blob_info', FStatus);
   if blobInfo[0]  = isc_info_blob_max_segment then
     begin
       result :=  isc_vax_integer(pchar(@blobInfo[3]), isc_vax_integer(pchar(@blobInfo[1]), 2));
     end
   else
      CheckError('isc_blob_info', FStatus);
end;

You should first check what it returns. I suspect the declared blob segment size.

Michael.



More information about the fpc-pascal mailing list