I've fixed it, but I've used seconds instead of minutes. It's easier this
way.
We have another problem. Even though the indexing is paused. I get an update
that the indexingSpeed is being reduced. (Not Immediately. About 15-20
seconds after it has been paused)
[/home/vishesh/kde/bin/nepomukservicestub]
nepomukstrigiservice(3823)/nepomuk (strigi service)
Nepomuk::IndexScheduler::setIndexingSpeed: 0 FullSpeed
[/home/vishesh/kde/bin/nepomukservicestub] nepomukfilewatch(3825)/nepomuk
(filewatch service) Nepomuk::FileWatch::watchFolder:
"/home/vishesh/indexing"
[/home/vishesh/kde/bin/nepomukservicestub]
nepomukstrigiservice(3823)/nepomuk (strigi service)
Nepomuk::IndexScheduler::setIndexingSpeed: 1 ReducedSpeed
Normally indexing a folder, which has about 29 files takes about 1min 43
seconds. (It has a mix of sounds & images). When I deliberately pause the
indexing (via dbus), it gets paused. The strigi widget shows that it's
paused and so does dbus. Yet, the above output is displayed in the terminal,
and on unpausing, the indexer takes lesser time.
I checked out IndexScheduler::waitForContinue, and it seems to be fine. I
even added debugging statements and it is waiting. :-/ So, in the end I
don't know whats wrong. Could someone else take a shot at this? BTW, this is
happening with the earlier versions of the patch as well. I just didn't
notice.
*Other Things I noticed :*
I was going through the source code of IndexScheduler and I saw a function
void setReducedIndexingSpeed( bool reduced = false );
Shouldn't the default value be true?
- Vishesh Handa
On Thu, Apr 22, 2010 at 12:41 AM, Sebastian Trüg <[email protected]> wrote:
> On 04/21/2010 07:10 PM, Vishesh Handa wrote:
> >
> > But I just realized yet another issue (sorry): QTime only measures a
> > single day. In theory the initial indexing can take more than an
> hour.
> >
> >
> > True. But I think what you meant was that the initial indexing could
> > take more than a day. In which case the time will get wrapped once it
> > exceeds a day, and hence be incorrect.
> >
> > That means it could make more sense to measure the indexing time in
> > minutes only (let's face it, we do not care much about seconds and
> msecs
> > here). So maybe the best would be to remember the start of indexing
> as a
> > QDateTime and then sum up the minutes that have passed since then.
> >
> >
> > I don't get what you mean. If we just sum up the minutes since then we
> > wouldn't be accounting for the duration where the indexer was paused.
> > And that is the issue I wanted to address. Or maybe we could store the
> > dateTime when the initial indexing began, and store the paused time as
> > well (Is this what you meant?). But then the paused time is also
> > susceptible to the more than a day problem.
> >
> > Could you please elaborate a little bit more?
>
> I thought about storing the datetime when indexing starts. Then whenever
> we pause we do this:
>
> m_totalIndexingMinutes
> += getPassedMinutes(m_indexingStartTime
> QDateTime::currentDateTime());
>
> then when indexing is resumed we again remember the time:
>
> m_indexingStartTime = QDateTime::currentDateTime();
>
> Of course the method getPassedMinutes does not exist yet. ;)
>
> Cheers,
> Sebastian
>
Index: eventmonitor.h
===================================================================
--- eventmonitor.h (revision 1116179)
+++ eventmonitor.h (working copy)
@@ -22,7 +22,7 @@
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QTimer>
-#include <QtCore/QTime>
+#include <QtCore/QDateTime>
class KDiskFreeSpace;
@@ -42,12 +42,16 @@
void slotPowerManagementStatusChanged( bool conserveResources );
void slotCheckAvailableSpace();
void slotIndexingStopped();
+ void pauseIndexing(int pauseState);
+ void resumeIndexing();
+ void slotIndexingSuspended( bool suspended );
private:
enum {
NotPaused,
PausedDueToPowerManagement,
- PausedDueToAvailSpace
+ PausedDueToAvailSpace,
+ PausedCustom
};
IndexScheduler* m_indexScheduler;
@@ -56,7 +60,8 @@
// timer used to periodically check for available space
QTimer m_availSpaceTimer;
- QTime m_initialIndexTime;
+ QDateTime m_indexingStartTime;
+ int m_totalIndexingSeconds;
};
}
Index: eventmonitor.cpp
===================================================================
--- eventmonitor.cpp (revision 1116179)
+++ eventmonitor.cpp (working copy)
@@ -43,7 +43,8 @@
Nepomuk::EventMonitor::EventMonitor( IndexScheduler* scheduler, QObject* parent )
: QObject( parent ),
m_indexScheduler( scheduler ),
- m_pauseState( NotPaused )
+ m_pauseState( NotPaused ),
+ m_totalIndexingSeconds( 0 )
{
// monitor the powermanagement to not drain the battery
connect( Solid::PowerManagement::notifier(), SIGNAL( appShouldConserveResourcesChanged( bool ) ),
@@ -57,7 +58,7 @@
if ( StrigiServiceConfig::self()->isInitialRun() ) {
// TODO: add actions to this notification
- m_initialIndexTime.start();
+ m_indexingStartTime = QDateTime::currentDateTime();
// inform the user about the initial indexing
sendEvent( "initialIndexingStarted",
@@ -70,6 +71,9 @@
connect( m_indexScheduler, SIGNAL( indexingStopped() ),
this, SLOT( slotIndexingStopped() ),
Qt::QueuedConnection );
+
+ connect( m_indexScheduler, SIGNAL( indexingSuspended(bool) ),
+ this, SLOT( slotIndexingSuspended(bool) ) );
}
slotPowerManagementStatusChanged( Solid::PowerManagement::appShouldConserveResources() );
@@ -85,16 +89,14 @@
{
if ( !conserveResources && m_pauseState == PausedDueToPowerManagement ) {
kDebug() << "Resuming indexer due to power management";
- m_pauseState = NotPaused;
- m_indexScheduler->resume();
+ resumeIndexing();
sendEvent( "indexingResumed", i18n("Resuming indexing of files for fast searching."), "battery-charging" );
}
else if ( conserveResources &&
m_indexScheduler->isRunning() &&
!m_indexScheduler->isSuspended() ) {
kDebug() << "Pausing indexer due to power management";
- m_pauseState = PausedDueToPowerManagement;
- m_indexScheduler->suspend();
+ pauseIndexing( PausedDueToPowerManagement );
sendEvent( "indexingSuspended", i18n("Suspending the indexing of files to preserve resources."), "battery-100" );
}
}
@@ -107,8 +109,7 @@
if ( info.available() <= StrigiServiceConfig::self()->minDiskSpace() ) {
if ( m_indexScheduler->isRunning() &&
!m_indexScheduler->isSuspended() ) {
- m_pauseState = PausedDueToAvailSpace;
- m_indexScheduler->suspend();
+ pauseIndexing( PausedDueToAvailSpace );
sendEvent( "indexingSuspended",
i18n("Disk space is running low (%1 left). Suspending indexing of files.",
KIO::convertSize( info.available() ) ),
@@ -117,8 +118,7 @@
}
else if ( m_pauseState == PausedDueToAvailSpace ) {
kDebug() << "Resuming indexer due to disk space";
- m_pauseState = NotPaused;
- m_indexScheduler->resume();
+ resumeIndexing();
sendEvent( "indexingResumed", i18n("Resuming indexing of files for fast searching."), "drive-harddisk" );
}
}
@@ -133,14 +133,48 @@
{
// inform the user about the end of initial indexing. This will only be called once
if ( !m_indexScheduler->isSuspended() ) {
- kDebug() << "initial indexing took" << m_initialIndexTime.elapsed();
+ m_totalIndexingSeconds += m_indexingStartTime.secsTo( QDateTime::currentDateTime() );
+ const int elapsed = m_totalIndexingSeconds * 1000;
+
+ kDebug() << "initial indexing took" << elapsed;
sendEvent( "initialIndexingFinished",
i18nc( "@info %1 is a duration formatted using KLocale::prettyFormatDuration",
"Initial indexing of files for fast searching finished in %1",
- KGlobal::locale()->prettyFormatDuration( m_initialIndexTime.elapsed() ) ),
+ KGlobal::locale()->prettyFormatDuration( elapsed ) ),
"nepomuk" );
m_indexScheduler->disconnect( this );
}
}
+
+void Nepomuk::EventMonitor::pauseIndexing(int pauseState)
+{
+ m_pauseState = pauseState;
+ m_indexScheduler->suspend();
+
+ m_totalIndexingSeconds += m_indexingStartTime.secsTo( QDateTime::currentDateTime() );
+}
+
+
+void Nepomuk::EventMonitor::resumeIndexing()
+{
+ m_pauseState = NotPaused;
+ m_indexScheduler->resume();
+
+ m_indexingStartTime = QDateTime::currentDateTime();
+}
+
+
+void Nepomuk::EventMonitor::slotIndexingSuspended( bool suspended )
+{
+ if( suspended ) {
+ //The indexing is already paused, this meerly sets the correct state, and adjusts the timing.
+ pauseIndexing( PausedCustom );
+ }
+ else {
+ //Again, used to set the correct state, and adjust the timing.
+ resumeIndexing();
+ }
+}
+
#include "eventmonitor.moc"
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk