Subject | Re: High CPU consumption |
---|---|
Author | kapsee |
Post date | 2005-10-04T16:53:45Z |
Thanks for the detailed response. When will version 2 be available ?
I am on 1.5 currently.
--- In firebird-support@yahoogroups.com, "Ann W. Harrison"
<aharrison@i...> wrote:
I am on 1.5 currently.
--- In firebird-support@yahoogroups.com, "Ann W. Harrison"
<aharrison@i...> wrote:
> kapsee wrote:against
> > My application is using the C interface to execute queries
> > firebird most of which are updates. I find that firebirdconsumes a
> > lot of CPU while this is happening.collection -
>
> The problem is likely to be garbage collection. Garbage
> the removal of unnecessary versions of records - is an on-goingprocess
> in all Firebird databases. The expensive part of garbagecollection is
> not removing the data itself, but removing index entries. Inthousands of
> particular, removing index entries when the index contains
> instance of that particular key value is very expensive.sweep
>
> The process that you can turn on and off is called "sweeping". A
> is an separate thread that reads every record in the database andoldest
> garbage collects unnecessary versions. Sweep also resets the
> interesting transaction marker by changing the state oftransactions
> from rolled back to committed once all their changes have beenremoved
> from the database. Sweeping is expensive and should not be doneduring
> high use periods. But it is not the only time garbage collectionis done.
>that
> In Classic, garbage collection is performed by the transaction
> finds the unneeded data. Any time any transaction finds anunnecessary
> record version it removes it, releasing the space it used for usein
> storing new records. It also removes index entries for thoserecord
> versions.When
>
> SuperServer 1.0x and 1.5x have a separate garbage collect thread.
> a transaction encounters an unnecessary record version, it poststhat
> record to the garbage collect thread. When the garbage collectthread
> runs, it attempts to remove the version and its index entries.Where
> there are large numbers of duplicate values for the index entrybeing
> removed, the cost of garbage collection can exceed the quantum oftime
> allocated to the garbage collect thread, so it must abandon itswork.
> That leads to lots of CPU use with not much progress to show forit.
>immediately by
> In SuperServer version 2, some garbage collection is done
> the transaction that encounters the unneeded record version -saving the
> extra I/O required for the garbage collect thread to read thepage.
> More complex operations - where removing the unnecessary versionwould
> involve additional I/O - are deferred to the garbage collectthread.
>and
> More significantly, I think, Version 2 changes the index structure
> makes garbage collecting index duplicates much less expensive.because
>
> Let me see if I can describe the problem simply. When you store a
> record, it typically goes at the end of the table. Not always,
> space released by deleted records and garbage collected oldversions
> will be used first, but typically new records show up at the endof the
> table. In Version 1.0x and 1.5x, duplicate index entries, on theother
> hand, are stored at the beginning of the list of duplicates.recent
>
> OK, so you've got two lists - record data is stored with the most
> record last, duplicate index entries are stored with the mostrecent
> record first.that's
>
> You decide to update or delete a group of records. No problem,
> fast and doesn't affect the indexes. When another transactionstarts to
> read the table - whether in natural order or by index - it willread the
> table in storage order - effectively oldest first. So the oldestof
> records are removed first. But their index entries are at the end
> the list of duplicates. Finding that entry requires reading thewhole
> list of duplicates. Removing the oldest entry in a list of 32,000second
> duplicates requires checking 32,000 index entries. Removing the
> oldest requires checking 31,999 index entries, and so on...record to
>
> Version 2 indexes order duplicates by the record number of the
> be deleted. The garbage collect thread can look up the entry tobe
> removed by a combination of the value - not very selective - andthe
> record number - very selective. For the purpose of garbagecollection,
> all indexes are unique. Instead of examining 32,000 entries, the
> garbage collector goes directly to the one it needs to remove.
>
> And that's a huge saving.
>
> Regards,
>
>
> An