Skip to content

Conversation

@sjudeng
Copy link
Contributor

@sjudeng sjudeng commented Jul 3, 2017

Makes the following updates to fix #383. With these updates the full (default+TinkerPop) test suite runtime for the CQL module is decreased from 15.1 hours to 3.3 hours.

  • A single static cluster instance and a single static session per keyspace managed in CQLStoreManager.
  • Truncate tables instead of drop keyspace in CQLStoreManager.clearStorage(). There was an issue with test failures when switching to truncation that was resolved by deleting the commitlog directory prior to starting embedded test instance in CassandraStorageSetup.
  • Test parallelism was removed to resolve test failures associated with the above updates and for consistency with test executions in other modules.
  • Minor updates to split Travis build matrix for CQL tests and reduce logging (also renamed logging appender names for consistency with other modules).

@janusgraph-bot janusgraph-bot added the cla: yes This PR is compliant with the CLA label Jul 3, 2017
@sjudeng
Copy link
Contributor Author

sjudeng commented Jul 3, 2017

@pkendall64 Would appreciate you taking a look at this to make sure the updates here seem reasonable. One of the main performance improvements came from switching back to table truncation (which I know you had originally) in clearStorage. As mentioned above the errors that occurred when making this switch were resolved by ensuring commitlog directory was deleted. Not sure why this is required for CQL and not Thrift.

@sjudeng sjudeng force-pushed the cql-performance branch from 98b949f to aa2ecc8 Compare July 3, 2017 01:09
@amcp amcp self-assigned this Jul 3, 2017
@amcp
Copy link

amcp commented Jul 3, 2017

@sjudeng instead of one build target now there are four travis builds for cql. How long does each of the lines 43-46 take? let me see if i can find that in the build.

@amcp
Copy link

amcp commented Jul 3, 2017

@sjudeng
Copy link
Contributor Author

sjudeng commented Jul 3, 2017

@amcp Yep. The Travis jobs for CQL (like Cassandra and HBase) are split by test execution and package. Test timing in Travis can vary considerably based on time of day and other external factors. Also by keeping individual Travis job times below 15 minutes they can get the full benefit of travis_retry, which will retry up to three times but only within the overall 50 minute job timeout.

Copy link

@amcp amcp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor questions

private static final int DEFAULT_PORT = 9042;

private static Cluster cluster;
private static Map<String,Session> sessions = new ConcurrentHashMap<>();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not running tests in parallel anymore as per the xml file. why does this need to be concurrent? As on line 117 there is only one keyspace variable for this store manager so what else will go in the sessions map? I searched the original file and this file and I do not see any other uses of the sessions map. Finally, initializeSession is private and it seems to be the only method that mutates the session map.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjudeng I get it, its static. You are considering the case of multiple cql store manager instances in the same JVM. When did this come up in testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amcp No it might not be a problem in testing. Do you think it might cause issues to use concurrent data structure and/or synchronized modifier here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem here.

sessions.put(keyspaceName, cluster.connect());
final Configuration configuration = getStorageConfig();
final Map<String, Object> replication = Match(configuration.get(REPLICATION_STRATEGY)).of(
Case($("SimpleStrategy"), strategy -> HashMap.<String, Object>of("class", strategy, "replication_factor", configuration.get(REPLICATION_FACTOR))),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the dollar sign for? Do we need to use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amcp These are showing as changes but it's just whitespace (indented under the cluster/session==null check). This is original code from #166.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $ turns a predicate into a pattern and most of the vavr APIs take patterns in the 0.9 version.

final Future<Seq<ResultSet>> result = Future.sequence(
Iterator.ofAll(cluster.getMetadata().getKeyspace(this.keyspace).getTables())
.map(table -> Future.fromJavaFuture(sessions.get(this.keyspace).executeAsync(truncate(this.keyspace, table.getName())))));
result.await();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no timeout for await?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

@pkendall64
Copy link
Contributor

Yeah, looks good to me. I have to wonder whether it would be better to use a wrapper to provide the caching in the test area rather than baking it into the main code directly though.

@sjudeng
Copy link
Contributor Author

sjudeng commented Jul 3, 2017

@pkendall64 That's not a bad idea. Probably would be a little ugly but at least it would contain it to test code. I'll take a look.

The suggestion to use the singleton cluster/session comes from http://www.datastax.com/dev/blog/4-simple-rules-when-using-the-datastax-drivers-for-cassandra. But now that I think about it if there needs to be support for connecting to different Cassandra cluster's in the same JVM this would require more updates than provided here and would probably get pretty messy.

…per to manage cluster and session statically in CQL tests.

Signed-off-by: sjudeng <sjudeng@users.noreply.github.com>
@amcp
Copy link

amcp commented Jul 4, 2017

@sjudeng maybe for testing it is useful to connect to be able to connect to different Cassandra clusters, but I think we can just convert the same-jvm-multiple-cluster-cql support issue into an issue on GitHub and move on with these changes?

@sjudeng sjudeng force-pushed the cql-performance branch from aa2ecc8 to 8f1387f Compare July 4, 2017 18:55
@sjudeng
Copy link
Contributor Author

sjudeng commented Jul 4, 2017

@amcp I think it's moot now ... I just pushed updates that refactor to use a wrapper class during testing (thanks @pkendall64). As expected it's a little ugly (needed some reflection on StandardStoreManager) but almost all updates are in test code only. I think it makes a lot more sense this way as it allows clients to build in caching themselves if necessary (e.g. caching CQLStoreManager instances by physical cluster and/or keyspace).

Copy link

@amcp amcp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking forward to getting test time down.

@sjudeng sjudeng merged commit e741dce into JanusGraph:master Jul 7, 2017
bwatson-rti-org pushed a commit to bwatson-rti-org/janusgraph that referenced this pull request Mar 9, 2019
Static cluster/session management in CQL backend
micpod pushed a commit to micpod/janusgraph that referenced this pull request Nov 5, 2019
Static cluster/session management in CQL backend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This PR is compliant with the CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve test performance in CQL backend

4 participants