Skip to content

Commit

Permalink
Switch to Java 18 and fix performance issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Lichtenberger committed Mar 30, 2022
1 parent 665e03a commit e184278
Show file tree
Hide file tree
Showing 18 changed files with 285 additions and 159 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '18'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '18'
- name: Gradle deploy
run: ./gradlew travisReleaseSnapshot --info
- name: Login to Docker Hub
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
- name: Set up JDK 18
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '18'
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stage-1
# Build jar

FROM gradle:7.2-jdk17 as builder
FROM gradle:7.4-jdk18 as builder
LABEL maintainer="Johannes Lichtenberger <[email protected]>"
WORKDIR /usr/app/

Expand All @@ -12,7 +12,7 @@ RUN gradle build --refresh-dependencies -x test
# Stage-2
# Copy jar and run the server

FROM gradle:jdk17-alpine as server
FROM gradle:jdk18-alpine as server
RUN apk update && apk add --no-cache bash && apk add --no-cache gcompat
ENV VERTICLE_FILE sirix-rest-api-*-SNAPSHOT-fat.jar
# Set the location of the verticles
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ git clone https://github.com/sirixdb/sirix.git

or use the following dependencies in your Maven or Gradle project.

**SirixDB uses Java 17, thus you need an up-to-date Gradle (if you want to work on SirixDB) and an IDE (for instance IntelliJ or Eclipse).**
**SirixDB uses Java 18, thus you need an up-to-date Gradle (if you want to work on SirixDB) and an IDE (for instance IntelliJ or Eclipse).**

### Maven artifacts
At this stage of development, you should use the latest SNAPSHOT artifacts from [the OSS snapshot repository](https://oss.sonatype.org/content/repositories/snapshots/io/sirix/) to get the most recent changes.
At this stage of development, you should use the latest SNAPSHOT aSrtifacts from [the OSS snapshot repository](https://oss.sonatype.org/content/repositories/snapshots/io/sirix/) to get the most recent changes.

Just add the following repository section to your POM or build.gradle file:
```xml
Expand Down
2 changes: 0 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ From there on or even before releasing 1.0.0 I'd love to put work into our [**we

- **Sharding** I'll have a look into how best to write and read from a distributed transaction log based on Apache BookKeeper most probably. Main goal is to shard SirixDB databases, that is replicate resources, partition a database... *However a community discussion would be best*.

- **Rewrite rules for the query compiler** We have to figure out how to rewrite the AST in Brackit to automatically take indexes and various statistics into account. In the future: Cost based optimizer. However I'm no query compiler expert, so as always a community effort would be awesome

## In the long run

- **Full text index** Would be awesome to provide full text indexing and querying capabilitie
Expand Down
64 changes: 32 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ afterReleaseBuild.dependsOn(uploadPublications)
allprojects {
group = 'io.sirix'

apply plugin: 'jacoco'
// apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'idea'

Expand All @@ -86,8 +86,8 @@ subprojects {
apply plugin: "com.diffplug.spotless"

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_18
targetCompatibility = JavaVersion.VERSION_18
withSourcesJar()
withJavadocJar()

Expand All @@ -99,7 +99,7 @@ subprojects {
javadoc {
failOnError = false
options {
addStringOption('-release', '17')
addStringOption('-release', '18')
addBooleanOption('-enable-preview', true)
addStringOption('-add-modules', 'jdk.incubator.foreign')
}
Expand All @@ -120,16 +120,16 @@ subprojects {
}
}

jacoco {
toolVersion = "0.8.7"
}

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
// jacoco {
// toolVersion = "0.8.7"
// }
//
// jacocoTestReport {
// reports {
// xml.enabled = true
// html.enabled = true
// }
// }

publishing {
publications {
Expand Down Expand Up @@ -235,21 +235,21 @@ subprojects {
}
}

task jacocoRootReport(type: JacocoReport) {
description = 'Generates an aggregate report from all subprojects'
dependsOn = subprojects.test
sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories.setFrom files(subprojects.sourceSets.main.output)
executionData.setFrom files(subprojects.jacocoTestReport.executionData).filter {
file -> file.exists()
}.asList()
reports {
html.enabled = true
xml.enabled = true
}
}

coveralls {
sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
//task jacocoRootReport(type: JacocoReport) {
// description = 'Generates an aggregate report from all subprojects'
// dependsOn = subprojects.test
// sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
// classDirectories.setFrom files(subprojects.sourceSets.main.output)
// executionData.setFrom files(subprojects.jacocoTestReport.executionData).filter {
// file -> file.exists()
// }.asList()
// reports {
// html.enabled = true
// xml.enabled = true
// }
//}
//
//coveralls {
// sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
// jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
//}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.sirix.utils.OS;

import org.checkerframework.checker.index.qual.NonNegative;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
Expand Down Expand Up @@ -161,8 +162,8 @@ public static int compareStructure(final Path file) {
/**
* Standard storage.
*/
private static final StorageType STORAGE =
OS.isWindows() ? StorageType.FILECHANNEL : OS.is64Bit() ? StorageType.MEMORY_MAPPED : StorageType.FILECHANNEL;
private static final StorageType STORAGE = StorageType.FILECHANNEL;
// OS.isWindows() ? StorageType.FILECHANNEL : OS.is64Bit() ? StorageType.MEMORY_MAPPED : StorageType.FILECHANNEL;

/**
* Standard versioning approach.
Expand Down Expand Up @@ -265,12 +266,17 @@ public static int compareStructure(final Path file) {
/**
* Determines if diffs are going to be stored or not.
*/
private final boolean storeDiffs;
public final boolean storeDiffs;

/**
* Determines if custom commit timestamps should be stored or not.
*/
private final boolean customCommitTimestamps;
public final boolean customCommitTimestamps;

/**
* Store the full node history of each record.
*/
public final boolean storeNodeHistory;

// END MEMBERS FOR FIXED FIELDS

Expand Down Expand Up @@ -305,6 +311,7 @@ private ResourceConfiguration(final ResourceConfiguration.Builder builder) {
storeChildCount = builder.storeChildCount;
storeDiffs = builder.storeDiffs;
customCommitTimestamps = builder.customCommitTimestamps;
storeNodeHistory = builder.storeNodeHistory;
}

public boolean customCommitTimestamps() {
Expand Down Expand Up @@ -419,13 +426,17 @@ public boolean getStoreChildCount() {
return storeChildCount;
}

public boolean storeNodeHistory() {
return storeNodeHistory;
}

/**
* JSON names.
*/
private static final String[] JSONNAMES =
{ "revisioning", "revisioningClass", "numbersOfRevisiontoRestore", "byteHandlerClasses", "storageKind",
"hashKind", "hashFunction", "compression", "pathSummary", "resourceID", "deweyIDsStored", "persistenter",
"storeDiffs", "customCommitTimestamps" };
"storeDiffs", "customCommitTimestamps", "storeNodeHistory" };

/**
* Serialize the configuration.
Expand Down Expand Up @@ -471,6 +482,8 @@ public static void serialize(final ResourceConfiguration config) throws SirixIOE
jsonWriter.name(JSONNAMES[12]).value(config.storeDiffs);
// Custom commit timestamps.
jsonWriter.name(JSONNAMES[13]).value(config.customCommitTimestamps);
// Node history.
jsonWriter.name(JSONNAMES[14]).value(config.storeNodeHistory);
jsonWriter.endObject();
} catch (final IOException e) {
throw new SirixIOException(e);
Expand Down Expand Up @@ -564,6 +577,9 @@ public static ResourceConfiguration deserialize(final Path file) throws SirixIOE
name = jsonReader.nextName();
assert name.equals(JSONNAMES[13]);
final boolean customCommitTimestamps = jsonReader.nextBoolean();
name = jsonReader.nextName();
assert name.equals(JSONNAMES[14]);
final boolean storeNodeHistory = jsonReader.nextBoolean();

jsonReader.endObject();
jsonReader.close();
Expand All @@ -584,7 +600,8 @@ public static ResourceConfiguration deserialize(final Path file) throws SirixIOE
.buildPathSummary(pathSummary)
.useDeweyIDs(deweyIDsStored)
.storeDiffs(storeDiffs)
.customCommitTimestamps(customCommitTimestamps);
.customCommitTimestamps(customCommitTimestamps)
.storeNodeHistory(storeNodeHistory);

// Deserialized instance.
final ResourceConfiguration config = new ResourceConfiguration(builder);
Expand Down Expand Up @@ -670,6 +687,11 @@ public static final class Builder {
*/
private boolean customCommitTimestamps;

/**
* Determines if node history should be stored or not.
*/
private boolean storeNodeHistory;

/**
* Constructor, setting the mandatory fields.
*
Expand All @@ -680,9 +702,6 @@ public Builder(final String resource) {
this.resource = checkNotNull(resource);
pathSummary = true;
storeChildCount = true;
// final Path path =
// mDBConfig.getFile().resolve(DatabaseConfiguration.DatabasePaths.DATA.getFile()).resolve(mResource);

byteHandler = new ByteHandlePipeline(new SnappyCompressor());// new Encryptor(path));
}

Expand Down Expand Up @@ -818,6 +837,17 @@ public Builder customCommitTimestamps(final boolean customCommitTimestamps) {
return this;
}

/**
* Set to {@code true} if node history should be stored.
*
* @param storeNodeHistory {code true}, if node history should be stored, {@code false} if not
* @return reference to the builder object
*/
public Builder storeNodeHistory(boolean storeNodeHistory) {
this.storeNodeHistory = storeNodeHistory;
return this;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
Expand All @@ -828,6 +858,12 @@ public String toString() {
.add("PathSummary", pathSummary)
.add("TextCompression", useTextCompression)
.add("Store diffs", storeDiffs)
.add("Store child count", storeChildCount)
.add("Store node history", storeNodeHistory)
.add("Custom commit timestamps", customCommitTimestamps)
.add("Max number of revisions to restore", maxNumberOfRevisionsToRestore)
.add("Use deweyIDs", useDeweyIDs)
.add("Byte handler pipeline", byteHandler)
.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public W commit(@Nullable final String commitMessage, @Nullable final Instant co
}

// Reinstantiate everything.
if (afterCommitState == AfterCommitState.KeepOpen) {
if (afterCommitState == AfterCommitState.KEEP_OPEN) {
reInstantiate(getId(), preCommitRevision);
state = State.Running;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,23 @@ public Path getCommitFile() {

@Override
public W beginNodeTrx() {
return beginNodeTrx(0, 0, TimeUnit.MILLISECONDS, AfterCommitState.KeepOpen);
return beginNodeTrx(0, 0, TimeUnit.MILLISECONDS, AfterCommitState.KEEP_OPEN);
}

@Override
public W beginNodeTrx(final @NonNegative int maxNodeCount) {
return beginNodeTrx(maxNodeCount, 0, TimeUnit.MILLISECONDS, AfterCommitState.KeepOpen);
return beginNodeTrx(maxNodeCount, 0, TimeUnit.MILLISECONDS, AfterCommitState.KEEP_OPEN);
}

@Override
public W beginNodeTrx(final @NonNegative int maxTime, final @NonNull TimeUnit timeUnit) {
return beginNodeTrx(0, maxTime, timeUnit, AfterCommitState.KeepOpen);
return beginNodeTrx(0, maxTime, timeUnit, AfterCommitState.KEEP_OPEN);
}

@Override
public W beginNodeTrx(final @NonNegative int maxNodeCount, final @NonNegative int maxTime,
final @NonNull TimeUnit timeUnit) {
return beginNodeTrx(maxNodeCount, maxTime, timeUnit, AfterCommitState.KeepOpen);
return beginNodeTrx(maxNodeCount, maxTime, timeUnit, AfterCommitState.KEEP_OPEN);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.sirix.access.trx.node;

public enum AfterCommitState {
KeepOpen,
KEEP_OPEN,

Close
CLOSE
}
Loading

0 comments on commit e184278

Please sign in to comment.