FirebirdSQL / firebird

Firebird server, client and tools
https://firebirdsql.org
1.26k stars 217 forks source link

Database creation in 3.0.12, 4.0.5 and 5.0.1 slower than in previous releases #8219

Closed mrotteveel closed 3 months ago

mrotteveel commented 3 months ago

While running the Jaybird tests against Firebird 5.0.1, I noticed a slow down in test execution compared to Firebird 5.0.0.

The problem seems to be that database creation in Firebird 5.0.1 is roughly 30% slower compared to Firebird 5.0.0. For example, if I create 500 database against 5.0.0 (on Windows) it takes ~41.7 seconds, and on 5.0.1 it takes ~55.2 seconds.

Both 5.0.0 and 5.0.1 use the same configuration. The databases are created with isc_dpb_force_write set to 1, but not setting it makes no significant difference).

Firebird 4.0.5 and 3.0.12 have a similar performance decrease creating database compared to 4.0.4/3.0.11:

I used the following test (from within Jaybird's test (placed in src/test/org/firebirdsql/jdbc):

package org.firebirdsql.jdbc;

import org.firebirdsql.common.FBTestProperties;
import org.firebirdsql.management.FBManager;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.RepetitionInfo;
import org.junit.jupiter.api.io.TempDir;

import java.nio.file.Path;

import static org.firebirdsql.common.FBTestProperties.configureFBManager;

/**
 * @author Mark Rotteveel
 */
class SandboxTest {

    @TempDir
    static Path tempDir;

    @RepeatedTest(500)
    void repeatedDatabaseCreation(RepetitionInfo repetition) throws Exception {
        String dbName = "database-%d.fdb".formatted(repetition.getCurrentRepetition());
        Path dbFile = tempDir.resolve(dbName);

        try (var manager = configureFBManager(new FBManager())) {
            manager.createDatabase(dbFile.toString(), FBTestProperties.DB_USER, FBTestProperties.DB_PASSWORD);
        }
    }

}
asfernandes commented 3 months ago

Please test again using next snapshots.

mrotteveel commented 3 months ago

Tested with:

5.0.2.1481-0-fc71044-windows-x64: 35.9 seconds 4.0.6.3144-0_x64: 37.5 seconds 3.0.13.33790-0_x64: 40.9 seconds

So, looks good, and for 4.0.6 and 5.0.2 even better than before the regression. Thanks!

TommiPrami commented 2 months ago

Will this affect also restoring of the backup or some other operations`?

asfernandes commented 2 months ago

Database creation in general (including restore). Note that it was catch creating many databases. It will be unnoticeable restoring single database specially if it's is big.

TommiPrami commented 2 months ago

Thanks for the info.

-tee-