Manuraj Singh created OAK-9363:
----------------------------------
Summary: Performance issue when creating Binary when creating node
type file
Key: OAK-9363
URL: https://issues.apache.org/jira/browse/OAK-9363
Project: Jackrabbit Oak
Issue Type: Bug
Affects Versions: 1.38.0
Environment: Windows 10 Pro
SSD
FileBlobStore
Repository - SQL Server 2012
RAM-16GB
CPU- INtel Core i7 3.6GHz 4 core with hyperthreading enabled
Reporter: Manuraj Singh
When adding file (size 20Mb) to a node, I am going through following logic
{code:java}
// Add File To Node
public void addFile(Session session, String path, File file)
throws RepositoryException, IOException {
String fileName = file.getName();
Node node = createNode(session, path);
if (node.hasNode(fileName)) {
logger.info("File Already exists");
return;
}
Node fileNode = node.addNode(fileName);
fileNode.setProperty("jcr:nodeType", "file");
fileNode.setProperty("size", file.length());
FileInputStream is = new FileInputStream(file);
try {
// Slow
Binary binary = session.getValueFactory().createBinary(is);
fileNode.setProperty("jcr:data", binary);
Date today = new Date();
fileNode.setProperty("jcr:created", today.toInstant().toString());
session.save();
} catch (Exception e) {
logger.error("Error when creating file node");
} finally {
is.close();
}
}
{code}
Creation of Binary from FileInputStream it is found to be slow. It takes about
4 mins to create a Binary for 20Mb file. It is further found that
MessageDigesting step (SHA-256) is taking a most of the time. The
HASH_ALGORITHM is final in Abstract class and is not overrid-able either.
Am I creating binary correctly?
Is there better way to do this?
Is this known performance issue?
Following is snippet of repository creation.
{code:java}
public Repository getRepository() {
DataSource ds =
RDBDataSourceFactory.forJdbcUrl("jdbc:sqlserver://localhost:1433",
"username", "password");
RDBOptions options = new
RDBOptions().tablePrefix("CR_").dropTablesOnClose(false);
NodeStore store = RDBDocumentNodeStoreBuilder.newRDBDocumentNodeStoreBuilder()
.setBlobStore((BlobStore) new FileBlobStore("REPO/blob")).setRDBConnection(ds,
options)
.build();
Repository repo = new Jcr(new Oak(store)).createRepository();
return repo;
}
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)