-
Notifications
You must be signed in to change notification settings - Fork 103
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
Improving data source synchronization performance #1186
Comments
Just a thought...
|
I hadn't measured the memory usage before but I ran following command before and after the changes with 100k member (only update) valgrind sympa.pl -d --sync_include=testlist Before:
After:
It would seem that the change would lower at least amount of memory allocated. I'm not sure if the bytes allocated is the stat that matters in this case. I have ran my test in virtual machine with 1 cpu and 512MB memory and just looking at the process (without Valgrind) in htop I get following numbers: Before:
After:
So memory utilization would be little bit higher and CPU utilization would be much higher as the sync process doesn't wait for each request to finish and does some of the checks in code. For the problems with transaction interface. I have triggered two synchronizations in parallel from command line and these finished successfully, but I'm not that familiar with Sympa codebase to know it there are some possible cases for failure. At least PostgreSQL does not seem to support parallel transactions with same connection, but with each transaction in its separate connection it should work. I have used PostgreSQL in my tests. |
What is architecture you are using? For example, x86-64 architecture consumes much memory than 32bit x86. |
I'm using x86-64. Here is some memory stats from
|
Thank you for information! At least the current results don't show a significant increase in memory usage. If possible, could you please also check the results by |
I got measurements from
And from Valgrind Before:
After:
|
Thank you! Things look good so far. Later I'll check memory usage and performance with my VM, too. |
@Jylhis , I have things a little unclear about your PR. First, --- Current code works as:
As far as I understood, your changes will make it:
My question is: May we leave 4. (INSERT new user) and III. (Expire outdated entries) out of the transaction? Second. --- Is the magic with autocomit useful? If poor support for transaction by SQLite is the problem, why not give up using transaction with SQLite? |
That process looks correct. The For the SQLite, it's really just a workaround for a workaround. The problem is that the SQLite sympa/src/lib/Sympa/DatabaseDriver/SQLite.pm Lines 523 to 526 in aa1b3ad
So if we start transaction before calling these functions, it will fail to acquire the lock and it will return undef. The AutoCommit check before commit is just to suppress warning messages saying commit doesn't have any effect when AutoCommit is enabled. Lines 1605 to 1611 in aa1b3ad
|
OK. I understood!
I added that first workaround for SQLite: Without it, the database might be occasionally locked and couldn't be recovered without recreating database file manually. SQLite's implementation for exclusive lock is inadequate. That's why I personally thought, to make things simple, we'd be better not to support transactions with SQLite. I'll think about it some more. |
According to the manual, SQLite's transaction by BEGIN...COMMIT can not be nested. I wrote the methods wrappring DBI methods to deal with it. If possible, can you check ikedas/sympa@4e3446c in your spare time? |
I checked your commit and that is better solution than my workaround. How do you want to handle merging it? Do you want to merge my changes to your branch or should I cherry-pick it to my branch? |
Please feel free to do it in any way confortable, either merging or cherrypicking! |
I cherry picked your commit and pushed the changes to my branch. The latest version should now be in #1184 |
@Jylhis , I checked your code and found a few things to be correct. That's all I can point out. When they are fixed, I'll add some refactoring and cosmetic changes and will merge it to base branch. |
Thanks! I will look into those fixes. |
Hi, I pushed a PR to your PR. If there are not any problems, please add this to your PR. The most important change is the commit 0b19264. Persistent connection (automatic reconnection) feature should be disabled during transaction. Or, if a transaction is aborted, e.g. due to a temporary server connection failure, the connection is automatically recovered |
PR merged 👍🏻 |
…s & ikedas Data source synchronization performance improvement (#1186)
@Jylhis , your PR has been merged now. Thank you for valuable improvment! Your changes will be included in the next beta released in this week. Please let us know if you notice anything. |
…onization performance"
…onization performance" And small refactoring.
Revert changes for #1186 "Improving data source synchronization performance"
Members synchronization process is currently quite slow for our use case and I would like to improve this.
Expected Behavior
Synchronization to be fast as possible and preferably maximum wait time of 1h in worst case scenario.
Current Behavior
Currently synchronizing 100 000 members (60k add and 40k update) takes ~10 min.
Possible Solution
Running profiler for the sync process shows that majority of the sync time is spent executing database queries. The sync process seems to be creating 4 queries per member update and 7 queries per member for remove and add.
I pushed draft PR (#1184) where I have moved couple queries out of loops and doing some of the check in code and I also grouped some of the queries in transactions. Here are the benchmarks I ran with the changes:
add 20 000, remove 20 000 update 20 000 members
add 60 000, update 40 000 members
Context
We need to synchronize around 4 milj. memberships total a cross all lists and we would like to keep our list memberships as much as possible in sync with our data source and minimizing the wait time for sync.
The text was updated successfully, but these errors were encountered: