-
Notifications
You must be signed in to change notification settings - Fork 1
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
Uploading job list is extremely slow #115
Comments
I haven't experienced this actually! For me this is quite fast, even for larger files. |
Ok, so one question is does that depend on the number of participants? is the uploading creating jobs lists and session data, etc before assigning participants? |
I have also never experienced this, but of course I've never worked with a database that's as populated as the one of @nclaidiere. |
I am testing this now on the server of @nclaidiere and I can confirm that this is really slow, about 30 seconds for a table with 50 rows and 2 columns. (Whereas otherwise the server is fairly snappy.) I suspect that |
Did some research into this, after I also experienced bad performance during an automated test run of a study. During that run, each query took about two seconds (according to the OpenSesame console), while for @smathot executing was in millisecond domain (#92 (comment))
There are also some proposed solutions for which varying degrees of success are reported:
I'll see if I have time to play around with these soon and see if they have any effect. If none of these work, we can also try to:
|
That does sound likely. That being said, uploading is also slow on servers for which the other queries go very fast. |
So, the culprit lays in Study.js in function If there are many job entries in the uploaded job file the following loop does an unholy amount of database requests that slows down the whole upload procedure: for (const [i, row] of Object.entries(jsonData)) {
const job = await this.jobs().create({
position: parseInt(i) + 1
}, trx)
await job.variables().attach(Object.keys(varTable), (record) => {
record.value = row[varTable[record.variable_id]]
}, trx)
} It has been difficult for me to improve speed in this loop due to:
So far I reached an improvement of around half the time by simply wrapping the for loop with Maybe this is already enough. If not I have to revisit this issue and probably have to try to refactor the database scheme. |
Thanks for this!
Why don't you try uploading a list of say 1000 rows? If this works within a reasonable time frame, then that's ok. Some background: Once we've refactored the database as described under #155 then it is no longer necessary to be able to upload extremely long job lists of tens of thousands of rows. The reason for such long lists would be to implement repeating trials through this route, rather than resetting job states, to avoid triggering database issues. This means that our goal is now to make uploading of regular-sized lists fast enough so that it doesn't significantly impair usability. How long does 1000 rows take for you? |
What would you consider a reasonable time frame here? And is the content of the job file any important. I currently use a simple job file with entries like:
With this data it takes the following to upload a job file:
But those times aren't much different to how it was before.
I'm actually on #155 now and try to think about a suitable database schema. I thought #155 is about refactoring the schema for the tables that store the resulting job data, namely table job_states that has the field data of type JSON that contains the result data. But the jobs that are uploaded are held in different tables, namely jobs, job_variable, and variables. I made a visualization of the database schema mostly for my own understanding.
I assume that a refactoring of the job result tables would have no impact of the job tables and therefore no impact on the upload times that this ticket is about. Am I assuming right? Maybe my confusion stems from the word 'trial', that does not exist in the database schema. Can you maybe define 'trial' for me again? Is it equal to a job result? Also, maybe we should continue the discussion in #155. |
Those times are reasonable, but don't correspond to what @nclaidiere experienced on their server. This may be because the performance of MySQL is very different in their environment, which is a Windows system running Docker. What kind of environment are you using to test this?
That is correct.
Yes. In most experiments, a trial would equal a job. And the result on a trial would equal a job result. So you can treat them as synonymous for this purpose. |
I use my Linux laptop with 32GB memory and a good CPU. Maybe the MySQL container in the production setup has some constrains. With Docker one can limit the resources that Docker gives each container. Or the overall host doesn't have much resources. Do you know the numbers of the production system? Another reason are the simple job data I used with just two columns. I did a new test, this time with 11 columns:
and it took longer:
If Nicolas has even more complex job data it can take even longer. Ah, now I re-read the Nicolas' original statement: "Uploading job list is extremely slow, about 3 mins for a 5kb csv file (I stopped counting when I had to upload a 10k trial list, I did it overnight but I think it was more than 1h).". My job data files' size from today's test are 76kB and 769kB. So, it is substantially faster on my system. I have three ideas for the cause:
So first we need some help from @nclaidiere: Can you please give us the metrics for memory (free and used), disk (free and used), and CPU on the production system? Are there other applications running on the host? And can you please check if the binary log is activated on the MySQL? And last, do you impose limits on MySQL docker container? |
Ok, @nclaidiere we'll wait for your input on this. |
Hi, I am back from a break. I did some tests, on my windows laptop a 1000 rows x 10 columns job list takes 1 mins to upload, on the now more powerful linux server (128GB RAM, Intel® Xeon(R) Silver 4216 CPU @ 2.10GHz × 64) it takes about 27 minutes. Can you please give us the metrics for memory (free and used), disk (free and used), and CPU on the production system? Are there other applications running on the host? And can you please check if the binary log is activated on the MySQL? And last, do you impose limits on MySQL docker container? I m not sure but I have a feeling this also depends on the number of participants, 6 on the laptop, 36 on the server. If that is the case, then it is a problem since the number of participants can easily increase in the order of a few 1000s. Hope this helps! |
Hi guys,
This makes me remember that from a certain version WSL2 (on which Docker is running) Windows has started to impose a memory restriction on the linux environment. It can only use max 8GB of system memory by default.
You can alter this setting by placing a .wslconfig file in your user directory (on Windows! E.g C:\Users\Someone) with the following contents:
…------
# Settings apply across all Linux distros running on WSL 2
[wsl2]
# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=16GB
------
My machine has 32GB of RAM so I gave it half here, but you can give it more of all of your system memory if the main job of the machine is to run omm-server
________________________________
From: Nicolas Claidiere ***@***.***>
Sent: Monday, July 15, 2024 8:59 AM
To: open-cogsci/omm-server ***@***.***>
Cc: Daniel Schreij ***@***.***>; Assign ***@***.***>
Subject: Re: [open-cogsci/omm-server] Uploading job list is extremely slow (Issue #115)
Hi, I am back from a break.
I did some tests, on my windows laptop a 1000 rows x 10 columns job list takes 1 mins to upload, on the now more powerful linux server (128GB RAM, Intel® Xeon(R) Silver 4216 CPU @ 2.10GHz × 64) it takes about 27 minutes.
Can you please give us the metrics for memory (free and used), disk (free and used), and CPU on the production system?
Memory (RAM, DD) is largely free > 80%.
Are there other applications running on the host?
Nope, it is used only for this
And can you please check if the binary log is activated on the MySQL?
Binlog is activated but i purge the logs very quickly, this has been the source of many probems. Here is the relevant section of docker-compose:
services:
mysql:
container_name: mysql
image: 'mysql:8'
command: --sort_buffer_size=1G
restart: always
ports:
- 3306:3306
volumes:
- mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 4D#BF_RPtrQ3Q2n=VuNR!k5WvhLsmB#8
MYSQL_DATABASE: omm
MYSQL_USER: omm
MYSQL_PASSWORD: ***@***.***+md6wZ_hsA=Qz52DSm
command:
- --sort_buffer_size=5M
- --innodb_redo_log_capacity=1073741824
- --binlog_expire_logs_seconds=86400
And last, do you impose limits on MySQL docker container?
I don't think so, hence the usage of all the available memory when the binlogs are not purged.
I m not sure but I have a feeling this also depends on the number of participants, 6 on the laptop, 36 on the server. If that is the case, then it is a problem since the number of participants can easily increase in the order of a few 1000s.
Hope this helps!
—
Reply to this email directly, view it on GitHub<#115 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAFIHFHJG2AMPETJCMCWMULZMNXMXAVCNFSM5TP2CQQKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRSG44DCNRXGI3Q>.
You are receiving this because you were assigned.Message ID: ***@***.***>
|
Uploading job list is extremely slow, about 3 mins for a 5kb csv file (I stopped counting when I had to upload a 10k trial list, I did it overnight but I think it was more than 1h).
The text was updated successfully, but these errors were encountered: