Skip to content
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

Improve DMatrix creation performance in python #10407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Jun 11, 2024

  1. Improve DMatrix creation performance in python

    The xgboost python python package serializes numpy arrays as json.
    This has non trivial overhead for small datasets.
    
    This patch optimizes the specific case where the numpy is already in
    "C" contigous 32-bit floating point format, and has rows*cols<=32768,
    and loads it directly without the json layer.
    xgboost/tests/python/microbench_numpy.py:
    
    Threads  | Rows     | Cols     | Current (sec)   | Optimized (sec) | Ratio
           1 |        1 |     1000 |       0.0001921 |       0.0001703 |        88.6%
           1 |        4 |     1000 |       0.0001689 |       0.0001437 |        85.1%
           1 |       16 |     1000 |       0.0002639 |       0.0002457 |        93.1%
           1 |       64 |     1000 |       0.0006843 |       0.0006719 |        98.2%
           1 |      256 |     1000 |        0.002611 |        0.002655 |       101.7%
           1 |     1024 |     1000 |           0.013 |          0.0126 |        97.0%
           1 |     4096 |     1000 |         0.06081 |          0.0593 |        97.5%
           1 |    16384 |     1000 |          0.2981 |          0.2974 |        99.8%
           2 |        1 |     1000 |       0.0001415 |       0.0001196 |        84.6%
           2 |        4 |     1000 |       0.0002155 |       0.0002003 |        93.0%
           2 |       16 |     1000 |       0.0002137 |        0.000196 |        91.7%
           2 |       64 |     1000 |       0.0005054 |       0.0004855 |        96.1%
           2 |      256 |     1000 |        0.001613 |        0.001687 |       104.6%
           2 |     1024 |     1000 |        0.007743 |        0.008194 |       105.8%
           2 |     4096 |     1000 |         0.03791 |         0.03783 |        99.8%
           2 |    16384 |     1000 |          0.2077 |          0.2037 |        98.1%
           4 |        1 |     1000 |       0.0001374 |       0.0001237 |        90.0%
           4 |        4 |     1000 |       0.0001985 |       0.0001621 |        81.7%
           4 |       16 |     1000 |       0.0002266 |       0.0001988 |        87.7%
           4 |       64 |     1000 |       0.0005175 |       0.0004775 |        92.3%
           4 |      256 |     1000 |         0.00166 |        0.001594 |        96.0%
           4 |     1024 |     1000 |        0.008257 |        0.008097 |        98.1%
           4 |     4096 |     1000 |         0.03492 |          0.0354 |       101.4%
           4 |    16384 |     1000 |          0.1896 |          0.1897 |       100.0%
           8 |        1 |     1000 |       0.0001471 |       0.0001254 |        85.3%
           8 |        4 |     1000 |       0.0003609 |        0.000326 |        90.4%
           8 |       16 |     1000 |       0.0002651 |       0.0002217 |        83.6%
           8 |       64 |     1000 |       0.0003504 |       0.0003064 |        87.5%
           8 |      256 |     1000 |       0.0008264 |       0.0008729 |       105.6%
           8 |     1024 |     1000 |        0.003367 |        0.003127 |        92.9%
           8 |     4096 |     1000 |         0.01932 |         0.01799 |        93.1%
           8 |    16384 |     1000 |          0.1245 |          0.1208 |        97.0%
    arieleizenberg committed Jun 11, 2024
    Configuration menu
    Copy the full SHA
    cdac476 View commit details
    Browse the repository at this point in the history