
Took a look at the flyweight library. I'm very much a beginner - so not a formal review, just a couple of comments: I wrote a very simple test program to try flyweight. In essence: vector<boost::flyweight<string> > vec; struct Insert { void operator()(string s) { vec.push_back(boost::flyweight<string>(s)); //vec.push_back(s); } }; void Test() { fstream f("d:\\bible12.txt", ios_base::in); { boost::progress_timer t; for_each(istream_iterator<string>(f), istream_iterator<string>(), Insert()); } } This fails to compile with Borland Turbo C++ (internal compiler error) Under MS Visual C++ (Express 2008) it compiles ok. There is quite a performance hit over a standard vector<string> - 6s -> 80s in debug and 101s in release? From the docs I'd expected to just use copy and back_inserter? However, the showstopper for me at present is this crashes with: Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'd:\Users\Martin\Documents\Visual Studio 2008\Projects\fly\Debug\fly.exe'. Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79e7352e, on thread 0x15d0. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack. Windows has triggered a breakpoint in fly.exe. This may be due to a corruption of the heap, which indicates a bug in fly.exe or any of the DLLs it has loaded. This may also be due to the user pressing F12 while fly.exe has focus. The output window may have more diagnostic information. On termination of the program. Have I misunderstood the usage of flyweight, or is there a problem here? Martin

Hello Martin, Martin Fisher ha escrito:
Took a look at the flyweight library.
I'm very much a beginner - so not a formal review, just a couple of comments:
I wrote a very simple test program to try flyweight.
In essence:
[...]
This fails to compile with Borland Turbo C++ (internal compiler error)
This is expected as flyweight<> default factory is based on Boost.MultiIndex, which is not supported on Borland. You might try redefining your flyweight type as flyweight<string,set_factory> where the factory is based on a regular std::set. I don't know if this will work in Borland, though, I haven't tried this compiler myself.
Under MS Visual C++ (Express 2008) it compiles ok. There is quite a performance hit over a standard vector<string> - 6s -> 80s in debug and 101s in release? From the docs I'd expected to just use copy and back_inserter?
However, the showstopper for me at present is this crashes with:
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'd:\Users\Martin\Documents\Visual Studio 2008\Projects\fly\Debug\fly.exe'.
Are you compiling in C++/CLI (CLR) mode rather than pure C++? This might be the cause of the speed penalty and the crash. I don't know how compatible the library is with managed C++'s. If you can provide me with a complete test program I'll be happy to try it myself this afternoon (in ~10 hours) and report my findings. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín Mª López Muñoz ha escrito:
Hello Martin,
Martin Fisher ha escrito:
Under MS Visual C++ (Express 2008) it compiles ok. There is quite a performance hit over a standard vector<string> - 6s -> 80s in debug and 101s in release? From the docs I'd expected to just use copy and back_inserter?
However, the showstopper for me at present is this crashes with:
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'd:\Users\Martin\Documents\Visual Studio 2008\Projects\fly\Debug\fly.exe'.
Are you compiling in C++/CLI (CLR) mode rather than pure C++? This might be the cause of the speed penalty and the crash. I don't know how compatible the library is with managed C++'s. If you can provide me with a complete test program I'll be happy to try it myself this afternoon (in ~10 hours) and report my findings.
You might want to take a look at a performance measuring program that is provided in the examples section: http://svn.boost.org/svn/boost/sandbox/flyweight/libs/flyweight/doc/examples... As you can see, the kind of test it performs is similar to what your program does. I've just compiled it with MSVC++ 6.0 and run it against a text file of Don Quixote (http://www.gutenberg.org/dirs/etext99/2donq10.txt, ~2 MB) and the results are (release mode): 1. simple string Time used: 7.218 s Bytes used: 44416133 2. flyweight, hashed factory Time used: 5.062 s Bytes used: 5852582 3. flyweight, hashed factory, no tracking Time used: 4.328 s Bytes used: 5750046 4. flyweight, set-based factory Time used: 5.782 s Bytes used: 5963774 5. flyweight, set-based factory, no tracking Time used: 4.953 s Bytes used: 5861238 The results are in no way similar to what you're getting, so I'm growing more suspicious the problem has to do with your using C++/CLI instead of C++. Maybe you can run the performance program yourself and compare. I'll be able to provide figures for MSVC++ 8.0 this afternoon, and, if you provide me with your test program, I will also run that. Best, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
Joaquín Mª López Muñoz
-
Martin Fisher