Parallel Garbage Collector - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Home : Support : Online Help : System : Information : Updates : Maple 17 : Parallel Garbage Collector

Parallel Garbage Collector

One of the core components of Maple's engine is the garbage collector. The garbage collector is responsible for finding and reclaiming memory that is no longer needed by the evaluation engine. In Maple 17, the garbage collector is capable of taking advantage of multiple processors to perform its job more quickly. As the garbage collector is used continuously as Maple runs, this speed up helps all users, not just those running parallel algorithms.

 • The garbage collector in Maple 17 is capable of running multiple threads to take advantage of multiple cores.  This can speed up the collector significantly.  Although the collector is only responsible for a fraction of Maple's total running time, this can still lead to running times reduced by up to 10%.  These speed ups require no changes to user code.
 • There are 2 kernelopts that can control the parallel collector.
 – gcmaxthreads controls the maximum number of threads that the parallel garbage collector will use.
 – gcthreadmemorysize controls how many threads Maple will use for a collection.  The number of bytes allocated is divided by the value assigned to gcthreadmemorysize to determine the number of threads.

The following example shows the speed up in the garbage collector from using multiple threads. Note that this may take a few minutes to run depending on your particular machine specifications.

 > $\mathrm{restart}$
 >
 >
 >
 > $\mathrm{kernelopts}\left(\mathrm{gcmaxthreads}=1\right):$
 > $\mathrm{kernelopts}\left(\mathrm{gcmaxthreads}=2\right):\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$$\mathrm{t1}\left[2\right]≔\mathrm{time}\left[\mathrm{real}\right]\left(p\left(\right)\right):$
 > $\mathrm{kernelopts}\left(\mathrm{gcmaxthreads}=4\right):\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$$\mathrm{t1}\left[4\right]≔\mathrm{time}\left[\mathrm{real}\right]\left(p\left(\right)\right):$
 > $\mathrm{Statistics}:-\mathrm{ColumnGraph}\left(\left[\mathrm{t1}[1],\mathrm{t1}[2],\mathrm{t1}[4]\right],\mathrm{datasetlabels}=\left["One Thread","Two Threads","Four Threads"\right],\mathrm{labels}=\left["","Seconds"\right],\mathrm{gridlines}\right)$

The garbage collection algorithm only comprises a small amount of the total Maple running time, so the speed up will not be this significant for real Maple computations.  The following example shows a more realistic situation.

 > $\mathrm{restart}$
 > $d:=\left[\mathrm{seq}\left(\mathrm{randpoly}\left(\left[x,y,z\right],\mathrm{dense},\mathrm{degree}=12\right),i=1..10000\right)\right]:$
 >
 > $\mathrm{kernelopts}\left(\mathrm{gcmaxthreads}=1\right):$
 > $\mathrm{t2}\left[1\right]≔\mathrm{time}\left[\mathrm{real}\right]\left(f\left(\right)\right):$
 >
 > $\mathrm{kernelopts}\left(\mathrm{gcmaxthreads}=2\right):$
 > $\mathrm{t2}\left[2\right]≔\mathrm{time}\left[\mathrm{real}\right]\left(f\left(\right)\right):$
 >
 > $\mathrm{kernelopts}\left(\mathrm{gcmaxthreads}=4\right):$
 > $\mathrm{t2}\left[4\right]≔\mathrm{time}\left[\mathrm{real}\right]\left(f\left(\right)\right):$
 >
 > $\mathrm{Statistics}:-\mathrm{ColumnGraph}\left({\left[\mathrm{t2}\left[1\right],\mathrm{t2}\left[2\right],\mathrm{t2}\left[4\right]\right]}_{},\mathrm{datasetlabels}=\left["One Thread","Two Threads","Four Threads"\right],\mathrm{labels}=\left["","Seconds"\right],\mathrm{gridlines}\right)$