UniTime / unitime

Comprehensive University Timetabling System
http://www.unitime.org
Apache License 2.0
267 stars 161 forks source link

Expand more memory and speed up timetabling process #164

Closed Animeakihabara closed 5 months ago

Animeakihabara commented 6 months ago

When i load about 2000 variables need to be scheduled. I face with problem, It seem like the memory usage are limited at about 2MB and when the memory usage got peak, it run too slow and even it show the error message 500 ... So how can I adding more memory using for scheduling process.

Anw, I have try the instruction installation for Mac in step 3, which have a command: export JAVA_OPTS="${JAVA_OPTS} -Xmx2g -Djava.awt.headless=true" for adding more memory, when I change it to 4 or 8 and run the command: chmod +x ~/Downloads/apache-tomcat-8.5.95/bin/*sh and when I run startup.sh, it show that: bad interpreter: Operation not permitted line 60: /Users/luong/Downloads/apache-tomcat-8.5.95/bin/catalina.sh: Undefined error: 0

so how can I adding more memory to run more efficiency and is there any other way to make it run faster.

tomas-muller commented 6 months ago

Do you see any OutOfMemorry errors in the Tomcat log?

You can verify that the -Xmx parameter is being used by doing ps Aww | grep catalina in the terminal. The -Xmx parameter tell Java the limit on how much memory it can allocate (so, -Xmx2g means it can use up to 2 GB of RAM).

You can also see how much memory the Tomcat/UniTime has available by checking the Administration > Solver > Manager Solvers page; see the Available Memory in the bottom table (Available Servers).

Animeakihabara commented 6 months ago

I have deployed in a server and expand more memory before starting tomcat, I try some different metrics to checkout the efficiency, I see a problem that, when I using about 60gb Ram it run almost 100% of CPU to archive about 10-20 it/sec, but when I using about 120gb ram it just run about 30-50% of CPU to archive about 60-90 it/sec. I knew that the speed still depend on the CPU so how can i using like almost 100% CPU and still using 120Gb ram to running timetabling in faster time.

tomas-muller commented 6 months ago

The iterations per second may not be a very good metric as it will strongly depend on the problem (e.g., how large the domains are) and in what phase the solver is. It may also depend on whether the solver can fit in memory, as if there is not enough memory, the garbage collection will run more often (possibly also consuming a lot of CPU) while bringing the performance down. The amount of memory needed greatly depends on the problem, if there are a lot of classes, and especially if their domains are large. For instance, if each class has 50+ possible times, as it could start every half hour each of the days; and there are no room restrictions, so there are hundreds of large enough classrooms available, the problem size will swell. Also the solver will also run slowly because it has to go over thousands of possible placements for each class. But it is rare for the problem to take more than 10 GB even for large institutions.

That said, when the solver can fit the problem in memory, it is all in-memory computation and it will max out all the CPU cores it is given, depending on the number of solver threads it is allowed to take. Each solver thread can take up to 100%, especially when there are only one or two solver threads, so there does not need to be a lot of coordination. You can see the number of threads a solver is using on the Administration > Solver > Manager Solvers page; see the Cores column. For course and examination timetabling, usually one core is enough (multiple threads/cores will not create a much better solution when the solver is running for a fixed time). On the other hand, the student scheduling solver can benefit greatly from using as many cores as possible as individual student schedules usually only collide when they fight for the remaining spots in a class.

The number of solver threads can be changed by the Parallel.NrSolvers solver parameter. For course timetabling, it defaults to 1/2 of the available cores; however, when the on-fly student sectioning is enabled, it is limited to 1. This is controlled by the "Enable on fly sectioning (if enabled, students will be resectioned after each iteration)" parameter.

The Parallel.NrSolvers parameter is not created by default; it can be created using the Administration > Solver > Parameters page, using the Add Parameter button. Here is an example for the course timetabling solver:

image

Animeakihabara commented 6 months ago

What about using GPU instead of CPU, I don't see any mention before about using GPU

tomas-muller commented 6 months ago

UniTime does not use GPU at the moment. Also, there are no plans of using GPUs in the near future.

tomas-muller commented 5 months ago

Closing the issue. Please let me know if the quest has not been answered.