qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ui: Optimization dirty rect empty check logic
@ 2023-11-25  7:54 lijiejun
  2023-11-27  8:05 ` Marc-André Lureau
  0 siblings, 1 reply; 2+ messages in thread
From: lijiejun @ 2023-11-25  7:54 UTC (permalink / raw)
  To: kraxel; +Cc: qemu-devel, lijiejun

Reduce unnecessary code execution in function qemu_spice_create_update,
such as "int blocks = DIV_ROUND_UP(surface_width(ssd->ds), blksize);"
and "int bpp = surface_bytes_per_pixel(ssd->ds);".

Signed-off-by: lijiejun <a_lijiejun@163.com>
---
 ui/spice-display.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/ui/spice-display.c b/ui/spice-display.c
index 6eb98a5a5c..508e35ed0f 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -194,10 +194,6 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
     int bpp = surface_bytes_per_pixel(ssd->ds);
     uint8_t *guest, *mirror;
 
-    if (qemu_spice_rect_is_empty(&ssd->dirty)) {
-        return;
-    };
-
     dirty_top = g_new(int, blocks);
     for (blk = 0; blk < blocks; blk++) {
         dirty_top[blk] = -1;
@@ -488,7 +484,9 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
 
     WITH_QEMU_LOCK_GUARD(&ssd->lock) {
         if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) {
-            qemu_spice_create_update(ssd);
+            if (!qemu_spice_rect_is_empty(&ssd->dirty)) {
+                qemu_spice_create_update(ssd);
+            }
             ssd->notify++;
         }
     }
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ui: Optimization dirty rect empty check logic
  2023-11-25  7:54 [PATCH] ui: Optimization dirty rect empty check logic lijiejun
@ 2023-11-27  8:05 ` Marc-André Lureau
  0 siblings, 0 replies; 2+ messages in thread
From: Marc-André Lureau @ 2023-11-27  8:05 UTC (permalink / raw)
  To: lijiejun; +Cc: kraxel, qemu-devel

Hi

On Sat, Nov 25, 2023 at 11:55 AM lijiejun <a_lijiejun@163.com> wrote:
>
> Reduce unnecessary code execution in function qemu_spice_create_update,
> such as "int blocks = DIV_ROUND_UP(surface_width(ssd->ds), blksize);"
> and "int bpp = surface_bytes_per_pixel(ssd->ds);".
>
> Signed-off-by: lijiejun <a_lijiejun@163.com>

This is a micro-optimization which makes the
qemu_spice_create_update() less complete, mixing caller/callee
responsibilities.

> ---
>  ui/spice-display.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index 6eb98a5a5c..508e35ed0f 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -194,10 +194,6 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
>      int bpp = surface_bytes_per_pixel(ssd->ds);
>      uint8_t *guest, *mirror;
>
> -    if (qemu_spice_rect_is_empty(&ssd->dirty)) {
> -        return;
> -    };
> -
>      dirty_top = g_new(int, blocks);
>      for (blk = 0; blk < blocks; blk++) {
>          dirty_top[blk] = -1;
> @@ -488,7 +484,9 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
>
>      WITH_QEMU_LOCK_GUARD(&ssd->lock) {
>          if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) {
> -            qemu_spice_create_update(ssd);
> +            if (!qemu_spice_rect_is_empty(&ssd->dirty)) {
> +                qemu_spice_create_update(ssd);
> +            }
>              ssd->notify++;
>          }
>      }
> --
> 2.25.1
>
>


-- 
Marc-André Lureau


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-27  8:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-25  7:54 [PATCH] ui: Optimization dirty rect empty check logic lijiejun
2023-11-27  8:05 ` Marc-André Lureau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).