Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
698 views
in Technique[技术] by (71.8m points)

infinite loop - Webpack constantly needs 30% CPU

Webpack constantly needs 30% CPU.

top

top - 09:53:40 up 29 min,  2 users,  load average: 1.39, 1.94, 1.66
Tasks: 130 total,   2 running,  85 sleeping,   0 stopped,   0 zombie
%Cpu(s):  7.8 us, 18.5 sy,  0.0 ni, 73.3 id,  0.0 wa,  0.0 hi,  0.4 si,  0.0 st
KiB Mem :  2040792 total,   289692 free,  1472500 used,   278600 buff/cache
KiB Swap:  2097148 total,  1839448 free,   257700 used.   381152 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                  
 2959 vagrant   20   0 1466436 645872  12568 R  27.4 31.6   8:00.78 webpack   <<<###########                                                                                                                                                
 2993 vagrant   20   0 1720656 219612  20180 D  18.2 10.8   4:03.88 /home/vagrant/.pyenv/versions/venv3.9.0/bin/python manage.py runserver 8000                                                                              
 2939 vagrant   20   0  917256  64692   8968 S   7.9  3.2   1:55.74 webpack   

ps aux --forest

2760  0.0  0.6 839884 13808 pts/0    Sl+    \_ node /usr/share/yarn/bin/yarn.js watch:hydra
2937  0.0  0.0   4644     0 pts/0    S+     |   \_ /bin/sh -c cd javascript && yarn watch
2940  0.0  0.6 840144 13264 pts/0    Sl+    |       \_ /usr/lib/nodejs/node-v12.16.1/bin/node /usr/share/yarn/bin/yarn.js watch
2958  0.0  0.0   4648     0 pts/0    S+     |           \_ /bin/sh -c STATIC_URL=${STATIC_URL:=/static} webpack --config webpack.vagrant.js --watch
2959 33.7 31.6 1466436 645872 pts/0  Sl+    |               \_ webpack

strace -p 2959

epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 4) = 1
read(16, "1", 1024)      = 8
futex(0x2a73780, FUTEX_WAIT_PRIVATE, 2, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x2a73780, FUTEX_WAKE_PRIVATE, 1) = 0
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 117) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 111) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 110) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 109) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 108) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 103) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 102) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 100) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 97) = 1
read(16, "1", 1024)      = 8
epoll_wait(13, [{EPOLLIN, {u32=16, u64=16}}], 1024, 96) = 1
read(16, "1", 1024)      = 8
futex(0x2a737e8, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x2a73780, FUTEX_WAKE_PRIVATE, 1) = 1

ls -l /proc/2959/fd

lrwx------ 1 vagrant vagrant 64 Jan  6 09:40 0 -> /dev/pts/0
l-wx------ 1 vagrant vagrant 64 Jan  6 09:40 1 -> 'pipe:[25920]'
lr-x------ 1 vagrant vagrant 64 Jan  6 09:40 10 -> 'pipe:[26989]'
l-wx------ 1 vagrant vagrant 64 Jan  6 09:40 11 -> 'pipe:[26989]'
lrwx------ 1 vagrant vagrant 64 Jan  6 09:40 12 -> 'anon_inode:[eventfd]'
lrwx------ 1 vagrant vagrant 64 Jan  6 09:40 13 -> 'anon_inode:[eventpoll]'
lr-x------ 1 vagrant vagrant 64 Jan  6 09:40 14 -> 'pipe:[26990]'
l-wx------ 1 vagrant vagrant 64 Jan  6 09:40 15 -> 'pipe:[26990]'
lrwx------ 1 vagrant vagrant 64 Jan  6 09:40 16 -> 'anon_inode:[eventfd]'
lr-x------ 1 vagrant vagrant 64 Jan  6 09:40 17 -> /dev/null
l-wx------ 1 vagrant vagrant 64 Jan  6 09:40 2 -> 'pipe:[25920]'
lrwx------ 1 vagrant vagrant 64 Jan  6 09:40 3 -> 'anon_inode:[eventpoll]'
lr-x------ 1 vagrant vagrant 64 Jan  6 09:40 4 -> 'pipe:[26987]'
l-wx------ 1 vagrant vagrant 64 Jan  6 09:40 5 -> 'pipe:[26987]'
lr-x------ 1 vagrant vagrant 64 Jan  6 09:40 6 -> 'pipe:[26988]'
l-wx------ 1 vagrant vagrant 64 Jan  6 09:40 7 -> 'pipe:[26988]'
lrwx------ 1 vagrant vagrant 64 Jan  6 09:40 8 -> 'anon_inode:[eventfd]'
lrwx------ 1 vagrant vagrant 64 Jan  6 09:40 9 -> 'anon_inode:[eventpoll]'

How could I find the root of the problem?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Vagrant inotify does not work. Polling is configured.

Webpack checks the files over and over again ...

See: https://www.javascriptstuff.com/webpack-watch-in-vagrant-docker/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...