Hi,

We are currently using Jackrabbit 2 in a production application and are
looking to move to Oak. In our Jackrabbit 2 application, we are using
MySql, BundleDbPersistenceManager, and a FileDataStore. When using a
similar configuration with Oak, we are noticing significant performance
issues when removing nodes from the repository. To show the performance
issue, I have created a simple example that creates a single parent node of
nt:unstructured type and then adds 150 more child nodes of the same type.
Each node, including the parent, has 10 properties and has a
mix:referenceable mixin.  Here is how I create the DocumentNodeStore:

MySql:

    static FileStore store;
    static FileDataStore fds;

    static void initFileStore() throws IOException {
        File testDir = new File("F:\\oak-datastore");
        FileDataStore _fds = new OakFileDataStore();
        _fds.init(testDir.getPath());
        FileStore.Builder fileStoreBuilder = FileStore.newFileStore(testDir)
            .withBlobStore(new DataStoreBlobStore(_fds))
            .withMaxFileSize(256)
            .withCacheSize(64)
            .withMemoryMapping(false);
        store = fileStoreBuilder.create();
        fds = _fds;
    }

    static DocumentNodeStore createDocumentNodeStoreMySql() {
        System.out.println("Using MySql/FileDataStore");
        String url = "jdbc:mysql://localhost:3306/oak";
        String userName = "root";
        String password = "password";
        String driver = "org.mariadb.jdbc.Driver";
        String prefix = "T" + UUID.randomUUID().toString().replace("-", "");
        DataSource ds = RDBDataSourceFactory.forJdbcUrl(url, userName,
password, driver);
        RDBOptions options = new
RDBOptions().tablePrefix(prefix).dropTablesOnClose(true);
        DocumentNodeStore ns = new
DocumentMK.Builder().setAsyncDelay(0).setBlobStore(
            new DataStoreBlobStore(fds)).setClusterId(1).setRDBConnection(
                ds, options).getNodeStore();
        return ns;
    }

MongoDB:

    static DocumentNodeStore createDocumentNodeStoreMongo() {
        System.out.println("Using MongoDB");
        DB db = new MongoClient("127.0.0.1", 27017).getDB("oak");
        DocumentNodeStore ns = new
DocumentMK.Builder().setMongoDB(db).getNodeStore();
        return ns;
    }

And here is how I create the nodes:

    static Node createNodes(Session session) throws RepositoryException {
        Node root = session.getRootNode();
        Date start = new Date();
        Node parent = root.addNode("Test", "nt:unstructured");
        totalNodes++;
        //
        // Commenting out the following line speeds up delete.
        //
        parent.addMixin("mix:referenceable");

        for (int p = 0; p < 10; p++) {
            parent.setProperty("count" + p, p);
        }
        for (int i = 0; i < 150; i++) {
            createChild(parent, i);
        }
        session.save();
        Date end = new Date();
        double seconds = (double) (end.getTime() - start.getTime()) /
1000.00;
        System.out.println("Created " + totalNodes + " nodes in " + seconds
+ " seconds");
        return parent;
    }

    static void createChild(Node parent, int index)
        throws RepositoryException {
        Node child = parent.addNode("Test" + index, "nt:unstructured");
        totalNodes++;
        //
        // Commenting out the following line speeds up delete.
        //
        child.addMixin("mix:referenceable");

        for (int p = 0; p < 10; p++) {
            child.setProperty("count" + p, p);
        }
    }

Finally, here is how I remove the parent node:

    static void deleteNodes(Session session, Node parent) throws
RepositoryException {
        Date start = new Date();
        parent.remove();
        session.save();
        Date end = new Date();
        double seconds = (double) (end.getTime() - start.getTime()) /
1000.00;
        System.out.println("Deleted " + totalNodes + " nodes in " + seconds
+ " seconds");
    }

When I run using MongoDB:

Using MongoDB
Created 151 nodes in 0.31 seconds
Deleted 151 nodes in 0.341 seconds

When I run using MySql/FileDataStore:

Using MySql/FileDataStore
Created 151 nodes in 0.391 seconds
Deleted 151 nodes in 10.946 seconds

As you can see, deleting the nodes is quite slow using MySql/FileDataStore.
Using Jackrabbit 2, a similar type of operation using MySql and file data
store takes approximately 1 second. Can anyone shed any light on why it is
taking so long to remove the nodes? Is there something I should be doing
differently when creating the DocumentNodeStore?

Thanks,

Mark

Reply via email to