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

Performance issue when fork on linux #379

Closed
diandianliu opened this issue Jan 10, 2019 · 4 comments
Closed

Performance issue when fork on linux #379

diandianliu opened this issue Jan 10, 2019 · 4 comments
Assignees
Labels
question sighting Suspicious library behavior. Should be promoted to a bug when confirmed

Comments

@diandianliu
Copy link

hi
I have created a libmxnet.so use USE_MKLDNN=1 in config.mk file.
the use time is 290ms per image is faster than before( 3800ms not use MKLDNN).

But I use fork to run the process the time is 1300ms per image the time is too long.

cpu useage:CPUS(32),not set OMP_NUM_THREADS use default
no fork :1600%CPU
fork:100%CPU ;

in fork case, when I set OMP_NUM_THREADS more large,the cpu usage is more large too ,but the speed is not improve.

why the Performance is so slow when use fork?

@emfomenk
Copy link

Hi @diandianliu,

Seems quite similar to this StackOverflow thread.

Could you please try resetting the mask in the child process?

cpu_set_t cpuset;
CPU_ZERO(&cpuset);
for (int i = 0; i < nthr; ++i) CPU_SET(i, &cpuset);
sched_setaffinity(0, sizeof(cpuset), &cpuset);

Alternatively, if you set KMP affinity like KMP_AFFINITY=granularity=fine,compact, try omitting it (just to check if this helps).

@emfomenk emfomenk self-assigned this Jan 10, 2019
@emfomenk emfomenk added question sighting Suspicious library behavior. Should be promoted to a bug when confirmed labels Jan 10, 2019
@TaoLv
Copy link
Contributor

TaoLv commented Jan 10, 2019

Hi @diandianliu Not sure what does "use fork to run the process" mean. But I guess it relates to the discussion here:
apache/mxnet#13606 (comment)
and
apache/mxnet#13593

@rsdubtso
Copy link

This does not seem to be directly related to MKL-DNN, but rather to the way OpenMP CPU affinity interacts with fork(), so I am inclined to close this issue. Keeping open for a couple of days...

@diandianliu
Copy link
Author

Hi @diandianliu,

Seems quite similar to this StackOverflow thread.

Could you please try resetting the mask in the child process?

cpu_set_t cpuset;
CPU_ZERO(&cpuset);
for (int i = 0; i < nthr; ++i) CPU_SET(i, &cpuset);
sched_setaffinity(0, sizeof(cpuset), &cpuset);

Alternatively, if you set KMP affinity like KMP_AFFINITY=granularity=fine,compact, try omitting it (just to check if this helps

thanks ,i find the quest , when use fork , mkl can only use one thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question sighting Suspicious library behavior. Should be promoted to a bug when confirmed
Projects
None yet
Development

No branches or pull requests

4 participants