Commit f25b00f1 authored by AnttiVillberg's avatar AnttiVillberg
Browse files

Stash

parent fd6297e1
......@@ -165,7 +165,7 @@ public class AsyncBarrierImpl extends AtomicInteger implements AsyncBarrier {
public void waitBarrier(Object request, ReadGraphImpl impl) {
if(caller == WAITED)
throw new IllegalStateException("Waiting twice on a same barrier.");
throw new IllegalStateException("Waiting twice on a same barrier: " + request);
if(isDone()) {
caller = WAITED;
......
......@@ -1377,8 +1377,7 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
if (ListenerEntry.NO_VALUE == oldValue) {
if (Development.DEVELOPMENT) {
if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, Bindings.BOOLEAN)) {
System.out.println("C " + query);
System.out.println("- " + oldValue);
System.out.println("C1 " + query);
System.out.println("- " + newValue);
}
}
......@@ -1396,11 +1395,13 @@ final public class QueryProcessor extends AbstractDisposable implements ReadGrap
} else
changed = (oldValue != null);
if (Development.DEVELOPMENT) {
if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, Bindings.BOOLEAN)) {
System.err.println("C " + query);
System.err.println("- " + oldValue);
System.err.println("- " + newValue);
if(changed) {
  • This could be inside if (Development.DEVELOPMENT) { as well althought I think JIT will simply discard the whole code as NOP anyway.

Please register or sign in to reply
if (Development.DEVELOPMENT) {
if(Development.<Boolean>getProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, Bindings.BOOLEAN)) {
System.err.println("C2 " + query);
System.err.println("- " + oldValue);
System.err.println("- " + newValue);
}
}
}
......
......@@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
......@@ -1545,6 +1546,28 @@ public class Layer0Utils {
}
public static Collection<Resource> domainClusterResources(ReadGraph graph, Resource r) throws DatabaseException {
Map<Long,Resource> result = new HashMap<>();
ClusteringSupport cs = graph.getService(ClusteringSupport.class);
for(Resource dr : domainResources(graph, r)) {
long c = cs.getCluster(dr);
if(!result.containsKey(c)) {
result.put(c, dr);
}
}
return result.values();
}
public static void domainSetImmutability(WriteGraph graph, Resource r, boolean value) throws DatabaseException {
XSupport xs = graph.getService(XSupport.class);
for(Resource dr : domainClusterResources(graph, r)) {
xs.setImmutable(dr, value);
}
}
private static Resource browse(ReadGraph graph, Resource r, String path) throws DatabaseException {
int beginIndex = 0;
int endIndex = path.indexOf(URIStringUtils.NAMESPACE_PATH_SEPARATOR, beginIndex);
......
......@@ -699,6 +699,13 @@ final public class Variables {
NodeStructure r = (NodeStructure)object;
return r.children.equals(children) && r.properties.equals(properties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(children.toString());
sb.append(properties.toString());
return sb.toString();
}
}
public static NodeStructure requestNodeStructure(ReadGraph graph, VariableNode<?> node) throws DatabaseException {
......
......@@ -3524,7 +3524,7 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
public int getAmountOfQueryThreads() {
// This must be a power of two
return 1;
return 4;
Please register or sign in to reply
// return Integer.highestOneBit(Runtime.getRuntime().availableProcessors());
}
......
......@@ -34,6 +34,8 @@ import org.simantics.db.Session;
import org.simantics.db.adaption.Adapter;
import org.simantics.db.adaption.AdapterInstaller;
import org.simantics.db.adaption.AdaptionService;
import org.simantics.db.common.primitiverequest.PossibleResource;
import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.request.Read;
import org.simantics.db.services.adaption.reflection.AdaptingDynamicAdapter2;
......@@ -173,7 +175,7 @@ public class AdapterRegistry2 {
List<IDynamicAdapter2> parameters = readParameters(g, node, b);
IDynamicAdapter2[] parameterArray =
parameters.toArray(new IDynamicAdapter2[parameters.size()]);
Resource r = g.getResource(uri);
Resource r = g.syncRequest(new PossibleResource(uri), TransientCacheAsyncListener.instance());
service.addInstanceAdapter(
r,
interface_,
......
......@@ -75,9 +75,9 @@ public class DevelopmentKeys {
Development.setProperty(DevelopmentKeys.WRITELOGGER_LOG, EVERYTHING | false, Bindings.BOOLEAN);
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_PERFORM_REQUEST, EVERYTHING | false, Bindings.BOOLEAN);
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_PERFORM_REQUEST, EVERYTHING | true, Bindings.BOOLEAN);
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_PERFORM_QUERY, EVERYTHING | false, Bindings.BOOLEAN);
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_PERFORM_QUERY, EVERYTHING | true, Bindings.BOOLEAN);
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_RECOMPUTE, EVERYTHING | false, Bindings.BOOLEAN);
......@@ -85,7 +85,7 @@ public class DevelopmentKeys {
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_CHANGES, EVERYTHING | false, Bindings.BOOLEAN);
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, EVERYTHING | false, Bindings.BOOLEAN);
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_UPDATE, EVERYTHING | true, Bindings.BOOLEAN);
Development.setProperty(DevelopmentKeys.QUERYPROCESSOR_DEPENDENCIES, EVERYTHING | false, Bindings.BOOLEAN);
......
......@@ -75,6 +75,7 @@ COMPONENTS.ParentlessComponent <T COMPONENTS.PrimitiveComponent /* Component wit
COMPONENTS.Composite <T STR.Composite <T COMPONENTS.Component
COMPONENTS.DummyContainer <T COMPONENTS.Component /* Dummy single component container which is not instantiated */
@connectionPoint RELATIONS.parent
@attribute PROPERTIES.exists true
@attribute PROPERTIES.pathExists FUNCTIONS.pathExists
......
......@@ -216,7 +216,7 @@ Documentation.Document <T Documentation.Components.Composite
L0.HasPredicate Documentation.Properties.experiment
L0.HasObject FUNCTIONS.experiment
Documentation.DocumentComponentType <T STR.ComponentType
Documentation.DocumentComponentType <T STR.DefinedComponentType
Please register or sign in to reply
Documentation.DocumentProceduralComponentType <T STR.ProceduralComponentType <T Documentation.DocumentComponentType
......
......@@ -129,7 +129,8 @@ public class DocumentServerUtils {
if(descs.size() != 2) return null;
for(VariableConnectionPointDescriptor desc : descs) {
if(desc.isFlattenedFrom(graph, connectionPoint)) continue;
if(desc.isFlattenedFrom(graph, connectionPoint))
continue;
return desc.getVariable(graph);
}
......@@ -155,6 +156,24 @@ public class DocumentServerUtils {
}
public static Variable getPossibleChildConnectionPoint2(ReadGraph graph, Variable connectionPointParent, Connection conn) throws DatabaseException {
Collection<VariableConnectionPointDescriptor> descs = conn.getConnection2().getConnectionPointDescriptors(graph, connectionPointParent, null);
if(descs.size() != 2) return null;
DocumentationResource DOC = DocumentationResource.getInstance(graph);
for(VariableConnectionPointDescriptor desc : descs) {
Resource res = desc.getConnectionPointResource(graph);
if(graph.isInstanceOf(res, DOC.Relations_parentRelation)) continue;
//if(desc.isFlattenedFrom(graph, connectionPoint)) continue;
return desc.getVariable(graph);
}
return null;
}
public static Collection<Variable> getOtherConnectionPoints(ReadGraph graph, Variable connectionPoint, Connection conn) throws DatabaseException {
ArrayList<Variable> connectionPoints = new ArrayList<Variable>();
......
......@@ -29,6 +29,7 @@ import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
import org.simantics.db.common.procedure.adapter.TransientCacheListener;
import org.simantics.db.common.request.BinaryRead;
import org.simantics.db.common.request.ResourceAsyncRead;
import org.simantics.db.common.request.ResourceRead;
import org.simantics.db.common.request.UniqueRead;
import org.simantics.db.common.request.WriteResultRequest;
import org.simantics.db.common.utils.Logger;
......@@ -43,6 +44,7 @@ import org.simantics.db.layer0.request.VariableProperty;
import org.simantics.db.layer0.request.VariableRead;
import org.simantics.db.layer0.request.VariableValueWithBinding;
import org.simantics.db.layer0.scl.SCLDatabaseException;
import org.simantics.db.layer0.util.Layer0Utils;
import org.simantics.db.layer0.variable.ConstantPropertyVariable;
import org.simantics.db.layer0.variable.ProxyChildVariable;
import org.simantics.db.layer0.variable.ProxySessionRequest;
......@@ -75,6 +77,7 @@ import org.simantics.document.server.serverResponse.SuccessResponse;
import org.simantics.document.server.state.StateNodeManager;
import org.simantics.document.server.state.StateRealm;
import org.simantics.document.server.state.StateSessionManager;
import org.simantics.layer0.Layer0;
import org.simantics.modeling.ModelingResources;
import org.simantics.modeling.services.CaseInsensitiveComponentFunctionNamingStrategy;
import org.simantics.modeling.services.ComponentNamingStrategy;
......@@ -1308,7 +1311,31 @@ public class Functions {
}
}
}
public static class ParentRelationsRequest extends ResourceRead<Collection<String>> {
protected ParentRelationsRequest(Resource widgetType) {
super(widgetType);
}
@Override
public Collection<String> perform(ReadGraph graph) throws DatabaseException {
Layer0 L0 = Layer0.getInstance(graph);
DocumentationResource DOC = DocumentationResource.getInstance(graph);
ArrayList<String> ret = new ArrayList<>();
Map<String,Resource> domainOf = Layer0Utils.getDomainOf(graph, resource);
for(Resource cp : domainOf.values()) {
if(graph.isInstanceOf(cp, DOC.Relations_parentRelation)) {
String name = graph.getPossibleRelatedValue(cp, L0.HasName, Bindings.STRING);
if(name != null)
ret.add(name);
}
}
return ret;
}
}
public static class PathExistsRequest extends VariableRead<Boolean> {
......@@ -1326,12 +1353,19 @@ public class Functions {
if (!graph.syncRequest(new ParentExistsRequest(widget.getParent(graph)))) return false;
DocumentationResource DOC = DocumentationResource.getInstance(graph);
Collection <Variable> cps = widget.getProperties(graph, DocumentationResource.URIs.Relations_parentRelation);
for (Variable cp : cps) {
Connection conn = cp.getValue(graph);
Variable otherCp = DocumentServerUtils.getPossibleChildConnectionPoint(graph, cp, conn);
Resource type = widget.getType(graph);
Collection<String> pars = graph.syncRequest(new ParentRelationsRequest(type));
// Collection <Variable> cps = widget.getProperties(graph, DocumentationResource.URIs.Relations_parentRelation);
int nCps = 0;
for(String par : pars) {
Connection conn = widget.getPossiblePropertyValue(graph, par);
if(conn == null)
continue;
nCps++;
//Connection conn = cp.getValue(graph);
Variable otherCp = DocumentServerUtils.getPossibleChildConnectionPoint2(graph, widget, conn);
if (otherCp != null) {
Variable parentWidget = otherCp.getParent(graph);
if (parentWidget.<Boolean>getPropertyValue(graph, "pathExists")) {
......@@ -1361,9 +1395,12 @@ public class Functions {
}
}
Resource type = widget.getType(graph);
// if(nCps != cps.size())
// System.err.println("booaa " + widget.getURI(graph));
DocumentationResource DOC = DocumentationResource.getInstance(graph);
return graph.isInheritedFrom(type, DOC.Components_ParentlessComponent) ||
(graph.isInheritedFrom(type, DOC.DocumentComponent) && cps.isEmpty());
(graph.isInheritedFrom(type, DOC.DocumentComponent) && nCps == 0);
}
}
......
......@@ -17,12 +17,13 @@ import org.simantics.db.layer0.request.VariableRead;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.db.procedure.AsyncProcedure;
import org.simantics.document.server.JSONObject;
import org.simantics.document.server.DocumentServerUtils.AttributesRequest;
public class DocumentRequest extends VariableRead<List<JSONObject>> {
public static boolean PROFILE = false;
public static boolean PROFILE = true;
// Thresholds in microseconds
public static int PROFILE_THRESHOLD_NODEREQUEST = 2000;
public static int PROFILE_THRESHOLD_NODEREQUEST = 10000;
public static int PROFILE_THRESHOLD_VALUEREQUEST = 500;
public DocumentRequest(Variable var) {
......@@ -40,7 +41,7 @@ public class DocumentRequest extends VariableRead<List<JSONObject>> {
HashSet<JSONObject> rs = new HashSet<JSONObject>(); // result
for(Variable node : parameter) {
graph.asyncRequest(new NodeRequest(node), new AsyncProcedure<JSONObject> () {
graph.asyncRequest(new AttributesRequest(node), new AsyncProcedure<JSONObject> () {
@Override
public void execute(AsyncReadGraph graph, JSONObject result) {
......
......@@ -27,6 +27,8 @@ public class URIDocumentRequest extends UnaryRead<String, List<JSONObject>> {
@Override
public List<JSONObject> perform(ReadGraph graph) throws DatabaseException {
graph.setSynchronous(true);
Please register or sign in to reply
Variable var = Variables.getPossibleVariable(graph, parameter);
if(var == null) {
......
......@@ -31,6 +31,7 @@ import org.simantics.db.ServerI;
import org.simantics.db.ServiceLocator;
import org.simantics.db.Session;
import org.simantics.db.WriteOnlyGraph;
import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.common.request.WriteOnlyRequest;
import org.simantics.db.exception.DatabaseException;
......@@ -110,7 +111,7 @@ public class ServerManager {
Layer0.getInstance(g);
}
};
session.syncRequest(req);
session.syncRequest(req, TransientCacheAsyncListener.instance());
Please register or sign in to reply
return new SessionDescriptor(session, false);
}
CoreInitialization.initializeBuiltins(session);
......
import "UI/Progress"
import "Simantics/DB"
importJava "org.simantics.db.service.ClusterUID" where
data ClusterUID
importJava "org.simantics.db.common.utils.CommonDBUtils" where
listClusters :: <ReadGraph> [ClusterUID]
......@@ -25,9 +28,19 @@ importJava "org.simantics.scl.db.SCLFunctions" where
importJava "org.simantics.db.layer0.util.Layer0Utils" where
@JavaName emptyTrashBin
emptyTrashBinWithMonitor :: ProgressMonitor -> <Proc> ()
domainClusterResources :: Resource -> <ReadGraph> [Resource]
domainSetImmutability :: Resource -> Boolean -> <WriteGraph> ()
//emptyTrashBin :: <Proc> ()
emptyTrashBin = emptyTrashBinWithMonitor $ createNullProgressMonitor ()
importJava "org.simantics.db.service.ClusterUID" where
data ClusterUID
foo :: Resource -> <ReadGraph,Proc> ()
Please register or sign in to reply
foo r = do
drs = domainClusterResources r
crs = map clusterUIDOfResource drs
print (map toDynamic crs)
rs = concatMap resourcesByCluster crs
print rs
for rs \r -> print (possibleUriOf r)
()
\ No newline at end of file
......@@ -32,7 +32,7 @@ import org.simantics.structural2.variables.ConnectionBrowser.IsLeafType;
* are not final and are replaced by correct descriptors during drill phase.
*
*/
class ActualConnectionDescriptor extends AbstractVariableConnectionPointDescriptor {
public class ActualConnectionDescriptor extends AbstractVariableConnectionPointDescriptor {
/*
* This is the nearest known ancestor variable
......
......@@ -9,7 +9,9 @@ import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.CopyOnWriteArrayList;
......@@ -26,7 +28,7 @@ public class Development {
private static final Logger LOGGER = LoggerFactory.getLogger(Development.class);
public static TreeMap<String,Integer> histogram = new TreeMap<>();
public static final boolean DEVELOPMENT = false;
public static final boolean DEVELOPMENT = true;
public static final String PRINT = "Development.print";
......@@ -57,6 +59,8 @@ public class Development {
new Exception("Development breakLine breakpoint was hit.").printStackTrace();
}
private static Map<String,Integer> logHistogram = new HashMap<>();
public static void log(String line) {
if (DEVELOPMENT) {
try {
......@@ -64,6 +68,13 @@ public class Development {
breakOnLine();
if(line.length() > 500) line = line.substring(0, 500);
log.write((line+'\n').getBytes());
Integer count = logHistogram.get(line);
if(count == null) {
count = 0;
}
logHistogram.put(line, count+1);
if(count > 600)
System.err.println("REPEATING QUERY (" + count + "): " + line);
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -60,6 +60,7 @@ import org.simantics.db.SessionModel;
import org.simantics.db.UndoContext;
import org.simantics.db.VirtualGraph;
import org.simantics.db.WriteGraph;
import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
import org.simantics.db.common.processor.MergingDelayedWriteProcessor;
import org.simantics.db.common.processor.MergingGraphRequestProcessor;
import org.simantics.db.common.request.ObjectsWithType;
......@@ -650,7 +651,7 @@ public class SimanticsPlatform implements LifecycleListener {
}
});
}, TransientCacheAsyncListener.instance());
  • This exists because otherwise Layer0X.getInstance(graph) will use getResource(uri) without caching which does tons of unnecessary work.

Please register or sign in to reply
if(sessionModel == null) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment