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

Speed up book close #1941

Merged
merged 2 commits into from
May 20, 2024

Conversation

christopherlam
Copy link
Contributor

@christopherlam christopherlam commented May 19, 2024

speeds up my book destruction routines from 0.9s to 0.6s

here's benchmarking patch:

modified   libgnucash/engine/qofsession.cpp
@@ -127,6 +127,8 @@ QofSessionImpl::QofSessionImpl (QofBook* book) noexcept
 
 QofSessionImpl::~QofSessionImpl () noexcept
 {
+    float startTime = (float)clock()/CLOCKS_PER_SEC;
+
     ENTER ("sess=%p uri=%s", this, m_uri.c_str ());
     end ();
     destroy_backend ();
@@ -134,6 +136,11 @@ QofSessionImpl::~QofSessionImpl () noexcept
     qof_book_destroy (m_book);
     m_book = nullptr;
     LEAVE ("sess=%p", this);
+
+    float endTime = (float)clock()/CLOCKS_PER_SEC;
+
+    float timeElapsed = endTime - startTime;
+    PWARN ("quit=%f", timeElapsed);
 }
 
 void

and the result -- from UI, repeated reloading of my main datafile; before:

* 20:42:15  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.904586
* 20:42:20  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.885174
* 20:42:26  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.895748
* 20:42:35  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.887468
* 20:42:43  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.914600

after:

* 20:43:34  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.679304
* 20:43:40  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.645597
* 20:43:46  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.652250
* 20:43:51  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.691999
* 20:43:57  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.645178
* 20:44:02  WARN <qof.session> [QofSessionImpl::~QofSessionImpl()] quit=0.664965

@jralls
Copy link
Member

jralls commented May 19, 2024

OK.

christopherlam added a commit to christopherlam/gnucash that referenced this pull request May 20, 2024
@code-gnucash-org code-gnucash-org merged commit fe2cdf4 into Gnucash:stable May 20, 2024
4 checks passed
@christopherlam christopherlam deleted the speed-up-book-close branch May 20, 2024 01:06
christopherlam referenced this pull request May 21, 2024
because removing the latest split is far more common (e.g. from ui or
during book shutdown) than removing an early split.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants