Skip to content

Commit

Permalink
benchmark: fix CreateBenchmark
Browse files Browse the repository at this point in the history
Motivation:
the FsInode is not thread safe, thus each thread should have it's own copy
of root inode.

Modification:
create a copy of fs root inode per thread. Remove irrelevant test cases.

Result:
correct test behavior

Target: master
Acked-by: Lea Morschel
  • Loading branch information
root authored and kofemann committed May 19, 2023
1 parent 10c2fe8 commit 9680a85
Showing 1 changed file with 12 additions and 27 deletions.
Expand Up @@ -55,24 +55,15 @@ public static class DB {
@Param(value = {"weak", "strong", "week_softupdate"})
String wcc;

@Param(value = {"nlink", "no_nlink"})
String ref;

protected FileSystemProvider _fs;

protected HikariDataSource _dataSource;

protected FsInode _rootInode;

@Setup
public void setUp() throws IOException, SQLException, LiquibaseException {
protected FileSystemProvider _fs;


switch (ref) {
case "nlink":
System.setProperty("nlink", "true");
break;
}
@Setup
public void setUp() throws IOException, SQLException, LiquibaseException {

switch (wcc) {
case "week_softupdate":
Expand All @@ -95,8 +86,11 @@ public void setUp() throws IOException, SQLException, LiquibaseException {
config.setJdbcUrl(dbProperties.getProperty("chimera.db.url"));
config.setUsername(dbProperties.getProperty("chimera.db.user"));
config.setPassword(dbProperties.getProperty("chimera.db.password"));
config.setMaximumPoolSize(Runtime.getRuntime().availableProcessors() * 2);
config.setMinimumIdle(100);
config.setMaximumPoolSize(128);
config.setMinimumIdle(64);
config.setAutoCommit(true);
config.setTransactionIsolation("TRANSACTION_READ_COMMITTED");


_dataSource = new HikariDataSource(config);

Expand All @@ -119,7 +113,6 @@ public void setUp() throws IOException, SQLException, LiquibaseException {
PlatformTransactionManager txManager = new DataSourceTransactionManager(_dataSource);
_fs = new JdbcFs(_dataSource, txManager);
_rootInode = _fs.path2inode("/");

_fs.createTag(_rootInode, "aTag");
FsInode tagInode = new FsInode_TAG(_fs, _rootInode.ino(), "aTag");
byte[] data = "data".getBytes(UTF_8);
Expand All @@ -129,26 +122,18 @@ public void setUp() throws IOException, SQLException, LiquibaseException {

@State(Scope.Thread)
public static class ThreadCtx {

@Param(value = {"all-in-one", "one-per-thread"})
String dir;

FsInode threadRoot;
FileSystemProvider fs;

@Setup
public void setUp(DB db) throws ChimeraFsException {
fs = db._fs;
threadRoot = dir.equals("all-in-one") ? db._rootInode
: db._rootInode.mkdir(Thread.currentThread().getName());
public void setUp(DB db) throws ChimeraFsException, SQLException {
threadRoot = db._fs.path2inode("/");
}

}

@TearDown
public void tearDown() throws Exception {
_dataSource.close();
_fs.close();
_dataSource.close();
}
}

Expand All @@ -165,7 +150,7 @@ public FsInode benchmarkCreateDir(ThreadCtx ctx) throws ChimeraFsException {
public FsInode benchmarkCreateDeleteDir(ThreadCtx ctx) throws ChimeraFsException {
var dirName = UUID.randomUUID().toString();
FsInode sub = ctx.threadRoot.mkdir(dirName);
ctx.fs.remove(ctx.threadRoot, dirName, sub);
ctx.threadRoot.remove(dirName);
return sub;
}

Expand Down

0 comments on commit 9680a85

Please sign in to comment.