Skip to content

Cache system libraries lookups - #4

Merged
ogrisel merged 1 commit into
joblib:masterfrom
ogrisel:optim-cache-libc
Mar 28, 2019
Merged

ogrisel merged 1 commit into
joblib:masterfrom
ogrisel:optim-cache-libc

Conversation

@ogrisel

@ogrisel ogrisel commented Mar 27, 2019

Copy link
Copy Markdown
Contributor

The lookup to the libc under POSIX is actually dominating the overhead based on a profile report of the benchmark script.

Simply caching this removes most of the overhead:

  • master:
$ python  benchmarks/bench_context_manager_overhead.py --n-calls 300 --import numpy scipy lightgbm
[{'filename_prefixes': ('libopenblas',),
  'internal_api': 'openblas',
  'module_path': '/opt/venvs/py37/lib/python3.7/site-packages/numpy/.libs/libopenblasp-r0-382c8f3a.3.5.dev.so',
  'n_thread': 4,
  'prefix': 'libopenblas',
  'user_api': 'blas',
  'version': '0.3.5.dev'},
 {'filename_prefixes': ('libopenblas',),
  'internal_api': 'openblas',
  'module_path': '/opt/venvs/py37/lib/python3.7/site-packages/scipy/.libs/libopenblasp-r0-8dca6697.3.0.dev.so',
  'n_thread': 4,
  'prefix': 'libopenblas',
  'user_api': 'blas',
  'version': None},
 {'filename_prefixes': ('libiomp', 'libgomp', 'libomp', 'vcomp'),
  'internal_api': 'openmp',
  'module_path': '/usr/lib/x86_64-linux-gnu/libgomp.so.1',
  'n_thread': 4,
  'prefix': 'libgomp',
  'user_api': 'openmp',
  'version': None}]
Overhead per call: 8.523 +/-0.252 ms
  • the branch of this PR:
$ python  benchmarks/bench_context_manager_overhead.py --n-calls 300 --import numpy scipy lightgbm
[{'filename_prefixes': ('libopenblas',),
  'internal_api': 'openblas',
  'module_path': '/opt/venvs/py37/lib/python3.7/site-packages/numpy/.libs/libopenblasp-r0-382c8f3a.3.5.dev.so',
  'n_thread': 4,
  'prefix': 'libopenblas',
  'user_api': 'blas',
  'version': '0.3.5.dev'},
 {'filename_prefixes': ('libopenblas',),
  'internal_api': 'openblas',
  'module_path': '/opt/venvs/py37/lib/python3.7/site-packages/scipy/.libs/libopenblasp-r0-8dca6697.3.0.dev.so',
  'n_thread': 4,
  'prefix': 'libopenblas',
  'user_api': 'blas',
  'version': None},
 {'filename_prefixes': ('libiomp', 'libgomp', 'libomp', 'vcomp'),
  'internal_api': 'openmp',
  'module_path': '/usr/lib/x86_64-linux-gnu/libgomp.so.1',
  'n_thread': 4,
  'prefix': 'libgomp',
  'user_api': 'openmp',
  'version': None}]
Overhead per call: 0.864 +/-0.240 ms

@ogrisel
ogrisel requested a review from tomMoral March 27, 2019 17:10
@codecov

codecov Bot commented Mar 27, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #4 into master will decrease coverage by 0.52%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #4      +/-   ##
==========================================
- Coverage    76.7%   76.17%   -0.53%     
==========================================
  Files           7        7              
  Lines         352      361       +9     
==========================================
+ Hits          270      275       +5     
- Misses         82       86       +4
Impacted Files Coverage Δ
threadpoolctl/_threadpool_limiters.py 76.26% <50%> (-0.99%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e173b31...f8c3869. Read the comment docs.

@tomMoral tomMoral left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was cached when we were using the wrapper and I did not realize it might have an impact on the overhead.
LGTM. thanks @ogrisel for the benchmarking!

@ogrisel
ogrisel merged commit f514e13 into joblib:master Mar 28, 2019
@ogrisel
ogrisel deleted the optim-cache-libc branch March 28, 2019 07:58
@ogrisel

ogrisel commented Mar 28, 2019

Copy link
Copy Markdown
Contributor Author

Merged. I do not understand why the code coverage wasn't 100% on linux. All the tests passe on all the platform and I did not see a codecov upload error. Let's see on master.

@tomMoral

Copy link
Copy Markdown
Contributor

The upload was failing. I fixed this in #5 that I just merged before. Now the coverage should be descent. (~90%)

jeremiedbb added a commit to jeremiedbb/threadpoolctl that referenced this pull request Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants