Skip to content

EmbeddedDatabase#drop 30x latency regression between 23.5.1 and 23.6.1 #1234

Closed

Description

@erickj

ArcadeDB Version:

upgrading from 23.5.1 to 23.6.1

OS and JDK Version:

$ java -version
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (Red_Hat-17.0.7.0.7-4.fc37) (build 17.0.7+7)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.7.0.7-4.fc37) (build 17.0.7+7, mixed mode, sharing)

$ cat /etc/os-release 
NAME="Fedora Linux"
VERSION="37 (Server Edition)"

Expected behavior

Upgrading from 23.5.1 to 23.6.1 should not have regressed Database#drop

screenshot of "slow" 23.6.1 profile showing 904 ms spent in EmbeddedDatabase#drop, w/ 872 ms coming from PageManager#close:
Screenshot from 2023-09-09 19-50-55

screenshot of "fast" 23.5.1 profile showing 36 ms spent in EmbeddedDatabase#drop:
Screenshot from 2023-09-09 19-46-59

The only difference between these profiler snapshots is the arcadedb upgrade

Actual behavior

Between upgrading from 23.5.1 to 23.6.1 a single test I have went from executing in ~6 seconds to >24 seconds

faster 23.5.1 test logs show:

5300 [main] [INFO] io.vos.service.graph.database.arcadedb.ArcadeUpsertNodeMutationTest - dropping db:[/tmp/arcadedb-databases/ArcadeUpsertNodeMutationTest-285f7f28-ca71-4f1b-9bf0-ca3b2161cc54]
| | | | | | |  duration: 30 ms
| | | | | | |    status: [OK] SUCCESSFUL
| | | | | '-- VertexTests finished after 93 ms.
| | | | '-- UpsertNodeMutationTests finished after 5337 ms.

slow 23.6.1 test logs show:

23265 [main] [INFO] io.vos.service.graph.database.arcadedb.ArcadeUpsertNodeMutationTest - dropping db:[/tmp/arcadedb-databases/ArcadeUpsertNodeMutationTest-fad9eea7-ed02-4ae0-9b1f-690f1fc203d0]
| | | | | | |  duration: 1031 ms
| | | | | | |    status: [OK] SUCCESSFUL
| | | | | '-- VertexTests finished after 3094 ms.
| | | | '-- UpsertNodeMutationTests finished after 24298 ms.

From the above "dropping db" log line, there is a slow down from ~30ms to ~1s per test, where "teardown" is effectively:

    logger.info("dropping db:[{}]", dbName);
    if (db != null) {
      db.drop();
      db = null;
    }

I have been unable to reproduce this regression on the arcadedb test suites, trying to use com.arcadedb.DocumentTest as a proxy for teardown behavior, but it's 100% repeatable in my test setup.

Profiling the running tests with VisualVM shows the latency regression is 100% located in com.arcadedb.engine.PageManager#close

Steps to reproduce

I'm still working on a simply JUnit test that reproduces the issue, but I"m filing a bug here in case it's obvious where the regression might have come from in the release window.

Activity

  1. changed the title [-]EmbeddedDatabase#drop regressed up to 30x latency between 23.5.1 and 23.6.1[/-] [+]EmbeddedDatabase#drop 30x latency regression between 23.5.1 and 23.6.1[/+] on Sep 9, 2023
  2. erickj commented on Sep 9, 2023

    @erickj
    ContributorAuthor

    attaching visual vm profile snapshots, although I don't see much more info here

    visual-vm-snapshots.zip

  3. erickj commented on Sep 9, 2023

    @erickj
    ContributorAuthor

    I've created a simple unit test which reproduces this issue & added it to the gist:

    https://gist.github.com/erickj/cae0a52053b4c8f054b222ca3fbad3fc#file-slowteardowntest-java

    There are 2 tests that run, as it seems that there are 2 cases to consider here:

    1. When I do NOT do any kind of schema or index creation between creating the database and tearing down the database, then there is a slow teardown behavior on BOTH versions.
    2. When I do create a small schema, then 23.5.1 executes the database teardown in just a few milliseconds.

    See log output for the simple test attached to the gist:

  4. self-assigned this
    on Sep 10, 2023
  5. added this to the 23.9.1 milestone on Sep 10, 2023
  6. lvca commented on Sep 10, 2023

    @lvca
    Member

    @erickj Thanks for the hyper-detailed report. I'm checking on it.

  7. lvca commented on Sep 10, 2023

    @lvca
    Member

    Okay, thanks to your report I found it quickly. This is to blame: f230646#diff-c850d6d81d642f63e8a1d34280a05e4739d0850d885ad612cb16daf827bbad0dL86. Working towards a more efficient way to manage the poll from the queue.

  8. lvca commented on Sep 10, 2023

    @lvca
    Member

    @erickj please let me know if this fix resolves the issue. The test suite now finishes much faster than before on my PC.

  9. erickj commented on Sep 10, 2023

    @erickj
    ContributorAuthor

    thanks for picking this up so quickly @lvca

    overall, the speed issues look solved (mostly).... but now there is a concerning severe error appearing in the logs in ~40% of test runs, which when it occurs now takes 2s to execute db#drop:

    2023-09-10 08:30:07.483 SEVER [PaginatedComponentFile] File 'an-indexed-type_7_2320327016564247.56.2097152.v1.umtidx' was closed on write. Reopen it and retry...Error on processing page flush requests
    java.nio.channels.ClosedByInterruptException
    	at java.base/java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:199)
    	at java.base/sun.nio.ch.FileChannelImpl.endBlocking(FileChannelImpl.java:171)
    	at java.base/sun.nio.ch.FileChannelImpl.writeInternal(FileChannelImpl.java:883)
    	at java.base/sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:864)
    	at com.arcadedb.engine.PaginatedComponentFile.write(PaginatedComponentFile.java:117)
    	at com.arcadedb.engine.PageManager.lambda$flushPage$0(PageManager.java:313)
    	at com.arcadedb.engine.PageManager.concurrentPageAccess(PageManager.java:360)
    	at com.arcadedb.engine.PageManager.flushPage(PageManager.java:312)
    	at com.arcadedb.engine.PageManagerFlushThread.flushPagesFromQueueToDisk(PageManagerFlushThread.java:89)
    	at com.arcadedb.engine.PageManagerFlushThread.run(PageManagerFlushThread.java:73)
    
    2023-09-10 08:30:09.487 WARNI [TransactionManager] Error on removing all transaction files. Remained: [/tmp/arcadedb-databases/createAndDropTest-e56a4ef2-4e6f-4746-b2cf-3a1bab7eaf5e/txlog_1.wal]
    2460 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOn23.6.1]]: ran in 2035
    
  10. erickj commented on Sep 10, 2023

    @erickj
    ContributorAuthor

    I actually noticed the same error when running the arcadedb mvn package to build the jars.

    [INFO] Running com.arcadedb.query.sql.functions.sql.SQLFunctionsTest
    
    2023-09-10 10:01:20.022 SEVER [PaginatedComponentFile] File 'Indexed_1_2318599566749093.42.2097152.v1.numtidx' was closed on write. Reopen it and retry...Error on processing page flush requests
    java.nio.channels.ClosedByInterruptException
    	at java.base/java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:199)
    	at java.base/sun.nio.ch.FileChannelImpl.endBlocking(FileChannelImpl.java:171)
    	at java.base/sun.nio.ch.FileChannelImpl.writeInternal(FileChannelImpl.java:883)
    	at java.base/sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:864)
    	at com.arcadedb.engine.PaginatedComponentFile.write(PaginatedComponentFile.java:117)
    	at com.arcadedb.engine.PageManager.lambda$flushPage$0(PageManager.java:313)
    	at com.arcadedb.engine.PageManager.concurrentPageAccess(PageManager.java:360)
    	at com.arcadedb.engine.PageManager.flushPage(PageManager.java:312)
    	at com.arcadedb.engine.PageManagerFlushThread.flushPagesFromQueueToDisk(PageManagerFlushThread.java:89)
    	at com.arcadedb.engine.PageManagerFlushThread.run(PageManagerFlushThread.java:73)
    

    wdyt? is this actually innocuous and can be ignored? or is this something more serious that could lead to database corruption on PageManager#flushPage?

  11. erickj commented on Sep 10, 2023

    @erickj
    ContributorAuthor

    @lvca what do you think about this instead?

    erickj@4a6a00b

    gives results:

    ==================== Test output for //javatests/io/vos/service/graph/database/arcadedb:SlowTeardownTest:
    [0.002s][info][gc] Using G1
    238 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOnBoth]]: ran in 226
    245 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOnBoth]]: ran in 6
    254 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOnBoth]]: ran in 3
    256 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOnBoth]]: ran in 2
    261 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOnBoth]]: ran in 3
    263 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOnBoth]]: ran in 2
    268 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOnBoth]]: ran in 3
    269 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOnBoth]]: ran in 1
    275 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOnBoth]]: ran in 3
    277 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOnBoth]]: ran in 2
    284 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOn23.6.1]]: ran in 3
    [0.875s][info][gc] GC(0) Pause Young (Normal) (G1 Evacuation Pause) 111M->31M(2048M) 6.128ms
    358 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[doSomeDbStuff[slowOn23.6.1]]: ran in 74
    366 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOn23.6.1]]: ran in 7
    371 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOn23.6.1]]: ran in 3
    403 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[doSomeDbStuff[slowOn23.6.1]]: ran in 32
    409 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOn23.6.1]]: ran in 6
    413 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOn23.6.1]]: ran in 2
    [0.970s][info][gc] GC(1) Pause Young (Normal) (G1 Evacuation Pause) 109M->32M(2048M) 4.418ms
    450 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[doSomeDbStuff[slowOn23.6.1]]: ran in 37
    505 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOn23.6.1]]: ran in 55
    509 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOn23.6.1]]: ran in 2
    537 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[doSomeDbStuff[slowOn23.6.1]]: ran in 28
    592 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOn23.6.1]]: ran in 55
    595 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - callTimed[setupADatabase[slowOn23.6.1]]: ran in 1
    [1.143s][info][gc] GC(2) Pause Young (Normal) (G1 Evacuation Pause) 110M->31M(2048M) 1.219ms
    623 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[doSomeDbStuff[slowOn23.6.1]]: ran in 27
    678 [main] [INFO] io.vos.service.graph.database.arcadedb.SlowTeardownTest - runTimed[db::drop[slowOn23.6.1]]: ran in 55
    
    Thanks for using JUnit! Support its development at https://junit.org/sponsoring
    
    .
    +-- JUnit Jupiter [OK]
    '-- JUnit Platform Suite [OK]
      '-- Vosio_SlowTeardownTest_Suite [OK]
        '-- JUnit Jupiter [OK]
          '-- SlowTeardownTest [OK]
            +-- slowTestOnBothVersions() [OK]
            | +-- repetition 1 of 5 [OK]
            | +-- repetition 2 of 5 [OK]
            | +-- repetition 3 of 5 [OK]
            | +-- repetition 4 of 5 [OK]
            | '-- repetition 5 of 5 [OK]
            '-- slowTestOn23_6_1() [OK]
              +-- repetition 1 of 5 [OK]
              +-- repetition 2 of 5 [OK]
              +-- repetition 3 of 5 [OK]
              +-- repetition 4 of 5 [OK]
              '-- repetition 5 of 5 [OK]
    
    Test run finished after 749 ms
    [         7 containers found      ]
    [         0 containers skipped    ]
    [         7 containers started    ]
    [         0 containers aborted    ]
    [         7 containers successful ]
    [         0 containers failed     ]
    [        10 tests found           ]
    [         0 tests skipped         ]
    [        10 tests started         ]
    [         0 tests aborted         ]
    [        10 tests successful      ]
    [         0 tests failed          ]
    
    ================================================================================
    Target //javatests/io/vos/service/graph/database/arcadedb:SlowTeardownTest up-to-date:
      bazel-bin/javatests/io/vos/service/graph/database/arcadedb/SlowTeardownTest.jar
      bazel-bin/javatests/io/vos/service/graph/database/arcadedb/SlowTeardownTest
    INFO: Elapsed time: 1.519s, Critical Path: 1.32s
    INFO: 2 processes: 2 linux-sandbox.
    INFO: Build completed successfully, 2 total actions
    //javatests/io/vos/service/graph/database/arcadedb:SlowTeardownTest      PASSED in 1.3s
    
  12. 4 remaining items

  13. erickj commented on Sep 10, 2023

    @erickj
    ContributorAuthor

    Great thanks @lvca !

    Where can I find the new implementation w/ the "GOODBYE" message for the queue (sounds much more clean, btw)? I don't see it committed to main

  14. lvca commented on Sep 10, 2023

    @lvca
    Member

    @erickj it wasn't pushed, no it is.

  15. lvca commented on Sep 10, 2023

    @lvca
    Member

    Instead of using a message, I used an empty list for that. When the page list is empty, then it means te threads must shutdown. In all other cases the list must be never empty.

  16. erickj commented on Sep 10, 2023

    @erickj
    ContributorAuthor

    looks great! thanks

    //javatests/io/vos/service/graph/database/arcadedb:SlowTeardownTest      PASSED in 1.1s
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions