Cocoa front-end performance improvement
PATCH 1/1 Cocoa front-end performance improvement
Current cocoa.m implementation is forcing a synchronized redraw operation on every display update callback. Fixing this to use the asynchronous method gives a 10x-100x performance boost on the QEMU console windows as the console drawing code is updating every character cell in the window separately. Linked to this, the window resize animation needs to be disabled (i.e. change to immediate resize) or the window contents will display incorrectly during the resize animation. Also, overriding default isOpaque method to return YES increases performance since the QEMU window does not contain transparent areas.
---
cocoa.m +5 -0
@@ -298,6 +298,11 @@ int cocoa_keycode_to_qemu(int keycode) [super dealloc]; } +- (BOOL) isOpaque +{ + return YES; +} + - (void) drawRect:(NSRect) rect { COCOA_DEBUG("QemuCocoaView: drawRect\n");
@@ -403,7 +408,7 @@ int cocoa_keycode_to_qemu(int keycode) } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU
%s", qemu_name]];
- [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:YES];
+ [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO];
}
screen.width = w;
screen.height = h;
@@ -922,7 +927,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h)
w * [cocoaView cdx],
h * [cocoaView cdy]);
}- [cocoaView displayRect:rect];
+ [cocoaView setNeedsDisplayInRect:rect];
}
static void cocoa_resize(DisplayState *ds)
Any comments on this patch? I'm surprised that nobody else has noticed how horribly slow the qemu monitor or any qemu console window is when using Cocoa. And the reason is simple, current implementation is forcing asynchronous updates to be done synchronously. Fixing this also removes the slowness.
Juha
Quoted 55 lines · Riihimaki Juha (Nokia-D/Helsinki)
Current cocoa.m implementation is forcing a synchronized redraw operation on every display update callback. Fixing this to use the asynchronous method gives a 10x-100x performance boost on the QEMU console windows as the console drawing code is updating every character cell in the window separately. Linked to this, the window resize animation needs to be disabled (i.e. change to immediate resize) or the window contents will display incorrectly during the resize animation. Also, overriding default isOpaque method to return YES increases performance since the QEMU window does not contain transparent areas.
Signed-off-by Juha Riihimäki <[email protected]>---
cocoa.m +5
-1@@ -298,6 +298,11 @@ int cocoa_keycode_to_qemu(int keycode) [super dealloc]; } +- (BOOL) isOpaque +{ + return YES; +} + - (void) drawRect:(NSRect) rect { COCOA_DEBUG("QemuCocoaView: drawRect\n");@@ -403,7 +408,7 @@ int cocoa_keycode_to_qemu(int keycode) } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w,h + [normalWindow frame].size.height - screen.height) display:YES animate:YES];
+ [normalWindow setFrame:NSMakeRect([normalWindow
frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YESanimate:NO]; } screen.width = w; screen.height = h;cocoa.m +1
-1@@ -922,7 +927,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h) w * [cocoaView cdx], h * [cocoaView cdy]); } - [cocoaView displayRect:rect]; + [cocoaView setNeedsDisplayInRect:rect]; }
Quoted 4 lines
static void
cocoa_resize(DisplayState *ds)
cocoa.m +7 -2
@@ -298,6 +298,11 @@ int cocoa_keycode_to_qemu(int keycode) [super dealloc]; } +- (BOOL) isOpaque +{ + return YES; +} + - (void) drawRect:(NSRect) rect { COCOA_DEBUG("QemuCocoaView: drawRect\n");
@@ -403,7 +408,7 @@ int cocoa_keycode_to_qemu(int keycode) } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:YES]; + [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO]; } screen.width = w; screen.height = h;
@@ -922,7 +927,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h) w * [cocoaView cdx], h * [cocoaView cdy]); } - [cocoaView displayRect:rect]; + [cocoaView setNeedsDisplayInRect:rect]; } static void cocoa_resize(DisplayState *ds)
Quoted 1 line · Juha Riihimäki
Any comments on this patch? I'm surprised that nobody else has noticed how horribly slow the qemu monitor or any qemu console window is when using Cocoa. And the reason is simple, current implementation is forcing asynchronous updates to be done synchronously. Fixing this also removes the slowness.
Looks good to me and works on a quick test.
Andreas Färber
Acked-byAm 28.03.2009 um 02:39 schrieb Alexander Graf:
Quoted 8 lines · Juha Riihimäki
Quoted 2 lines
Any comments on this patch? I'm surprised that nobody else has noticed how horribly slow the qemu monitor or any qemu console window is when using Cocoa. And the reason is simple, current implementation is forcing asynchronous updates to be done synchronously. Fixing this also removes the slowness.
Looks good to me and works on a quick test.
Signed-off-by Alexander Graf <[email protected]>
QEMU has always been horribly slow on OSX/ppc. Didn't measure the exact performance improvements, but it doesn't seem to break anything.
The patch appeared to be whitespace-damaged. Fixed version attached.
cocoa.m +7 -2
@@ -298,6 +298,11 @@ int cocoa_keycode_to_qemu(int keycode) [super dealloc]; } +- (BOOL) isOpaque +{ + return YES; +} + - (void) drawRect:(NSRect) rect { COCOA_DEBUG("QemuCocoaView: drawRect\n");
@@ -403,7 +408,7 @@ int cocoa_keycode_to_qemu(int keycode) } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:YES]; + [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO]; } screen.width = w; screen.height = h;
@@ -922,7 +927,7 @@ static void cocoa_update(DisplayState *ds, int x, int y, int w, int h) w * [cocoaView cdx], h * [cocoaView cdy]); } - [cocoaView displayRect:rect]; + [cocoaView setNeedsDisplayInRect:rect]; } static void cocoa_resize(DisplayState *ds)
Am 04.04.2009 um 12:26 schrieb Andreas Färber:
Quoted 6 lines
Am 28.03.2009 um 02:39 schrieb Alexander Graf:
Quoted 3 lines · Juha Riihimäki
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Any comments on this patch? I'm surprised that nobody else has noticed how horribly slow the qemu monitor or any qemu console window is when using Cocoa. And the reason is simple, current implementation is forcing asynchronous updates to be done synchronously. Fixing this also removes the slowness.
Looks good to me and works on a quick test.
Signed-off-by Alexander Graf <[email protected]>QEMU has always been horribly slow on OSX/ppc. Didn't measure the exact performance improvements, but it doesn't seem to break anything.
On further tries, I notice a significant improvement when booting FreeBSD/i386.
On the other hand, Debian/sparc currently crashes for me (r6972), and with this patch applied I can't see the last OpenBIOS output:
[sparc] Booting file 'disk' with parameters ''
Trying disk (/iommu/sbus/espdma/esp/sd@0,0)
Andreas