gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A question on discardEventsMatchingMask:beforeEvent:


From: Banlu Kemiyatorn
Subject: Re: A question on discardEventsMatchingMask:beforeEvent:
Date: Fri, 28 Jan 2011 23:07:22 +0700

On Fri, Jan 28, 2011 at 10:33 PM, Richard Frith-Macdonald
<address@hidden> wrote:
>
> On 28 Jan 2011, at 14:53, Banlu Kemiyatorn wrote:
>> Just try benching with preallocated pool to make use of deallocated
>> object w/o reallocation, it's ~160% faster than traditional +alloc. So
>> my event queue would use a union for encapsulation, like XEvent.
>
> For sure the biggest problem with events in GNUstep (which made us need to 
> combine them in the backend) was performance even when just dragging the 
> mouse, and most of the issue was with the allocation/deallocation of NSEvent 
> objects.  I considered trying to improve that a few years ago, so I'm not 
> surprised that you can get a huge performance improvement using an 
> alternative allocation scheme.
> When I was looking at it, I found it hard to see how best to make a fast 
> allocation/deallocation scheme thread-safe.
> You might also want to consider the idea of making the event queue a linked 
> list rather than a mutable array implementation.

Thanks,
In the test I use something like fixed array.. kinda like
malloc(sizeof(@defs(NSEvent)) * fixed_array_size) but not exactly the
same, with a NSLock'ed mapper stack that can tell which slot was
recently freed for new allocation, should be similar to adding a link
pointer into the struct. This is on GNU/Linux Ubuntu though. The fixed
size pool can be fully filled, when that happen, it temporarily stores
new event in a linked-list for counting the leak and increase the
fixed size pool to suite the leaking result. This would allow the
fixed pool to periodically grow and shrink over time.

Note that in my implementation, my app also allows these methods to
register events to the event pool (will be used for XInput2 support),
which didn't cause NSEvent mallocations, the parameters were directly
stored on the preallocated struct array. The real NSEvent then can be
allocated after a user definable filtering method. May not sound that
necessary after the event pool, but I'd like to keep it for faster
enumeration API.

- (void) postMouseEventWithType:(NSEventType)type
                       location:(NSPoint)location
                  modifierFlags:(NSUInteger)flags
                      timestamp:(NSTimeInterval)time
                   windowNumber:(NSInteger)windowNum
                        context:(NSGraphicsContext *)context
                    eventNumber:(NSInteger)eventNumber
                     clickCount:(NSInteger)clickNumber
                       pressure:(float)pressure
                        atStart:(BOOL)atStart;
et. all

-- 
    .----.     Banlu Kemiyatorn
  /.../\...\   漫画家
 |.../  \...|  http://qstx.blogspot.com (Free Software Advocacy & Development)
 |../    \..|  http://feedbat.blogspot.com (Studio Work For Hire)
  \/      \/   http://groundzerostudiocomplex.blogspot.com (Studio Research)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]