ladybird/Ports/qemu/patches/0003-Use-the-coarse-monotonic-clock-for-timing-CPU-ticks.patch
Tim Schumacher be6b3710c8 Ports/qemu: Use the coarse monotonic clock for timing CPU ticks
While this loses quite a bit of accuracy (although to no apparent
decrease in emulation quality) , it helps avoiding the additional
overhead of the `clock_gettime` syscall (as `CLOCK_MONOTONIC_COARSE`
is forwarded using the mapped time page) and we don't have to do a
HPET timer read for each tick.

This results in a decrease of Serenity boot time from 1h16m down to
42m when running on Serenity.
2022-09-30 20:13:11 -07:00

28 lines
1.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tim Schumacher <timschumi@gmx.de>
Date: Sat, 1 Oct 2022 02:46:48 +0200
Subject: [PATCH] Use the coarse monotonic clock for timing CPU ticks
While this loses quite a bit of accuracy (although to no apparent
decrease in emulation quality), it helps avoiding the additional
overhead of the `clock_gettime` syscall (as `CLOCK_MONOTONIC_COARSE`
is forwarded using the mapped time page) and we don't have to do a
HPET timer read for each tick.
---
include/qemu/timer.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index ee071e07d131641131ed9705e7407f153bbf6c67..97fb9b9ac28bd36cd7200e92c3c0c1e30858aa0d 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -833,7 +833,7 @@ static inline int64_t get_clock(void)
{
if (use_rt_clock) {
struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
+ clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
return ts.tv_sec * 1000000000LL + ts.tv_nsec;
} else {
/* XXX: using gettimeofday leads to problems if the date