Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311186 - [cache] Inefficiency in CommandCache
Summary: [cache] Inefficiency in CommandCache
Status: CLOSED INVALID
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf (show other bugs)
Version: 6.0   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Pawel Piech CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-30 10:25 EDT by Marc Khouzam CLA
Modified: 2010-04-30 11:30 EDT (History)
1 user (show)

See Also:
marc.khouzam: review? (pawel.1.piech)


Attachments
Proposed improvement (1.16 KB, patch)
2010-04-30 10:25 EDT, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Khouzam CLA 2010-04-30 10:25:33 EDT
Created attachment 166615 [details]
Proposed improvement

While looking at CommandCache, I noticed a potential minor inefficiency.

Pawel, are you ok with this change?
Comment 1 Marc Khouzam CLA 2010-04-30 11:30:52 EDT
Thanks to the JUnit tests I realized this 'fix' was bad.

I wanted to optimize:

for ( CommandInfo unqueuedCommand : new ArrayList<CommandInfo>(fPendingQCommandsNotYetSent) ) {
   if ( unqueuedCommand.equals( cachedCmd )) {
        fPendingQCommandsNotYetSent.remove(unqueuedCommand);
        fPendingQCommandsSent.add(unqueuedCommand);
        break;
   }
}


the problem turns out to be that 'cachedCmd' although considered equals() with 'unqueuedCommand', is not actually identical.  'cachedCmd' does not contain the list of requestMonitors that unqueuedCommand contains.

So, we actually need to fetch unqueuedCommand from the fPendingQCommandsNotYetSent map before inserting it in fPendingQCommandsSent

I've added a comment in the method to explain this.