-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use mimalloc to improve performance and reduce memory allocation lock contention #6
Use mimalloc to improve performance and reduce memory allocation lock contention #6
Conversation
I'm looking at enabling github actions on this repo. Once I get that working I can look at this PR |
any chance you can test the installers from https://github.com/postgresql-interfaces/psqlodbc/actions/runs/8469691901 |
Sorry I was off for a few weeks. Do you still need these installers tested? |
@apgrucza yes please. I have been working on automating the release process. |
Can you rebase and add your tests to the github actions ? |
I ran the
Not sure which tests you are referring to. This pull request does not add any tests. |
@apgrucza right, but wouldn't we have to build with your option turned on, and then run all of the tests ? |
0df3899
to
c602f0b
Compare
c602f0b
to
d886ab4
Compare
@apgrucza looks like the test is failing ? |
@davecramer my changes are now complete. Please try again. |
Thanks! |
@davecramer I tried running the 64-bit installer again (the linked artifact has expired but I still have the file), and I now get the following error: Error installing ODBC driver: PostgreSQL ANSI(x64), ODBC error 13: The setup routines for the PostgreSQL ANSI(x64) ODBC driver could not be loaded due to system error code 126: The specified module could not be found. (C:\Program Files\psqlODBC\1600\bin\psqlodbc30a.dll).. Verify that the file PostgreSQL ANSI(x64) exists and that you can access it. Not sure why I didn't get this the first time around. The same error occurs whether I install fresh or upgrade from an old version. I've tested on two different machines. The |
The x86 installer works fine though. |
@apgrucza can you try https://github.com/postgresql-interfaces/psqlodbc/releases/tag/REL-16_00_0003 ? |
@davecramer that link only contains the x86 installer. I did test that one (in addition to the build artifacts) and it installed without error. The problem seems to be just with the x64 installer. I don't think it's related, but I'm also curious to know why the version of |
Interesting. As for 17. it's because I build against head. Presumably the next release will be against 17 |
The instructions on how to create the installers are not helpful here. |
I found the problem. I deleted
out of installer.mak. This is where the extra files are added |
When was that? installer.mak hasn't been changed for 10 years. |
Not sure, all I know is that it is in the original code, and that is where the additional dll's are added |
So looking at this some more, psqlodbc/installer/psqlodbcm_cpu.wxs Lines 106 to 135 in 3869efe
It's becoming clear to me that the actual release steps are not documented anywhere. You are correct installer.mak hasn't changed and I found the code in a private repo that I have access to. Either way we need to fix the release code to include those libraries. Also need to figure out how to get the 32bit versions of those libraries. |
I just took a deeper look too.
As you say, we still need to figure out how to get the 32-bit versions of those libraries. @winpg was the one who always prepared and announced psqlODBC releases. Perhaps he could provide some insight here, or is he also unavailable? |
The EDB installer must include those extra DLLs because they are required by PostgreSQL. So I checked the Windows build instructions for PostgreSQL and it lists the requirements. One of them is OpenSSL, and it provides a link to download binaries. I downloaded OpenSSL v3.3.0 Light and found that it includes both the |
Yes, I am in the process of doing that now!. Thanks |
can you check the installers from https://github.com/postgresql-interfaces/psqlodbc/actions/runs/8992393964 |
Both installers now work without errors. However, the x86 installer still does not contain the libssl and libcrypto DLLs. |
One problem I can see is that this:
needs to be changed to this:
|
BTW the usage of |
The dll's are installed in both places so it is currently correct. |
I'm not sure how to handle that either. I guess we need to figure out how to invalidate the cache when the version of postgres changes as well. Thanks for testing this |
… contention (#6) * Add mimalloc submodule and update build script * Add steps to build and test with UseMimalloc * Update mimalloc submodule * Change UseMimalloc parameter type to switch * Add ExpectMimalloc parameter * Fetch mimalloc submodule and use mimalloc parameters * Prevent MIMALLOC_VERBOSE aborting tests * Uninstall driver after tests; upload mimalloc artifacts
Yes you are correct. So I guess the installers you built weren't working due to the caching issue. |
I disabled the caching in my fork so that I could test your changes. The x86 installer does now install the libssl and libcrypto DLLs. However, the DLL versions are not consistent between x86 and x64.
Is it possible to build the x64 driver the same way as the x86 driver so that we can have some consistency? And to get the PostgreSQL code from a stable release, from https://www.postgresql.org/ftp/source/? |
Ah, good point. Yes, it is possible to build the driver the same way |
can you check these https://github.com/davecramer/psqlodbc/actions/runs/9036264469 ? |
I have a fix for the caching issue here: #13 |
The x86 artifact still contains libpq 17, and looking at the GitHub Actions log reveals that it's because the "build postgresx86" step was again skipped (due to the caching problem). If you want to merge your changes then I can rebase #13 and the problem should go away. |
The EDB installer takes 2m 30s to install. With your recent change, is the EDB installer now only used to run PostgreSQL (so that the psqlodbc tests can run)? If so, we could reduce the workflow duration by running the PostgreSQL Docker image instead. |
I didn't think docker ran on github windows images ? |
Oh, that surprises me. I haven't used GitHub Actions much before. |
I think you can run testcontainers which does run docker but I don't think you can specify the version of postgres. It seemed simpler to use EDB |
We have a multi-threaded Windows application that was experiencing delays due to high lock contention in memory allocations from the PostgreSQL ODBC driver. We tried modifying the driver to use mimalloc, which is a memory allocator with better performance characteristics. After deploying this change, the delays due to lock contention disappeared. It has been running on thousands of our production deployments for 9 months without issue.
I've created this pull request so that others can benefit from this change by building the driver with the
_MIMALLOC_
symbol defined and linking to the mimalloc library. If building on Windows,BuildAll.ps1
accepts a-UseMimalloc
argument that does this for you (requires a toolset ofv141
,v142
or later). Below is an example of how to build with mimalloc on Windows:Currently the usage of mimalloc is off by default, but I'd like to get people's thoughts on whether it should be enabled by default.