-
Notifications
You must be signed in to change notification settings - Fork 42
std::wstring_convert performance bottleneck #161
Conversation
Nice catch! Makes total sense to have that be static there too. |
I'm happy to modify this patch to do both if you like. |
Indeed, it looks like there are a few places it could be added---plus I have an indentation issue. Curse you, GitHub editor... I'll fix it locally. |
Good catch. Thanks for very interesting report |
Glad you like it. VS2015 has some really convenient profiling features that made this easy to find. |
@mcg1969 Yes, looks like GH editor is messed with tabs, instead of inserting 4 spaces. @lexicalunit merging? I can untabify after merge. |
Can't blame GitHub for the second commit; that was VS2015. Bothersome. I can fix before merging if you want. |
Fixing would be helpful as it is a good idea to not to mess the history with 'untabify' commits. Regarding multiple commits, yeah, that's why the 'old-school' way of submitting PRs is the best :)
But, if it is a problem, I will take care of it. |
Using a static converter is fine for single threaded applications. How would this hold up against multiple threads using a single (static) converter? Neither This answer seems to agree with me: http://stackoverflow.com/a/26055879 One solution would be to use a static mutex and a lock per converter, before using those converters... But then again, it will be convoluted and it would incur a slight performance penalty in single threaded applications. |
@kentf thanks for chiming in, that's a crucial observation. For my application this is not going to be a problem, but I assume that we shouldn't merge this until this is addressed somehow. I doubt the mutex would be as expensive as the current (non-static) implementation. |
@mcg1969: I agree it's not as expensive as constructing the converter every time. It would make sense to opt out of using Using a non-static I'd love to implement it, but I don't have the time required for testing and verifying it. |
Isn't this what thread_local is for? |
I was just going to ask. I'm a bit new to the latest C++ goodies. |
The downside of thread_local would be poor performance if an app were constantly launching new threads, but I think that's far preferable to the scalability impact of a mutex. |
I agree with @kentf that mutex (or TLS) should be conditionally compiled in. |
Agree that we should make efforts to ensure things don't break for multithreaded applications when possible. I haven't used |
I'm using it now with VS2015. Seems to work fine. And it's c++11, so it's reasonably safe, it would seem. |
There are two more places where we create static |
Thanks Amy. I'm happy to work on both of these PRs in a few days but I've got to help get a release of conda out the door first. (No, we don't use these in conda :-)) |
"(No, we don't use these in conda :-))" Yet! :-p |
I'm sorry for missing this---got your closure notice though! Yes you're right, the focus should be on #201. I've had some difficulty getting the Linux debugging going |
I recently updated a project from VS2010 to VS2015 (finally!) and nanodbc 1.x to 2.x. I saw a horrible slowdown that can be traced to the poor performance of the
std::wstring_convert
constructor; see this post for discussion. Making this converter static seems to have addressed the problem.I only made the change in the VS2015 version of the converter, but I suspect this same pattern should be considered anywhere
std::wstring_convert
is used.