-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 06/26/2010 10:18 PM, Bill Webster wrote: > My use case is long-lived C++ application, which invokes millions of worker > threads during its lifetime.
Making my point about Windows application design rather well :-) > My C++ objects do "clean up after themselves", but I would like to provide > strong guarantees about memory and file handles in exception handlers. Those statements are contradictory. If you have a C++ object encapsulating a statement then why isn't it finalizing them? Same question for blobs, connections etc. To do it right you'll probably need to use some form of reference counting as you need to ensure blobs and statements are cleaned up before connections, user defined collations & functions after statements but before connections etc. Also be aware that SQLite is C code and hence not exception safe. Consequently you cannot throw exceptions in user defined functions, collations, virtual tables etc. Instead you'll need to catch exceptions and change them into a SQLite error code and message. When back in your code that called SQLite, you can turn error codes and messages back into exceptions again. I do both the reference counting to ensure correct ordering of cleanup and exception handling in my Python wrapper in order to adapt the C nature of SQLite to Python's object model. (ie this stuff works, works well and is reliable.) > Performance is very important. I can't just spawn processes and let the OS > take care of resource cleanup. Why not? Making processes and cleaning up is something they are good at. Obviously spawning a process per query would be over the top, but longer lived processes are just fine. And in many cases you can expect increased performance - page tables do not have to be shared between processes as they are between threads, no need for barriers and other expensive parts of thread synchronization, SQLite's mutexes won't affect anything etc. You can also spread work over multiple machines by using TCP instead of pipes for components to talk to each other. Additionally it is more reliable using multiple processes - for example you can limit the amount of memory a worker process consumes so that it crashes if there is a leak or denial of service attack which won't take out your main application. Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkwm/KQACgkQmOOfHg372QSaFgCeOLhGykgzYQOqYywSAaMjngvw YmYAoKQyybAyFjbYrX4AUSwvdaROxCJp =MocH -----END PGP SIGNATURE----- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users