Ticket #10069 (new optimization)

Opened 6 weeks ago

2.8: Double performance of wxMimeTypesManagerImpl::Initialize

Reported by: botg Owned by:
Priority: normal Milestone:
Component: base Version: 2.8-svn
Keywords: Cc:
Blocked By: Patch: yes
Blocking:

Description

This patch speeds up the mime types manager initialization in src/unix/mimetype.cpp

Using the callgrind tool in valgrind and the KCachegrind visualization shows that simply starting the XRC sample and closing it again spends more than a third of the time in wxMimeTypesManagerImpl::Initialize, which takes roughly 460M instructions.

Observations:
- In lots of cases pIndexOf gets called with a key just to use the returned index with GetCmd to get the value for that key.
- The search strings and lines in the file always get converted into lowercase, CmpNoCase however is much faster, avoids copying the string.

The attached patch adds the wxMimeTextFile::GetCmd(const wxString& sSearch) function which does the above two things in one step and more efficiently by using CmpNoCase.
It also exploits the fact that string lengths and check for the = key/value separator are essentially free.

This more than halves the runtime requirements of wxMimeTypesManagerImpl::Initialize and brings it down to below 220M instructions.

Patch only implemented for 2.8 branch for now. I had a brief look at trunk, but there are a couple of differences and I'm not familiar with the changes to wxString and its usage on trunk yet.

Attachments

mimetype.cpp.patch (6.8 kB) - added by botg 6 weeks ago.

Change History

Changed 6 weeks ago by botg

Note: See TracTickets for help on using tickets.