The program blocks, but NOT when it goes through strace
I am doing server side rendering with wkhtmltoimage and every launch is blocked at "88% load" for 1-2 minutes. I decided to debug what was happening through strace, but in a completely strange twist, the program did NOT lock. I found this completely repeatable and consistent. Why would the fear of making the program faster, when by all rights the program should be slower ?!
Run without strace:
user@server:~/public_html/shapes$ time wkhtmltoimage --disable-smart-width --width 970 --format jpg '[THE URL]' '[THE PATH].jpg'
Loading page (1/2)
Rendering (2/2)
Done
real 1m45.724s
user 1m42.887s
sys 0m0.623s
Running with strace:
user@server:~/public_html/shapes$ time strace wkhtmltoimage --disable-smart-width --width 970 --format jpg '[THE URL]' '[THE PATH].jpg'
execve("/usr/local/bin/wkhtmltoimage", ["wkhtmltoimage", "--disable-smart-width", "--width", "970", "--format", "jpg", "[THE URL]"..., "[THE PATH]"...], [/* 21 vars */]) = 0
brk(0) = 0x311a000
...
exit_group(0) = ?
+++ exited with 0 +++
real 0m6.526s
user 0m0.582s
sys 0m0.377s
The server is closed, so I edited the URL and PATH, but otherwise the output will be correct. Also both runs produce correct output and I have cleaned up the temp files to ensure this is not a caching issue. I did these runs 10 times each to ensure that this is not a random artifact, but it happens in sequence. SO the only logical conclusion is that strace somehow changes the behavior of wkhtmltoimage, and I was really hoping someone would tell me. If I knew why strace is forcing the program not to block, I could find a solution.
Here's the hanging process:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
772 sigapp 20 0 1485600 45760 14524 R 99.8 2.2 0:57.02 wkhtmltoimage
As root, I can attach to the dangling image with strace -p $(pidof wkhtmltoimage)
, and the result is:
gettimeofday({1436692542, 446246}, NULL) = 0
gettimeofday({1436692542, 556958}, NULL) = 0
gettimeofday({1436692542, 557161}, NULL) = 0
gettimeofday({1436692542, 659238}, NULL) = 0
gettimeofday({1436692542, 771381}, NULL) = 0
gettimeofday({1436692542, 771686}, NULL) = 0
gettimeofday({1436692542, 875783}, NULL) = 0
gettimeofday({1436692542, 987490}, NULL) = 0
gettimeofday({1436692542, 987781}, NULL) = 0
gettimeofday({1436692543, 84764}, NULL) = 0
...
System: Linux Server 3.13.0-30-generiC # 55-Ubuntu SMP Fri Jul 4 21:40:53 UTC 2014 x86_64 x86_64 x86_64 GNU / Linux (runs on 2 Xen guest machines)
Software: wkhtmltoimage 0.12.2.1 (with fixed qt) <- installed from official site via .deb file
I read this but not sure if this is relevant: Hoon processes are resumed if they are attached to strace
UPDATE:
Tried with another program webkit2pdf
and also saw locks. This time the strace output is different. Both programs use webkit .:
root@server:~# strace -p `pidof webkit2pdf`
Process 4699 attached
restart_syscall(<... resuming interrupted call ...>
On successful launch, strace wkhtmltoimage ...
I can see similar calls, but not as often as many preceded mmap:
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f9dbbbc1000
gettimeofday({1436696839, 361942}, NULL) = 0
gettimeofday({1436696839, 362254}, NULL) = 0
gettimeofday({1436696839, 362505}, NULL) = 0
gettimeofday({1436696839, 362787}, NULL) = 0
gettimeofday({1436696839, 363172}, NULL) = 0
gettimeofday({1436696839, 363568}, NULL) = 0
gettimeofday({1436696839, 363913}, NULL) = 0
mmap(NULL, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f9db5000000
gettimeofday({1436696839, 364701}, NULL) = 0
mmap(NULL, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f9db4ff9000
gettimeofday({1436696839, 365612}, NULL) = 0
gettimeofday({1436696839, 365956}, NULL) = 0
So the pvg comment below is most likely a blocking mechanism for setAttribute
working correctly in strace
, and not working properly.
source to share
No one has answered this question yet
See similar questions:
or similar: