From cd321f9b14f1686244ad5112a57da339cdf49ce1 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Wed, 21 Jan 2026 18:08:59 +1100 Subject: [PATCH 1/6] Remove mutex in RavelWrap in favor of thread safety in RavelCAPI. For #1900. --- RavelCAPI | 2 +- model/ravelWrap.cc | 45 ++------------------------------------------- model/ravelWrap.h | 2 -- 3 files changed, 3 insertions(+), 46 deletions(-) diff --git a/RavelCAPI b/RavelCAPI index 8282d1b91..b6974785f 160000 --- a/RavelCAPI +++ b/RavelCAPI @@ -1 +1 @@ -Subproject commit 8282d1b91ec193f3b0e4d6102eaa9873814d3994 +Subproject commit b6974785f1e168028805e15527d3843f07b84fbf diff --git a/model/ravelWrap.cc b/model/ravelWrap.cc index dd58b6914..54e1fbb60 100644 --- a/model/ravelWrap.cc +++ b/model/ravelWrap.cc @@ -130,7 +130,6 @@ namespace minsky { cairo_scale(cairo,z,z); CairoRenderer cr(cairo); - shared_lock lock(updateMutex); wrappedRavel.render(cr); } else @@ -144,7 +143,6 @@ namespace minsky void Ravel::resize(const LassoBox& b) { - lock_guard lock(updateMutex); wrappedRavel.rescale(0.5*std::max(fabs(b.x0-b.x1),fabs(b.y0-b.y1))/(1.21*zoomFactor())); moveTo(0.5*(b.x0+b.x1), 0.5*(b.y0+b.y1)); bb.update(*this); @@ -154,7 +152,6 @@ namespace minsky { if (m_editorMode) { - shared_lock lock(updateMutex); const float r=1.1*zoomFactor()*wrappedRavel.radius(); return std::abs(xx-x())<=r && std::abs(yy-y())<=r; } @@ -164,17 +161,13 @@ namespace minsky void Ravel::onMouseDown(float xx, float yy) { const double invZ=1/zoomFactor(); - lock_guard lock(updateMutex); wrappedRavel.onMouseDown((xx-x())*invZ,(yy-y())*invZ); } bool Ravel::onMouseUp(float xx, float yy) { const double invZ=1/zoomFactor(); - { - lock_guard lock(updateMutex); - wrappedRavel.onMouseUp((xx-x())*invZ,(yy-y())*invZ); - } + wrappedRavel.onMouseUp((xx-x())*invZ,(yy-y())*invZ); resortHandleIfDynamic(); broadcastStateToLockGroup(); return m_ports[1]->numWires(); // only reset if input port connected. Don't if sourced from database @@ -182,20 +175,17 @@ namespace minsky bool Ravel::onMouseMotion(float xx, float yy) { const double invZ=1/zoomFactor(); - shared_lock lock(updateMutex); return wrappedRavel.onMouseMotion((xx-x())*invZ,(yy-y())*invZ); } bool Ravel::onMouseOver(float xx, float yy) { const double invZ=1/zoomFactor(); - shared_lock lock(updateMutex); return wrappedRavel.onMouseOver((xx-x())*invZ,(yy-y())*invZ); } Hypercube Ravel::hypercube() const { - shared_lock lock(updateMutex); auto outHandles=wrappedRavel.outputHandleIds(); Hypercube hc; auto& xv=hc.xvectors; @@ -219,7 +209,6 @@ namespace minsky void Ravel::populateHypercube(const Hypercube& hc) { if (!wrappedRavel) return; - lock_guard lock(updateMutex); auto state=initState.empty()? getState(): initState; const bool redistribute=!initState.empty(); initState.clear(); @@ -250,13 +239,11 @@ namespace minsky { vector ids; for (size_t i=0; iwires().empty()) { minsky().flags&=~Minsky::reset_needed; //disable resetting until user gets a chance to manipulate ravel - lock_guard lock(updateMutex); db.fullHypercube(wrappedRavel); } } @@ -315,7 +301,6 @@ namespace minsky if (buf.cmp(lastState)!=0) { lastState.swap(buf); - shared_lock lock(updateMutex); cachedDbResult=db.hyperSlice(wrappedRavel); } return {cachedDbResult}; @@ -323,7 +308,6 @@ namespace minsky bool Ravel::displayFilterCaliper() const { - shared_lock lock(updateMutex); const int h=wrappedRavel.selectedHandle(); if (h>=0) { @@ -335,7 +319,6 @@ namespace minsky bool Ravel::setDisplayFilterCaliper(bool x) { - lock_guard lock(updateMutex); const int h=wrappedRavel.selectedHandle(); if (h>=0) wrappedRavel.displayFilterCaliper(h,x); @@ -344,31 +327,26 @@ namespace minsky vector Ravel::allSliceLabels() const { - shared_lock lock(updateMutex); return wrappedRavel.allSliceLabels(wrappedRavel.selectedHandle(),ravel::HandleSort::forward); } vector Ravel::allSliceLabelsAxis(int axis) const { - shared_lock lock(updateMutex); return wrappedRavel.allSliceLabels(axis,ravel::HandleSort::forward); } vector Ravel::pickedSliceLabels(int axis) const { - shared_lock lock(updateMutex); return wrappedRavel.sliceLabels(axis); } vector Ravel::pickedSliceLabels() const { - shared_lock lock(updateMutex); return pickedSliceLabels(wrappedRavel.selectedHandle()); } void Ravel::pickSliceLabels(int axis, const vector& pick) { - lock_guard lock(updateMutex); if (axis>=0 && axis customOrder, currentOrder=wrappedRavel.currentPermutation(axis); @@ -400,7 +378,6 @@ namespace minsky Dimension Ravel::dimension(int handle) const { - shared_lock lock(updateMutex); Dimension dim; auto dimitr=cminsky().dimensions.find(handleDescription(handle)); if (dimitr!=cminsky().dimensions.end()) @@ -410,7 +387,6 @@ namespace minsky ravel::HandleSort::Order Ravel::sortOrder() const { - shared_lock lock(updateMutex); const int h=wrappedRavel.selectedHandle(); if (h>=0) { @@ -422,14 +398,12 @@ namespace minsky ravel::HandleSort::Order Ravel::setSortOrder(ravel::HandleSort::Order x) { - lock_guard lock(updateMutex); setHandleSortOrder(x, wrappedRavel.selectedHandle()); return x; } void Ravel::resortHandleIfDynamic() { - lock_guard lock(updateMutex); if (wrappedRavel.rank()==1) { const int outputHandleId=wrappedRavel.outputHandleIds()[0]; @@ -457,7 +431,6 @@ namespace minsky { if (handle>=0) { - lock_guard lock(updateMutex); const Dimension dim=dimension(handle); wrappedRavel.orderLabels(handle,order); } @@ -466,7 +439,6 @@ namespace minsky bool Ravel::handleSortableByValue() const { - shared_lock lock(updateMutex); if (wrappedRavel.rank()!=1) return false; auto ids=wrappedRavel.outputHandleIds(); return size_t(wrappedRavel.selectedHandle())==ids[0]; @@ -474,7 +446,6 @@ namespace minsky void Ravel::sortByValue(ravel::HandleSort::Order dir) { - lock_guard lock(updateMutex); if (wrappedRavel.rank()!=1) return; try {minsky().requestReset();} catch (...) {throw runtime_error("Cannot sort handle at the moment");} auto vv=m_ports[1]->getVariableValue(); @@ -486,25 +457,21 @@ namespace minsky string Ravel::description() const { - shared_lock lock(updateMutex); return handleDescription(wrappedRavel.selectedHandle()); } void Ravel::setDescription(const string& description) { - lock_guard lock(updateMutex); wrappedRavel.setHandleDescription(wrappedRavel.selectedHandle(),description); } Dimension::Type Ravel::dimensionType() const { - shared_lock lock(updateMutex); return dimensionType(selectedHandle()); } Dimension::Type Ravel::dimensionType(int handleIndex) const { - shared_lock lock(updateMutex); auto descr=handleDescription(handleIndex); if (auto i=axisDimensions.find(descr); i!=axisDimensions.end()) @@ -518,13 +485,11 @@ namespace minsky std::string Ravel::dimensionUnitsFormat() const { - shared_lock lock(updateMutex); return dimensionUnitsFormat(selectedHandle()); } std::string Ravel::dimensionUnitsFormat(int handleIndex) const { - shared_lock lock(updateMutex); auto descr=handleDescription(handleIndex); if (descr.empty()) return ""; auto i=axisDimensions.find(descr); @@ -539,14 +504,12 @@ namespace minsky /// @throw if type does not match global dimension type void Ravel::setDimension(Dimension::Type type,const std::string& units) { - lock_guard lock(updateMutex); return setDimension(selectedHandle(), type, units); } /// @throw if type does not match global dimension type void Ravel::setDimension(int handleIndex, Dimension::Type type,const std::string& units) { - lock_guard lock(updateMutex); auto descr=handleDescription(handleIndex); if (descr.empty()) return; auto i=cminsky().dimensions.find(descr); @@ -575,7 +538,6 @@ namespace minsky } // if no variable value attached, create one - lock_guard lock(updateMutex); VariableValue v(VariableType::flow); v.hypercube(hypercube()); const TensorsFromPort tp(make_shared()); tp.ev->update(ValueVector::flowVars.data(), ValueVector::flowVars.size(), ValueVector::stockVars.data()); @@ -593,8 +555,7 @@ namespace minsky // reduced by product handles for (size_t h=0; h Date: Wed, 21 Jan 2026 18:14:21 +1100 Subject: [PATCH 2/6] Update EcoLab ref. --- ecolab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecolab b/ecolab index 4feaa4d74..696284281 160000 --- a/ecolab +++ b/ecolab @@ -1 +1 @@ -Subproject commit 4feaa4d74b66b858bc6c8fe4639b1a363fb7c10a +Subproject commit 69628428104f0ff14ab39fbfb84b5f9e7acd060d From 0149a7f6555207f5e5ddfb16289031d63d4c2285 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Wed, 21 Jan 2026 18:21:25 +1100 Subject: [PATCH 3/6] Indentation and whitespace fixes. --- test/testTensorOps.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testTensorOps.cc b/test/testTensorOps.cc index 758eb6da0..7781b0356 100644 --- a/test/testTensorOps.cc +++ b/test/testTensorOps.cc @@ -1205,7 +1205,7 @@ TEST_F(TensorValFixture, reduction2dswapped) expected={0,54,180,4,70,208,10,88,238}; index=chain.back()->index(); sortedIdx=vector(index.begin(),index.end()); sort(sortedIdx.begin(),sortedIdx.end()); - for (size_t _i=0; _i<9; ++_i) EXPECT_EQ(expected[_i], chain.back()->atHCIndex(sortedIdx[_i])); + for (size_t _i=0; _i<9; ++_i) EXPECT_EQ(expected[_i], chain.back()->atHCIndex(sortedIdx[_i])); sex->reductionOp=ravel::Op::av; chain=createRavelChain(state, arg); @@ -1282,7 +1282,7 @@ TEST_F(TensorValFixture, sparseSlicedRavel) expectedf={0,3,1,4,2}; index=chain.back()->index(); sortedIdx=vector(index.begin(),index.end()); sort(sortedIdx.begin(),sortedIdx.end()); - for (size_t _i=0; _i<5; ++_i) EXPECT_EQ(expectedf[_i], chain.back()->atHCIndex(sortedIdx[_i])); + for (size_t _i=0; _i<5; ++_i) EXPECT_EQ(expectedf[_i], chain.back()->atHCIndex(sortedIdx[_i])); } TEST_F(TensorValFixture, calipered) From 6f36ef4a977610a4cc0fb4c96d6c27d2de4b9f64 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Wed, 21 Jan 2026 18:43:50 +1100 Subject: [PATCH 4/6] Remove shared_mutex header include --- model/ravelWrap.h | 1 - 1 file changed, 1 deletion(-) diff --git a/model/ravelWrap.h b/model/ravelWrap.h index 6d1dac94a..30fbc315e 100644 --- a/model/ravelWrap.h +++ b/model/ravelWrap.h @@ -27,7 +27,6 @@ #include "handleLockInfo.h" #include "renderNativeWindow.h" #include "SVGItem.h" -#include namespace minsky { From dd41404b8c86e0ea3a31d66babbe407849f13217 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Wed, 21 Jan 2026 19:47:30 +1100 Subject: [PATCH 5/6] Add /usr/local/lib to LD_LIBRARY_PATH --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8431926ba..afcd3c5e8 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ TK_LIB=$(dir $(shell find $(TCL_PREFIX) -name tk.tcl -path "*/tk$(TCL_VERSION)*" # root directory for ecolab include files and libraries ECOLAB_HOME=$(shell pwd)/ecolab -export LD_LIBRARY_PATH:=$(ECOLAB_HOME)/lib:$(LD_LIBRARY_PATH) +export LD_LIBRARY_PATH:=$(ECOLAB_HOME)/lib:$(LD_LIBRARY_PATH):/usr/local/lib ARCH=$(shell arch) HAVE_CLANG=$(shell if which clang++>/dev/null; then echo 1; fi) From 7b444f2dc7518dcf7e6c5788291af5076822209e Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Wed, 21 Jan 2026 20:49:25 +1100 Subject: [PATCH 6/6] Needs to be /usr/local/lib64 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index afcd3c5e8..20fe09388 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ TK_LIB=$(dir $(shell find $(TCL_PREFIX) -name tk.tcl -path "*/tk$(TCL_VERSION)*" # root directory for ecolab include files and libraries ECOLAB_HOME=$(shell pwd)/ecolab -export LD_LIBRARY_PATH:=$(ECOLAB_HOME)/lib:$(LD_LIBRARY_PATH):/usr/local/lib +export LD_LIBRARY_PATH:=$(ECOLAB_HOME)/lib:$(LD_LIBRARY_PATH):/usr/local/lib64 ARCH=$(shell arch) HAVE_CLANG=$(shell if which clang++>/dev/null; then echo 1; fi)