configmgr/source/components.cxx |    6 ++++++
 configmgr/source/node.cxx       |   13 ++++++++++++-
 configmgr/source/node.hxx       |    4 ++++
 3 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 0e05a04a9ba320f994f18d92359a7374f12ac748
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Sat Oct 19 16:57:44 2024 +0100
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Oct 21 09:48:00 2024 +0200

    lok: encourage more sharing of config Node pages.
    
    Profiles show lots of probe:do_wp_page events from things like
    configmgr::Access::getUnmodifiedChild - as when we read we touch
    lots of Node reference counts - un-necessarily.
    
    So - reduce un-necessary reference counting thrash here in the
    lok case through the environment variable. Quite possibly this
    would also be safe and beneficial for the desktop app - needs
    measurement.
    
    measuring with coolmap and an empty hello-world.odt before & after:
    before:
            unshared  3634 (14536kB)
            unshared  3631 (14524kB)
            unshared  3605 (14420kB)
    
    after:
            unshared  3578 (14312kB)
            unshared  3613 (14452kB)
            unshared  3599 (14396kB)
    
    Not hugely encouraging, perhaps there is another page touch
    underneath we'll find when this is addressed.
    
    Change-Id: I8ac74c5fcd17f8699139e914a7076a7848456e2a
    Signed-off-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175197
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx
index 3c35a258c12c..af7ac1e4ae39 100644
--- a/configmgr/source/components.cxx
+++ b/configmgr/source/components.cxx
@@ -466,6 +466,10 @@ Components::Components(
 {
     assert(context.is());
     lock_ = lock();
+
+    bool staticize = !!getenv("SAL_CONFIG_STATICIZE");
+    Node::setStaticizedFlag(staticize);
+
     OUString conf(expand("${CONFIGURATION_LAYERS}"));
     int layer = 0;
     for (sal_Int32 i = 0;;) {
@@ -603,6 +607,8 @@ Components::Components(
         }
         i = n;
     }
+
+    Node::setStaticizedFlag(false);
 }
 
 Components::~Components()
diff --git a/configmgr/source/node.cxx b/configmgr/source/node.cxx
index 2c8c697b5338..c9e356c7b913 100644
--- a/configmgr/source/node.cxx
+++ b/configmgr/source/node.cxx
@@ -65,7 +65,18 @@ rtl::Reference< Node > Node::getMember(OUString const & 
name) {
     return i == members.end() ? rtl::Reference< Node >() : i->second;
 }
 
-Node::Node(int layer): layer_(layer), finalized_(Data::NO_LAYER) {}
+bool Node::CreateStaticizedNodes = false;
+
+void Node::setStaticizedFlag(bool staticized)
+{
+    CreateStaticizedNodes = staticized;
+}
+
+Node::Node(int layer): layer_(layer), finalized_(Data::NO_LAYER)
+{
+    if (CreateStaticizedNodes)
+        staticize();
+}
 
 Node::Node(const Node & other):
     SimpleReferenceObject(), layer_(other.layer_), finalized_(other.finalized_)
diff --git a/configmgr/source/node.hxx b/configmgr/source/node.hxx
index cce8e3d4abb3..184d00dc1b48 100644
--- a/configmgr/source/node.hxx
+++ b/configmgr/source/node.hxx
@@ -50,6 +50,9 @@ public:
     void setLayer(int layer);
     int getLayer() const { return layer_;}
 
+    /// when @staticized is set all new nodes will not ref-count
+    static void setStaticizedFlag(bool staticized);
+
     void setFinalized(int layer);
     int getFinalized() const { return finalized_;}
 
@@ -67,6 +70,7 @@ private:
     int layer_;
     int finalized_;
     OUString description_;
+    static bool CreateStaticizedNodes;
 };
 
 }

Reply via email to