Opened 10 years ago

Last modified 6 years ago

#7494 assigned Bugs

boost::replace_all is very slow on debug build when Format size is big

Reported by: Jan Vonasek <jan.vonasek@…> Owned by: Marshall Clow
Milestone: To Be Determined Component: string_algo
Version: Boost 1.45.0 Severity: Optimization
Keywords: Cc:

Description

Method boost::replace_all(SequenceT& Input, const Range1T& Search, const Range2T& Format) on debug build takes very long time when Format size is about 300k. On call stack I can see push_front for every char.

When I use std::find and std::replace in loop it is cca 10 times faster.

I have Boost library 1.45, Visual Studio 2010, Win7 x64 SP1, 6-core CPU.

Change History (5)

comment:1 by Jan Vonasek <jan.vonasek@…>, 10 years ago

deque::_Insert is used and it contains

for (; _First != _Last; ++_First)

push_front(*_First); prepend flipped

comment:2 by Marshall Clow, 10 years ago

Status: newassigned

Can you send me a test program, please?

comment:3 by Jan Vonasek <jan.vonasek@…>, 10 years ago

Sample code: std::wstring sInput = cca 20kB text (HTML template containing texts like "ImagePath1", "ImagePath2",...); std::wstring sFormat1 = cca 300kB text (base64 encoded image); boost::replace_all(sInput, L"ImagePath1", sFormat1); std::wstring sFormat2 = cca 300kB text (base64 encoded image); boost::replace_all(sInput, L"ImagePath2", sFormat2);

comment:4 by Jan Vonasek <jan.vonasek@…>, 10 years ago

Sample code:

std::wstring sInput = cca 20kB text (HTML template containing texts like "ImagePath1", "ImagePath2",...);
std::wstring sFormat1 = cca 300kB text (base64 encoded image);
boost::replace_all(sInput, L"ImagePath1", sFormat1);
std::wstring sFormat2 = cca 300kB text (base64 encoded image);
boost::replace_all(sInput, L"ImagePath2", sFormat2);

comment:5 by Alexander Zaitsev <zamazan4ik@…>, 6 years ago

Do we need to fix it in Boost 1.61? Or it maybe already fixed?

Note: See TracTickets for help on using tickets.