https://git.reactos.org/?p=reactos.git;a=commitdiff;h=65e29b4b1f3ba0360c2fb…
commit 65e29b4b1f3ba0360c2fb30b5c3a38d1ffb784e2
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Wed May 2 23:30:10 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Wed May 2 23:33:45 2018 +0200
[NTOSKRNL] Optimize a bit deferred writes.
In the lazy writer run, first post items that are queued for this.
Only then, start executing deferred writes if any.
If there were any, reschedule immediately a lazy writer run, to keep
Cc warm and to make it unqueue write faster in case of high IOs situation.
To make second lazy writer run happen faster, we keep our state active to
use short delay (1s) instead of standard idle (3s).
---
ntoskrnl/cc/lazywrite.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/ntoskrnl/cc/lazywrite.c b/ntoskrnl/cc/lazywrite.c
index ddb7bc42c3..8cb5adb2e7 100644
--- a/ntoskrnl/cc/lazywrite.c
+++ b/ntoskrnl/cc/lazywrite.c
@@ -152,12 +152,6 @@ CcLazyWriteScan(VOID)
DPRINT("Lazy writer done (%d)\n", Count);
}
- /* If we have deferred writes, try them now! */
- if (!IsListEmpty(&CcDeferredWrites))
- {
- CcPostDeferredWrites();
- }
-
/* Post items that were due for end of run */
while (!IsListEmpty(&ToPost))
{
@@ -166,10 +160,22 @@ CcLazyWriteScan(VOID)
CcPostWorkQueue(WorkItem, &CcRegularWorkQueue);
}
- /* We're no longer active */
- OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
- LazyWriter.ScanActive = FALSE;
- KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);
+ /* If we have deferred writes, try them now! */
+ if (!IsListEmpty(&CcDeferredWrites))
+ {
+ CcPostDeferredWrites();
+ /* Reschedule immediately a lazy writer run
+ * Keep us active to have short idle delay
+ */
+ CcScheduleLazyWriteScan(FALSE);
+ }
+ else
+ {
+ /* We're no longer active */
+ OldIrql = KeAcquireQueuedSpinLock(LockQueueMasterLock);
+ LazyWriter.ScanActive = FALSE;
+ KeReleaseQueuedSpinLock(LockQueueMasterLock, OldIrql);
+ }
}
VOID CcScheduleLazyWriteScan(