Linux

不同使用者的執行時間不同

  • December 26, 2012

我正在由另一個受限使用者執行簡單R的工作。root執行時間明顯不同。問題的根源是什麼?

更多的資訊

這是我比較執行時間的方式:

# time /share/binary/R/bin/R CMD BATCH s1n\=50.R

real    0m0.278s
user    0m0.217s
sys 0m0.032s
# su john
$ time /share/binary/R/bin/R CMD BATCH s1n\=50.R

john使用者下執行需要很長時間並且永遠不會完成!perf在這些間隔期間的輸出是:

  PerfTop:     906 irqs/sec  kernel:19.3%  exact:  0.0% [1000Hz cycles],  (all, 8 CPUs)
-------------------------------------------------------------------------------------------------------------------------------------------------------------

            samples  pcnt function                      DSO
            _______ _____ _____________________________ _______________________________

             598.00 14.5% __GI_vfprintf                 /lib64/libc-2.12.so            
             194.00  4.7% intel_idle                    [kernel.kallsyms]              
             176.00  4.3% read_hpet                     [kernel.kallsyms]              
             170.00  4.1% bcEval                        /usr/local/R/lib64/R/bin/exec/R
             141.00  3.4% ___printf_fp                  /lib64/libc-2.12.so            
             138.00  3.4% __strchrnul                   /lib64/libc-2.12.so            
             121.00  2.9% Rf_cons                       /usr/local/R/lib64/R/bin/exec/R
             120.00  2.9% R_gc_internal                 /usr/local/R/lib64/R/bin/exec/R
              91.00  2.2% _IO_default_xsputn_internal   /lib64/libc-2.12.so            
              88.00  2.1% Rf_allocVector                /usr/local/R/lib64/R/bin/exec/R
              84.00  2.0% _IO_file_xsputn_internal      /lib64/libc-2.12.so            
              82.00  2.0% scientific                    /usr/local/R/lib64/R/bin/exec/R
              72.00  1.7% MatrixSubset                  /usr/local/R/lib64/R/bin/exec/R
              71.00  1.7% duplicate1                    /usr/local/R/lib64/R/bin/exec/R
              68.00  1.7% floor                         /lib64/libm-2.12.so            
              64.00  1.6% __strcmp_sse42                /lib64/libc-2.12.so            
              53.00  1.3% Rf_findVarInFrame3            /usr/local/R/lib64/R/bin/exec/R
              53.00  1.3% Rf_protect                    /usr/local/R/lib64/R/bin/exec/R
              50.00  1.2% _IO_str_init_static_internal  /lib64/libc-2.12.so            
              50.00  1.2% Rf_eval                       /usr/local/R/lib64/R/bin/exec/R
              43.00  1.0% Rf_formatReal                 /usr/local/R/lib64/R/bin/exec/R
              43.00  1.0% Rf_matchArgs                  /usr/local/R/lib64/R/bin/exec/R
              41.00  1.0% _int_malloc                   /lib64/libc-2.12.so            
              36.00  0.9% _itoa_word                    /lib64/libc-2.12.so            
              33.00  0.8% __ieee754_log                 /lib64/libm-2.12.so            
              31.00  0.8% Rf_EncodeReal                 /usr/local/R/lib64/R/bin/exec/R
              29.00  0.7% Rf_mkPROMISE                  /usr/local/R/lib64/R/bin/exec/R
              29.00  0.7% do_bind                       /usr/local/R/lib64/R/bin/exec/R
              28.00  0.7% Rf_install                    /usr/local/R/lib64/R/bin/exec/R
              27.00  0.7% __vsnprintf                   /lib64/libc-2.12.so            
              27.00  0.7% _IO_no_init                   /lib64/libc-2.12.so            
              23.00  0.6% _IO_old_init                  /lib64/libc-2.12.so            
              22.00  0.5% __GI__nss_files_parse_servent /lib64/libnss_files-2.12.so    
              22.00  0.5% Rconn_printf                  /usr/local/R/lib64/R/bin/exec/R
              22.00  0.5% finite                        /lib64/libm-2.12.so            
              22.00  0.5% findVarLocInFrame             /usr/local/R/lib64/R/bin/exec/R
              21.00  0.5% Rf_getAttrib                  /usr/local/R/lib64/R/bin/exec/R

我懷疑ulimit和``磁碟配額. After disabling the disk quota, the problem is still exist. Unfortunately, limits are equal underand約翰. Here is the output ofulimit -a`(感謝@Eric DANNIELO):

# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 127383
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
# su john
$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 127383
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

作業系統:CentOS 6.2

硬體:Intel Core-i7 16GB RAM

先感謝您!

我不確定它是否相關,但你應該真正使用su - john而不是su john: 那樣它將呼叫一個乾淨的登錄 shell。請檢查,這樣做,ulimit -a現在可能會顯示一些相關的差異嗎?

另一件事:使用strace -f R而不是strace R這樣當它呼叫子程序時,strace 也會跟踪該子程序並準確顯示該子程序的掛起位置。

引用自:https://serverfault.com/questions/460595