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

profiling the sh module causes SIGALRM (usually) #454

Open
jakeogh opened this issue Oct 23, 2022 · 0 comments
Open

profiling the sh module causes SIGALRM (usually) #454

jakeogh opened this issue Oct 23, 2022 · 0 comments

Comments

@jakeogh
Copy link

jakeogh commented Oct 23, 2022

I hit this it profiling an application that uses sh to call the rhash command. Seems to be load dependent, long running commands are more likely to trigger it, the demo below triggers the problem 100% of the time. This is my first time using scalene.

$ cat sh_sleep.py ; scalene --cli ./sh_sleep.py 10
#!/usr/bin/env python

import sh  # https://github.com/amoffat/sh

_command = sh.Command('/usr/bin/sleep')
_command = _command.bake(10)
_result = str(_command())
Error in program being profiled:
 

  RAN: /usr/bin/sleep 10

  STDOUT:


  STDERR:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/scalene/scalene_profiler.py", line 1631, in profile_code
    exec(code, the_globals, the_locals)
  File "./sh_sleep.py", line 7, in <module>
    _result = str(_command())
  File "/usr/lib/python3.10/site-packages/sh.py", line 1542, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/usr/lib/python3.10/site-packages/sh.py", line 797, in __init__
    self.wait()
  File "/usr/lib/python3.10/site-packages/sh.py", line 854, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/lib/python3.10/site-packages/sh.py", line 878, in handle_command_exit_code
    raise exc
sh.SignalException_SIGALRM: 

  RAN: /usr/bin/sleep 10

  STDOUT:


  STDERR:

                                         Memory usage: ██ (max:   1.65MB, growth rate: 106%)                                          
                                           ./sh_sleep.py: % of time =   0.00 out of   0.02.                                           
       ╷       ╷       ╷       ╷        ╷       ╷               ╷       ╷                                                             
       │Time   │–––––– │–––––– │Memory  │–––––– │–––––––––––    │Copy   │                                                             
  Line │Python │native │system │Python  │peak   │timeline/%     │(MB/s) │./sh_sleep.py                                                
╺━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
     1 │       │       │       │        │       │               │       │#!/usr/bin/env python                                        
     2 │       │       │       │        │       │               │       │                                                             
     3 │       │       │       │        │       │               │       │import sh  # https://github.com/amoffat/sh                   
     4 │       │       │       │        │       │               │       │                                                             
     5 │       │       │       │        │       │               │       │_command = sh.Command('/usr/bin/sleep')                    
     6 │       │       │       │        │       │               │       │_command = _command.bake(10)                             
     7 │       │       │       │        │       │               │       │_result = str(_command())                                  
     8 │       │       │       │        │       │               │       │                                                             
       ╵       ╵       ╵       ╵        ╵       ╵               ╵       ╵                                                             
Top AVERAGE memory consumption, by line:
(1)     7:     2 MB                                                                                                                    
Top PEAK memory consumption, by line:
(1)     7:     2 MB                                                                                                           


$ uname -a
Linux zbook 6.0.0-gentoo-x86_64 #1 SMP PREEMPT_DYNAMIC Thu Oct 6 15:04:38 MST 2022 x86_64 Intel(R) Core(TM) i7-4910MQ CPU @ 2.90GHz GenuineIntel GNU/Linux

$ $ python --version
Python 3.10.8

$ scalene --version
Scalene version 1.5.13

$ # I also tied git-latest:
$ pip install --user git+https://github.com/plasma-umass/scalene.git
$ # and got the same result
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

No branches or pull requests

1 participant