Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to change to single MemorySegment for slots #737

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ subprojects {
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+DebugNonSafepoints",
//"-XX:+UseShenandoahGC",
// "-Xlog:gc*=debug:file=g1.log",
// "-XX:+UseZGC",
"-Xlog:gc*=debug:file=g1.log",
"-XX:+UseZGC",
// "-XX:+ZGenerational",
// "-verbose:gc",
"-verbose:gc",
"-XX:+HeapDumpOnOutOfMemoryError",
//"-XX:HeapDumpPath=heapdump.hprof",
"-XX:+UseStringDeduplication",
Expand All @@ -285,7 +285,7 @@ subprojects {
/* "-XX:MaxInlineSize=500" */])

minHeapSize = '5g'
maxHeapSize = '8g'
maxHeapSize = '12g'
}
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
253 changes: 0 additions & 253 deletions bundles/sirix-core/g1-chicago.log

This file was deleted.

38,662 changes: 0 additions & 38,662 deletions bundles/sirix-core/g1-detailed.log

This file was deleted.

13,733 changes: 0 additions & 13,733 deletions bundles/sirix-core/shenandoah.log

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public LocalDatabase(final TransactionManager transactionManager, final Database
this.bufferManagers = Databases.getBufferManager(dbConfig.getDatabaseFile());
}

private void addResourceToBufferManagerMapping(Path resourceFile, ResourceConfiguration resourceConfig) {
bufferManagers.put(resourceFile, new BufferManagerImpl(10_000, 1_000, 5_000, 50_000, 500, 20));
private void addResourceToBufferManagerMapping(Path resourceFile) {
bufferManagers.put(resourceFile, new BufferManagerImpl(500_000, 65_536 * 100, 5_000, 50_000, 500, 20));
}

@Override
Expand Down Expand Up @@ -148,7 +148,7 @@ private void addResourceToBufferManagerMapping(Path resourceFile, ResourceConfig

// Add resource to buffer manager mapping.
if (!bufferManagers.containsKey(resourcePath)) {
addResourceToBufferManagerMapping(resourcePath, resourceConfig);
addResourceToBufferManagerMapping(resourcePath);
}

return resourceStore.beginResourceSession(resourceConfig, bufferManagers.get(resourcePath), resourcePath);
Expand Down Expand Up @@ -220,7 +220,7 @@ public synchronized boolean createResource(final ResourceConfiguration resourceC
}

if (!bufferManagers.containsKey(path)) {
addResourceToBufferManagerMapping(path, resourceConfig);
addResourceToBufferManagerMapping(path);
}

return returnVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@
import com.google.common.base.MoreObjects;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.sirix.access.trx.node.HashType;
import io.sirix.node.NodeSerializerImpl;
import io.sirix.node.interfaces.RecordSerializer;
import net.openhft.hashing.LongHashFunction;
import org.checkerframework.checker.index.qual.NonNegative;
import io.sirix.BinaryEncodingVersion;
import io.sirix.access.trx.node.HashType;
import io.sirix.exception.SirixIOException;
import io.sirix.io.StorageType;
import io.sirix.io.bytepipe.ByteHandler;
import io.sirix.io.bytepipe.ByteHandlerKind;
import io.sirix.io.bytepipe.ByteHandlerPipeline;
import io.sirix.io.bytepipe.LZ4Compressor;
import io.sirix.node.NodeSerializerImpl;
import io.sirix.node.interfaces.RecordSerializer;
import io.sirix.settings.VersioningType;
import io.sirix.utils.OS;
import net.openhft.hashing.LongHashFunction;
import org.checkerframework.checker.index.qual.NonNegative;

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

/**
* Standard versioning approach.
Expand Down Expand Up @@ -709,7 +709,7 @@ public static final class Builder {
/**
* Determines if node history should be stored or not.
*/
private boolean storeNodeHistory;
private boolean storeNodeHistory = true;

private BinaryEncodingVersion binaryEncodingVersion = BINARY_ENCODING_VERSION;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class AbstractNodeReadOnlyTrx<T extends NodeCursor & NodeReadOnl
/**
* ID of transaction.
*/
protected final long id;
protected final int id;

/**
* State of transaction including all cached stuff.
Expand Down Expand Up @@ -75,7 +75,7 @@ public abstract class AbstractNodeReadOnlyTrx<T extends NodeCursor & NodeReadOnl
* @param resourceSession The resource manager for the current transaction
* @param itemList Read-transaction-exclusive item list.
*/
protected AbstractNodeReadOnlyTrx(final @NonNegative long trxId, final @NonNull PageReadOnlyTrx pageReadTransaction,
protected AbstractNodeReadOnlyTrx(final @NonNegative int trxId, final @NonNull PageReadOnlyTrx pageReadTransaction,
final @NonNull N documentNode, final InternalResourceSession<T, W> resourceSession,
final ItemList<AtomicValue> itemList) {
this.itemList = itemList;
Expand Down Expand Up @@ -196,7 +196,7 @@ public long getPathNodeKey() {
}

@Override
public long getId() {
public int getId() {
assertNotClosed();
return id;
}
Expand Down Expand Up @@ -534,11 +534,8 @@ public boolean isClosed() {
}

@Override
public synchronized void close() {
public void close() {
if (!isClosed) {
// Close own state.
pageReadOnlyTrx.close();

// Callback on session to make sure everything is cleaned up.
resourceSession.closeReadTransaction(id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,7 @@ protected void runLocked(final Runnable runnable) {
if (lock != null) {
lock.lock();
}
try {
runnable.run();
} finally {
}
runnable.run();
if (lock != null) {
lock.unlock();
}
Expand Down Expand Up @@ -346,7 +343,7 @@ private void intermediateCommitIfRequired() {
* @param trxID transaction ID
* @param revNumber revision number
*/
private void reInstantiate(final @NonNegative long trxID, final @NonNegative int revNumber) {
private void reInstantiate(final @NonNegative int trxID, final @NonNegative int revNumber) {
// Reset page transaction to new uber page.
resourceSession.closeNodePageWriteTransaction(getId());
pageTrx =
Expand Down Expand Up @@ -397,7 +394,7 @@ public synchronized W rollback() {
modificationCount = 0L;

// Close current page transaction.
final long trxID = getId();
final int trxID = getId();
final int revision = getRevisionNumber();
final int revNumber = pageTrx.getUberPage().isBootstrap() ? 0 : revision - 1;

Expand Down Expand Up @@ -445,7 +442,7 @@ public W revertTo(final int revision) {
resourceSession.assertAccess(revision);

// Close current page transaction.
final long trxID = getId();
final int trxID = getId();
final int revNumber = getRevisionNumber();

// Reset internal transaction state to new uber page.
Expand Down Expand Up @@ -555,7 +552,7 @@ public synchronized void close() {
}

// Release all state immediately.
final long trxId = getId();
final int trxId = getId();
nodeReadOnlyTrx.close();
resourceSession.closeWriteTransaction(trxId);
removeCommitFile();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package io.sirix.access.trx.node;

import cn.danielw.fop.*;
import io.sirix.api.*;
import io.brackit.query.jdm.DocumentException;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import io.sirix.access.DatabaseConfiguration;
import io.sirix.access.ResourceConfiguration;
import io.sirix.access.ResourceStore;
Expand All @@ -15,6 +11,7 @@
import io.sirix.access.trx.page.PageTrxFactory;
import io.sirix.access.trx.page.PageTrxReadOnlyFactory;
import io.sirix.access.trx.page.RevisionRootPageReader;
import io.sirix.api.*;
import io.sirix.api.json.JsonNodeTrx;
import io.sirix.api.xml.XmlNodeTrx;
import io.sirix.cache.BufferManager;
Expand All @@ -32,6 +29,9 @@
import io.sirix.node.interfaces.Node;
import io.sirix.page.UberPage;
import io.sirix.settings.Fixed;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -46,7 +46,7 @@
import java.util.List;
import java.util.Optional;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
Expand All @@ -73,17 +73,17 @@ public abstract class AbstractResourceSession<R extends NodeReadOnlyTrx & NodeCu
/**
* Remember all running node transactions (both read and write).
*/
final ConcurrentMap<Long, R> nodeTrxMap;
final ConcurrentMap<Integer, R> nodeTrxMap;

/**
* Remember all running page transactions (both read and write).
*/
final ConcurrentMap<Long, PageReadOnlyTrx> pageTrxMap;
final ConcurrentMap<Integer, PageReadOnlyTrx> pageTrxMap;

/**
* Remember the write seperately because of the concurrent writes.
*/
final ConcurrentMap<Long, PageTrx> nodePageTrxMap;
final ConcurrentMap<Integer, PageTrx> nodePageTrxMap;

/**
* Lock for blocking the commit.
Expand All @@ -103,12 +103,12 @@ public abstract class AbstractResourceSession<R extends NodeReadOnlyTrx & NodeCu
/**
* Atomic counter for concurrent generation of node transaction id.
*/
private final AtomicLong nodeTrxIDCounter;
private final AtomicInteger nodeTrxIDCounter;

/**
* Atomic counter for concurrent generation of page transaction id.
*/
final AtomicLong pageTrxIDCounter;
final AtomicInteger pageTrxIDCounter;

private final AtomicReference<ObjectPool<PageReadOnlyTrx>> pool;

Expand Down Expand Up @@ -169,8 +169,8 @@ protected AbstractResourceSession(final @NonNull ResourceStore<? extends Resourc
pageTrxMap = new ConcurrentHashMap<>();
nodePageTrxMap = new ConcurrentHashMap<>();

nodeTrxIDCounter = new AtomicLong();
pageTrxIDCounter = new AtomicLong();
nodeTrxIDCounter = new AtomicInteger();
pageTrxIDCounter = new AtomicInteger();
commitLock = new ReentrantLock(false);

this.writeLock = requireNonNull(writeLock);
Expand Down Expand Up @@ -234,7 +234,7 @@ public Cache<RBIndexKey, Node> getIndexCache() {
* @return a new {@link PageTrx} instance
*/
@Override
public PageTrx createPageTransaction(final @NonNegative long id, final @NonNegative int representRevision,
public PageTrx createPageTransaction(final @NonNegative int id, final @NonNegative int representRevision,
final @NonNegative int storedRevision, final Abort abort, boolean isBoundToNodeTrx) {
checkArgument(id >= 0, "id must be >= 0!");
checkArgument(representRevision >= 0, "representRevision must be >= 0!");
Expand Down Expand Up @@ -363,9 +363,9 @@ public synchronized R beginNodeReadOnlyTrx(@NonNegative final int revision) {
return reader;
}

public abstract R createNodeReadOnlyTrx(long nodeTrxId, PageReadOnlyTrx pageReadTrx, Node documentNode);
public abstract R createNodeReadOnlyTrx(int nodeTrxId, PageReadOnlyTrx pageReadTrx, Node documentNode);

public abstract W createNodeReadWriteTrx(long nodeTrxId, PageTrx pageTrx, int maxNodeCount, Duration autoCommitDelay,
public abstract W createNodeReadWriteTrx(int nodeTrxId, PageTrx pageTrx, int maxNodeCount, Duration autoCommitDelay,
Node documentNode, AfterCommitState afterCommitState);

static Node getDocumentNode(final PageReadOnlyTrx pageReadTrx) {
Expand Down Expand Up @@ -447,7 +447,7 @@ public synchronized W beginNodeTrx(final @NonNegative int maxNodeCount, final @N
LOGGER.trace("Lock: lock acquired (beginNodeTrx)");

// Create new page write transaction (shares the same ID with the node write trx).
final long nodeTrxId = nodeTrxIDCounter.incrementAndGet();
final int nodeTrxId = nodeTrxIDCounter.incrementAndGet();
final int lastRev = getMostRecentRevisionNumber();
final PageTrx pageWtx = createPageTransaction(nodeTrxId, lastRev, lastRev, Abort.NO, true);

Expand Down Expand Up @@ -552,7 +552,7 @@ public boolean hasRunningNodeWriteTrx() {
* @param pageTrx page write trx
*/
@Override
public void setNodePageWriteTransaction(final @NonNegative long transactionID, @NonNull final PageTrx pageTrx) {
public void setNodePageWriteTransaction(final @NonNegative int transactionID, @NonNull final PageTrx pageTrx) {
assertNotClosed();
nodePageTrxMap.put(transactionID, pageTrx);
}
Expand All @@ -564,7 +564,7 @@ public void setNodePageWriteTransaction(final @NonNegative long transactionID, @
* @throws SirixIOException if an I/O error occurs
*/
@Override
public void closeNodePageWriteTransaction(final @NonNegative long transactionID) {
public void closeNodePageWriteTransaction(final @NonNegative int transactionID) {
assertNotClosed();
final PageReadOnlyTrx pageRtx = nodePageTrxMap.remove(transactionID);
if (pageRtx != null) {
Expand All @@ -578,7 +578,7 @@ public void closeNodePageWriteTransaction(final @NonNegative long transactionID)
* @param transactionID write transaction ID
*/
@Override
public void closeWriteTransaction(final @NonNegative long transactionID) {
public void closeWriteTransaction(final @NonNegative int transactionID) {
assertNotClosed();

// Remove from internal map.
Expand All @@ -595,7 +595,7 @@ public void closeWriteTransaction(final @NonNegative long transactionID) {
* @param transactionID read transaction ID
*/
@Override
public void closeReadTransaction(final @NonNegative long transactionID) {
public void closeReadTransaction(final @NonNegative int transactionID) {
assertNotClosed();

// Remove from internal map.
Expand All @@ -608,7 +608,7 @@ public void closeReadTransaction(final @NonNegative long transactionID) {
* @param transactionID write transaction ID
*/
@Override
public void closePageWriteTransaction(final @NonNegative Long transactionID) {
public void closePageWriteTransaction(final @NonNegative Integer transactionID) {
assertNotClosed();

// Remove from internal map.
Expand All @@ -625,7 +625,7 @@ public void closePageWriteTransaction(final @NonNegative Long transactionID) {
* @param transactionID read transaction ID
*/
@Override
public void closePageReadTransaction(final @NonNegative Long transactionID) {
public void closePageReadTransaction(final @NonNegative Integer transactionID) {
assertNotClosed();

// Remove from internal map.
Expand All @@ -637,7 +637,7 @@ public void closePageReadTransaction(final @NonNegative Long transactionID) {
*
* @param transactionID transaction ID to remove
*/
private void removeFromPageMapping(final @NonNegative Long transactionID) {
private void removeFromPageMapping(final @NonNegative Integer transactionID) {
assertNotClosed();

// Purge transaction from internal state.
Expand Down Expand Up @@ -720,7 +720,7 @@ public synchronized PathSummaryReader openPathSummary(final @NonNegative int rev
public PageReadOnlyTrx beginPageReadOnlyTrx(final @NonNegative int revision) {
assertAccess(revision);

final long currentPageTrxID = pageTrxIDCounter.incrementAndGet();
final int currentPageTrxID = pageTrxIDCounter.incrementAndGet();
final NodePageReadOnlyTrx pageReadTrx = new NodePageReadOnlyTrx(currentPageTrxID,
this,
lastCommittedUberPage.get(),
Expand Down Expand Up @@ -752,7 +752,7 @@ public synchronized PageTrx beginPageTrx(final @NonNegative int revision) {

LOGGER.debug("Lock: lock acquired (beginPageTrx)");

final long currentPageTrxID = pageTrxIDCounter.incrementAndGet();
final int currentPageTrxID = pageTrxIDCounter.incrementAndGet();
final int lastRev = getMostRecentRevisionNumber();
final PageTrx pageTrx = createPageTransaction(currentPageTrxID, lastRev, lastRev, Abort.NO, false);

Expand All @@ -765,7 +765,7 @@ public synchronized PageTrx beginPageTrx(final @NonNegative int revision) {
}

@Override
public Optional<R> getNodeReadTrxByTrxId(final Long ID) {
public Optional<R> getNodeReadTrxByTrxId(final Integer ID) {
assertNotClosed();

return Optional.ofNullable(nodeTrxMap.get(ID));
Expand Down
Loading
Loading