GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Performance issue with client side transaction management · Issue #1390 · ArcadeData/arcadedb

Performance issue with client side transaction management #1390

New issue
Copy link
New issue
Copy link
Closed
Closed
Performance issue with client side transaction management#1390
Copy link
Assignees
lvca
Labels
performancewontfixThis will not be worked on
Milestone
23.12.1

Description

@devcode100
devcode100
opened on Dec 18, 2023
Issue body actions

ArcadeDB Version:

ArcadeDB Server version: 23.11.1

OS and JDK Version:

OS = Linux(ubuntu 22.04)
JDK version = 17
Artifacts:
arcadedb-gremlin = 23.12.1-SNAPSHOT
arcadedb-network = 23.12.1-SNAPSHOT

Expected behavior

Simple mutation logics within a transaction block, such as adding new vertex with ~3 properties should not take more than ~20ms in a database with existing record size of 1000 records.

Actual behavior

The simple mutation logic is taking 300ms.

Steps to reproduce

There are two implementation styles which will help to compare the performance issue.

  1. The mutation logic ran as below without explicitly starting transaction at client side.
    This implementation will commit transaction at server side.
    Performance: 10ms. This is an expected performance.
    Drawback: Unable to perform client side transaction management. In case of rollback due to client side exceptions, with this implementation is not possible.
       ArcadeGraph arcadeGraph = arcadeGraphFactory.get();
        GraphTraversalSource g = arcadeGraph.traversal();
        try {
            g.addV("Country").property("id", id).property("country", country).property("code", code).iterate();
        } catch (Exception e) {
            logger.debug("Exception: {}", e);
        } finally {
            arcadeGraph.close();
        }
  1. The mutation logic ran as below by starting transaction using arcadeGraph.tx().begin() and commit at client side:
        ArcadeGraph arcadeGraph = arcadeGraphFactory.get();
        GraphTraversalSource g = arcadeGraph.tx().begin();
        try {
            g.addV("Country").property("id", id).property("country", country).property("code", code).iterate();

            arcadeGraph.tx().commit();
        } catch (Exception e) {
            arcadeGraph.tx().rollback();
        } finally {
            arcadeGraph.close();
        }

Performance: 300ms. This is an issue.
But here full control of transaction is possible.

To summarize, the expectation is to have the latency of mutation logic to be at ~10-20ms, together with the ability to control transaction management at client side.

Activity

  1. lvca
    self-assigned this
    on Dec 18, 2023
  2. lvca
    added
    performance
    on Dec 18, 2023
  3. lvca
    added this to the 23.12.1 milestone on Dec 18, 2023
  4. lvca commented on Dec 18, 2023

    @lvca
    lvca
    on Dec 18, 2023
    Member
    More actions

    I've created 2 new tests in our test suite:

    @Test
      public void executeTraversalTxMgmt() {
        try (ArcadeGraphFactory pool = ArcadeGraphFactory.withRemote("127.0.0.1", 2480, getDatabaseName(), "root",
            BaseGraphServerTest.DEFAULT_PASSWORD_FOR_TESTS)) {
          try (final ArcadeGraph graph = pool.get()) {
            for (int i = 0; i < 1000; i++) {
              GraphTraversalSource g = graph.tx().begin();
              g.addV("Country").property("id", i).property("country", "USA").property("code", i).iterate();
              g.tx().commit();
            }
    
            Assertions.assertEquals(1000, graph.traversal().V().hasLabel("Country").count().toList().get(0));
          }
        }
      }
    
      @Test
      public void executeTraversalNoTxMgmt() {
        try (ArcadeGraphFactory pool = ArcadeGraphFactory.withRemote("127.0.0.1", 2480, getDatabaseName(), "root",
            BaseGraphServerTest.DEFAULT_PASSWORD_FOR_TESTS)) {
          try (final ArcadeGraph graph = pool.get()) {
            for (int i = 0; i < 1000; i++)
              graph.traversal().addV("Country").property("id", i).property("country", "USA").property("code", i).iterate();
          }
    
          try (final ArcadeGraph graph = pool.get()) {
            Assertions.assertEquals(1000, graph.traversal().V().hasLabel("Country").count().toList().get(0));
          }
        }
      }
    

    And the version that begin/commit a transaction per vertex, 1,000 times, it's a little slower than the one that executes 1,000 adds a vertex in the same transaction:

    • executeTraversalNoTxMgmt: 4.6 sec
    • executeTraversalTxMgmt: 5.4 sec

    How can I reproduce this issue? Could your issue be related to the client/server network?

    Could you please get the latest source and run the tests above under the class com.arcadedb.server.gremlin.RemoteGremlinFactoryIT?

  5. lvca
    added a commit that references this issue on Dec 18, 2023

    test: addes a couple of tests for issue #1390

    ecdb67d
  6. devcode100 commented on Dec 18, 2023

    @devcode100
    devcode100
    on Dec 18, 2023
    Author
    More actions

    One of the key difference between the above Tests and the implementation I shared is that I use ArcadeGraphFactory as singleton and create ArcadeGraph instance for every request. The requests are concurrent and may not be always sequential.

  7. lvca commented on Dec 18, 2023

    @lvca
    lvca
    on Dec 18, 2023
    Member
    More actions

    I tested by getting a new graph every time, but since we have a pool now, the performance are identical to the previous tests. Trying to spin multiple threads

  8. lvca commented on Dec 18, 2023

    @lvca
    lvca
    on Dec 18, 2023
    Member
    More actions

    Tried multi threads, same time:

    @Test
      public void executeTraversalTxMgmtMultiThreads() throws InterruptedException {
        try (ArcadeGraphFactory pool = ArcadeGraphFactory.withRemote("127.0.0.1", 2480, getDatabaseName(), "root",
            BaseGraphServerTest.DEFAULT_PASSWORD_FOR_TESTS)) {
    
          try (final ArcadeGraph graph = pool.get()) {
            graph.getDatabase().getSchema().createVertexType("Country");
          }
    
          final ExecutorService executorService = Executors.newFixedThreadPool(10);
    
          for (int i = 0; i < 1000; i++) {
            final int id = i;
            executorService.submit(() -> {
              try (final ArcadeGraph graph = pool.get()) {
                GraphTraversalSource g = graph.tx().begin();
                g.addV("Country").property("id", id).property("country", "USA").property("code", id).iterate();
                g.tx().commit();
              }
            });
          }
    
          executorService.shutdown();
          executorService.awaitTermination(60, TimeUnit.SECONDS);
    
          try (final ArcadeGraph graph = pool.get()) {
            Assertions.assertTrue(graph.traversal().V().hasLabel("Country").count().toList().get(0) > 800);
          }
        }
      }

    I think it could be the latency between client and server. How are they connected? LAN? Internet?

  9. devcode100 commented on Dec 18, 2023

    @devcode100
    devcode100
    on Dec 18, 2023
    Author
    More actions

    Am using the same connection and setup for both the scenarios(10ms and 300ms code blocks run on same setup)and at this moment I can rule out bandwidth dependency.
    If you can follow the below *Steps to Replicate:

    • with a real remote connection
      Spin up new cloud VM(I use AWS EC2 - Ubuntu 22.04) specifically test on cloud VM and connect to it remotely from client. at least this is how I could replicate ]
    1. Auto assign public IP(machine is publicly assessable).
    2. Set up JDK 17
    3. Download latest distro: https://github.com/ArcadeData/arcadedb/releases/download/23.11.1/arcadedb-23.11.1.tar.gz
    4. Clone the repo: https://github.com/ArcadeData/arcadedb and use main branch to execute mvn clean install
    5. Replace the arcadedb-*.jars(11 jars) in the arcadedb server lib folder.
    6. Run the command from home dir to start the server:
      bin/server.sh -Darcadedb.server.plugins="GremlinServer:com.arcadedb.server.gremlin.GremlinServerPlugin"
    7. Configure java client to connect to the remote server using ArcadeGraphFactory(use the same 23.12.1-SNAPSHOT in pom.ml - client app.)

    Enabled logs. PF the trace for the mutation logic which took > ~300ms.
    Tx_perf_issue

    I tried to replicate in local[windows](follow step 3-7), am not getting the issue, Tx is fast.

    If you are not able to replicate even after following the above steps(similar) then I will wait for the next release to upgrade the server and maven libs without any manual artifact build and replacement, and will test it again.

    Note:-
    If the complete tx() is sum of below 3 network round trips, then its fair to have the latency as I mentioned and could be considered as working as expected. The ping latency is fairly high for the cloud VM's I use.

    • GraphTraversalSource g = graph.tx().begin(); // Network Round trip - 150ms
    • g.addV("Country").property("id", id).property("country", "USA").property("code", id).iterate(); // Network Round trip - 150ms
    • g.tx().commit(); // Network Round trip - 150ms
  10. lvca commented on Dec 18, 2023

    @lvca
    lvca
    on Dec 18, 2023
    Member
    More actions

    I found the reason. With the TX management, ArcadeDB is using the HTTP protocol and it's sending 3 HTTP commands for each cycle to the server:

    1. begin
    2. gremlin command to add a vertex
    3. commit

    With the non-TX management (the fast one), the client communicates with the Gremlin server by using the binary protocol + the transaction management is done on the server side.

    So the difference in speed is mainly for the 3 requests against 1. The 3 requests cannot be sent asynchronously because they are sequential begin/addV/commit. You pay the latency here of waiting for the 2 additional commands.

    About the HTTP vs Binary protocols, I don't think this makes a lot of difference.

  11. lvca commented on Dec 19, 2023

    @lvca
    lvca
    on Dec 19, 2023
    Member
    More actions

    Tried back with using only Gremlin, but this is the exception on the Gremlin side:

    java.lang.IllegalStateException: javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.traversal() is applicable for argument types: () values: []
    

    And this was the source:

    @Test
      public void executeTraversalTxMgmtBinary() throws InterruptedException {
        try (ArcadeGraphFactory pool = ArcadeGraphFactory.withRemote("127.0.0.1", 2480, getDatabaseName(), "root",
            BaseGraphServerTest.DEFAULT_PASSWORD_FOR_TESTS)) {
    
          for (int i = 0; i < 1000; i++) {
            final int id = i;
            try (final ArcadeGraph graph = pool.get()) {
              GraphTraversalSource g = graph.traversal();
              g.tx().begin();
              g.addV("Country").property("id", id).property("country", "USA").property("code", id).iterate();
              g.tx().commit();
            }
          }
    
          try (final ArcadeGraph graph = pool.get()) {
            Assertions.assertEquals(1000, graph.traversal().V().hasLabel("Country").count().toList().get(0));
          }
        }
      }

    So I'm closing the issue, knowing that by using explicit TX control means involving 2 commands per vertex

  12. lvca
    closed this as completedon Dec 19, 2023
  13. lvca
    added
    wontfixThis will not be worked on
    on Dec 19, 2023
  14. lvca
    added a commit that references this issue on Dec 19, 2023

    test: changes the tests for #1390

    baca572
  15. mergify
    added a commit that references this issue on Jun 7, 2026

    chore(deps): bump neo4j-driver from 6.0.1 to 6.1.0 in /e2e-js [skip ci]

    8f88285
  16. tae898
    added 3 commits that reference this issue on Jun 28, 2026

    test: addes a couple of tests for issue ArcadeData#1390

    939fd2e

    test: changes the tests for ArcadeData#1390

    ec4e3db

    chore(deps): bump neo4j-driver from 6.0.1 to 6.1.0 in /e2e-js [skip ci]

    591aea3
  17. mergify
    added 2 commits that reference this issue on Aug 9, 2026

    chore(deps-dev): bump testcontainers from 12.0.4 to 12.1.0 in /e2e-js…

    82fd973

    chore(deps-dev): bump testcontainers from 12.0.4 to 12.1.0 in /e2e-st…

    63efb33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @lvca
    lvca

Labels

performancewontfixThis will not be worked on

Type

No type

Projects

No projects

    Milestone

    • 23.12.1

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.