Skip to content

Commit

Permalink
Cpu docker tcmalloc (dmlc#5969)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-sizov authored and DominikaJedynak committed Mar 12, 2024
1 parent 7b537e4 commit e258b89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docker/Dockerfile.ci_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ RUN bash /install/ubuntu_install_core.sh
COPY install/ubuntu_install_build.sh /install/ubuntu_install_build.sh
RUN bash /install/ubuntu_install_build.sh

# tcmalloc
RUN apt-get install -y libgoogle-perftools4
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4:$LD_PRELOAD

# python
COPY install/ubuntu_install_conda.sh /install/ubuntu_install_conda.sh
RUN bash /install/ubuntu_install_conda.sh
Expand Down
10 changes: 10 additions & 0 deletions tutorials/cpu/cpu_best_practises.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
is to turn off hyperthreading.
Turning off the hyper threading feature can be done at BIOS [#f1]_ or operating system level [#f2]_ [#f3]_ .
Alternative memory allocators
---------------------------
Alternative memory allocators, such as *tcmalloc*, might provide significant performance improvements by more efficient memory usage, reducing overhead on unnecessary memory allocations or deallocations. *tcmalloc* uses thread-local caches to reduce overhead on thread synchronization, locks contention by using spinlocks and per-thread arenas respectively and categorizes memory allocations by sizes to reduce overhead on memory fragmentation.
To take advantage of optimizations *tcmalloc* provides, install it on your system (on Ubuntu *tcmalloc* is included in libgoogle-perftools4 package) and add shared library to the LD_PRELOAD environment variable:
.. code-block:: shell
export LD_PRELOAD=/lib/x86_64-linux-gnu/libtcmalloc.so.4:$LD_PRELOAD
OpenMP settings
---------------------------
Expand Down

0 comments on commit e258b89

Please sign in to comment.