diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-01-13 09:38:07 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-01-13 09:43:26 +0100 |
commit | bb59742bcf4883af5876a2ffadcc4a689e414b60 (patch) | |
tree | 32083c35eb4968f9c817f084ede88f26e753c025 /connectivity | |
parent | 1b8b6ecf5fdf753bd787748d54aaa61964199465 (diff) |
Confine JDBC driver to thread-affine apartment for Java 6 performance
... so that the massive number of the JDBC driver's calls to JNI Attach/Detach-
CurrentThread are guaranteed not to happen on the main thread (where they are
extremely expensive, see
<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6978641> "Fix for 6929067
introduces additional overhead in thread creation/termination paths").
Diffstat (limited to 'connectivity')
-rwxr-xr-x | connectivity/source/drivers/jdbc/exports.dxp | 1 | ||||
-rw-r--r-- | connectivity/source/drivers/jdbc/jservices.cxx | 16 | ||||
-rwxr-xr-x | connectivity/source/drivers/jdbc/makefile.mk | 2 |
3 files changed, 16 insertions, 3 deletions
diff --git a/connectivity/source/drivers/jdbc/exports.dxp b/connectivity/source/drivers/jdbc/exports.dxp index 70033078921a..f0e1c69934bc 100755 --- a/connectivity/source/drivers/jdbc/exports.dxp +++ b/connectivity/source/drivers/jdbc/exports.dxp @@ -1 +1,2 @@ +component_getImplementationEnvironment component_getFactory diff --git a/connectivity/source/drivers/jdbc/jservices.cxx b/connectivity/source/drivers/jdbc/jservices.cxx index 59c73ff6cbc5..85df77190783 100644 --- a/connectivity/source/drivers/jdbc/jservices.cxx +++ b/connectivity/source/drivers/jdbc/jservices.cxx @@ -83,7 +83,21 @@ struct ProviderRequest void* getProvider() const { return xRet.get(); } }; -//--------------------------------------------------------------------------------------- +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL +component_getImplementationEnvironment( + char const ** ppEnvTypeName, uno_Environment **) +{ + // Recent Java 6 VMs make calls to JNI Attach/DetachCurrentThread (which + // this code does extensively) very expensive. A follow-up JVM fix reduced + // the overhead significantly again for all threads but the main thread. So + // a quick hack to improve performance of this component again is to confine + // it in the affine apartment (where all code will run on a single, + // dedicated thread that is guaranteed no to be the main thread). However, + // a better fix would still be to redesign the code so that it does not call + // Attach/DetachCurrentThread so frequently: + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine"; +} + extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName, void* pServiceManager, diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk index befdc73d7bf8..4229c8f53349 100755 --- a/connectivity/source/drivers/jdbc/makefile.mk +++ b/connectivity/source/drivers/jdbc/makefile.mk @@ -78,8 +78,6 @@ SLOFILES=\ $(SLO)$/tools.obj \ $(SLO)$/ContextClassLoader.obj -SHL1VERSIONMAP=$(SOLARENV)/src/component.map - # --- Library ----------------------------------- SHL1TARGET= $(JDBC_TARGET)$(DLLPOSTFIX) |