New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catastrophic slowdown in isql in Firebird 3 compared to Firebird 2.5 under Linux [CORE5668] #5934
Comments
Commented by: Vadim Zeitlin (vz) Something looks very wrong with multithreading in Firebird 3. Compare the CPU usage, context switches and CPU migrations between 2.5: % perf stat isql-fb -q -b -i q.sql Performance counter stats for 'isql-fb -q -b -i q.sql':
and 3.0.3: % perf stat isql -q -b -i q.sql Performance counter stats for 'isql -q -b -i q.sql':
Numbers of instructions retired per cycle and mispredicted branches are also much worse. |
Commented by: @dyemanov Elapsed time: 0.17s vs 31.8s -- I believe this is the only reason of higher context switches / migrations , i.e. multithreading is not an issue here. |
Commented by: @dyemanov I can confirm the issue. CREATE TABLE executes with the same speed, however the subsequent COMMIT (implicit in your case due to AUTODDL ON) takes 0.1-0.15s on v3 vs 0.01s on v2.5: FB 2.5: SQL> CREATE TABLE t_08 (id CHAR(3)); FB 3.0: SQL> CREATE TABLE t_08 (id CHAR(3)); Number of writes is nearly the same in both cases. |
Commented by: @dyemanov I suppose I know the answer. FB 2.5 creates the database with FW=ON in the database, but FW is treated as OFF inside this connection (which creates the database). So all writes are performed as buffered (as FW=OFF) and only after reconnect the proper FW setting is taken into account. FB 3.0, in turn, deals with the actual FW =ON since the very beginning and thus writes synchronously. So it's actually a bug inside FB 2.5 rather than in FB 3.0. It can be easily validated against v2.5: CREATE DATABASE 'test.fdb'; CREATE TABLE t_01 (id CHAR(3)); Now this also becomes slow. |
Commented by: @asfernandes I'm saying for a long time that Firebird became very slow in Linux. This thing about creating database with FW=on was being said. It may be a reason (not sure it's the single one), but FW=on in Linux (ext partition?) is very slower than on Windows. To run fbtcs, I always patch PIO file to forcibly disable FW. We have discussed but so far I think nobody tried to make FW=on works without opening the file with O_SYNC, but to sync after groups of file writes that are unrelated with each other in the dependency page graph. |
Modified by: @AlexPeshkoffassignee: Alexander Peshkov [ alexpeshkoff ] |
Commented by: @dyemanov Slow FW is because of barriers that are enabled by default starting with ext3 (or was it ext4?). Layered flushing without O_SYNC is possible but another (probably better) possibility also exists - still use O_SYNC but perform async writes and synchronize them at precedence layers. |
Commented by: @AlexPeshkoff Mounting FS with 'nobarrier' option almost destroys perf.difference between 2.5 & 3. What about when was it introduced - ext3 or ext4, hard to answer. If explicit barrier/nobarrier is not set this option is implementation dependent in the kernel for both ext3 and ext4 and (moreover) it's distro dependent. This default was changed in most distros when introducing ext4, most of them changed it for ext3 a bit later too. Currently (kernel 4.x) looks like "barrier=1" became worls default. It (more or less) matched in time with fb3 release, together with fixed FW mode after db creation that caused serious pepformance penalty. I suggest to recommend HDD users to use barrier=0 in case of disk performance problems, generic answer for year 2017 is SSD. |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Commented by: @doychin SSD's are not always the answer. I prefer to use fast NVMe SSD but sometimes the budget does not allow this for small clients. So we are stuck with faster HDD in RAID array but no SSD. A working solution is needed in this case. |
Submitted by: Vadim Zeitlin (vz)
Attempting to switch to using Firebird 3 I realized that creating our database, i.e. just executing "CREATE TABLE" basically, now takes 4.5 *minutes* when it previously took 1.5 *seconds* under Linux. The problem can be even seen with completely trivial example such as this one:
CREATE DATABASE 'test.fdb';
CREATE TABLE t_01 (id CHAR(3));
CREATE TABLE t_02 (id CHAR(3));
CREATE TABLE t_03 (id CHAR(3));
CREATE TABLE t_04 (id CHAR(3));
CREATE TABLE t_05 (id CHAR(3));
CREATE TABLE t_06 (id CHAR(3));
CREATE TABLE t_07 (id CHAR(3));
CREATE TABLE t_08 (id CHAR(3));
CREATE TABLE t_09 (id CHAR(3));
CREATE TABLE t_10 (id CHAR(3));
Running "isql-fb -q -b -i test.sql" with this file takes less than 0.1s with Firebird 2.5 but almost 3.5s with Firebird 3.0.3. I thought there was something wrong with the version provided by Debian (3.0.2.32703.ds4-11), but the version I compiled myself from the latest B3_0_Release branch sources shows the same behaviour. However this is definitely Linux-specific as under Windows Firebird 3 is as fast or faster than 2.5.
This basically makes Firebird unusable even for our very modest needs, fully populating the database with data took a long time (hours) even with Firebird 2.5, I won't even be able to test it with Firebird 3.
Is there anything particularly stupid I'm doing here or could the performance really degrade that badly? Looking at perf output, there is nothing especially jarring, although it is surprising that ~4% of total time is spent in Firebird::MemPool::allocate and another 2% in Firebird::MemPool::release.
The text was updated successfully, but these errors were encountered: