Opened 13 years ago

Closed 13 years ago

#695 closed task (fixed)

[PATCH] Stop using boost::filesystem::operator< so much

Reported by: Philip Taylor Owned by: Rodolphe Ortalo
Priority: Nice to Have Milestone: Alpha 4
Component: Core engine Keywords: simple
Cc: Jan Wassenberg Patch:

Description

When launching the game and starting a map, Callgrind says boost::filesystem::operator< accounts for about 14% of instructions executed, which is a stupid waste. It's called about 90,000 times and does about 800,000 memory allocations (it's not just a straight string comparison).

The main callers are

CTextureManagerImpl::CreateTexture
CTextureManagerImpl::GetConverterSettings
CTextureManagerImpl::GetSettingsFile
CSkeletonAnimManager::GetAnimation
Landlord<>::add_
FileCache::Retrieve

which look like std::map<VfsPath, ...>. If these places don't care about ordered iteration, they should probably use a hash map instead. If they do care, they should probably store strings instead of VfsPaths so that lookups are cheaper.

Attachments (1)

ro_695_r2.patch (7.5 KB ) - added by Rodolphe Ortalo 13 years ago.
Patch with respect to source/ directory

Download all attachments as: .zip

Change History (6)

comment:1 by Jan Wassenberg, 13 years ago

Cc: Jan Wassenberg added

comment:2 by Rodolphe Ortalo, 13 years ago

Owner: set to Rodolphe Ortalo
Status: newassigned

Attached patch should bring usage of this operator to nearly 0. I followed your hints, and also changed the set type of the TextureCache object to boost::unordered_set to eliminate the last 23000 calls. (Checked with Callgrind.) Hope the patch is correct (have not done C++ for a while).

Please, feedback.

by Rodolphe Ortalo, 13 years ago

Attachment: ro_695_r2.patch added

Patch with respect to source/ directory

comment:3 by Rodolphe Ortalo, 13 years ago

Keywords: review added

comment:4 by Rodolphe Ortalo, 13 years ago

Summary: Stop using boost::filesystem::operator< so much[PATCH] Stop using boost::filesystem::operator< so much

comment:5 by Jan Wassenberg, 13 years ago

Keywords: review removed
Resolution: fixed
Status: assignedclosed

Committed (along with a few more set -> unordered_set in CGUI), thanks!

Note: See TracTickets for help on using tickets.