question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optimize byteplay

See original GitHub issue

Currently byteplay is 50% of the view loading time which accounts for about 25-30% of total app start time.

Cumulative time

02-06 20:14:46.641 7734-7751/com.codelv.thermostat I/pybridge:          

349319 function calls (343557 primitive calls) in 3.937 seconds

    Ordered by: cumulative time

    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.001    0.001    3.948    3.948 /data/user/0/com.codelv.thermostat/assets/python/main.py:36(main)
        1    0.000    0.000    3.205    3.205 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/app.py:131(start)
        1    0.000    0.000    3.205    3.205 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/loop.py:266(start)
        1    0.000    0.000    3.205    3.205 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/twisted/internet/base.py:1241(run)
        1    0.000    0.000    3.204    3.204 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/twisted/internet/base.py:1246(mainLoop)
        13    0.001    0.000    1.722    0.132 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/twisted/internet/base.py:839(runUntilCurrent)
        12    0.000    0.000    1.480    0.123 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/twisted/internet/epollreactor.py:206(doPoll)
        12    1.477    0.123    1.477    0.123 {method 'poll' of 'select.epoll' objects}
        1    0.000    0.000    1.203    1.203 /data/user/0/com.codelv.thermostat/assets/python/main.py:55(load_view)
        1    0.000    0.000    1.035    1.035 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/import_hooks.py:124(load_module)
        1    0.003    0.003    1.019    1.019 /data/user/0/com.codelv.thermostat/assets/python/view.enaml:0()
        462    0.008    0.000    0.684    0.001 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/compiler_helpers.py:548(run_operator)
        1    0.000    0.000    0.657    0.657 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/android/app.py:71(__init__)
        1    0.000    0.000    0.657    0.657 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/app.py:116(__init__)
        1    0.000    0.000    0.655    0.655 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/app.py:213(init_error_handler)
        1    0.000    0.000    0.655    0.655 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/app.py:91(_default_loop)
        1    0.000    0.000    0.655    0.655 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/loop.py:33(default)
        1    0.001    0.001    0.647    0.647 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/loop.py:216(available)
        1    0.000    0.000    0.644    0.644 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/twisted/internet/reactor.py:32(<module>)
        1    0.001    0.001    0.643    0.643 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/twisted/internet/default.py:10(<module>)
        5    0.000    0.000    0.511    0.102 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/app.py:354(process_events)
        5    0.000    0.000    0.511    0.102 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/app.py:366(handle_event)
        469    0.083    0.000    0.510    0.001 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/byteplay.py:646(to_code)
        107    0.003    0.000    0.393    0.004 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/operators.py:185(op_subscribe)
        107    0.003    0.000    0.390    0.004 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/operators.py:73(gen_tracer)
        1

By internal time

02-06 20:14:47.509 7734-7751/com.codelv.thermostat I/pybridge:          

349319 function calls (343557 primitive calls) in 3.937 seconds
                                                               
            Ordered by: internal time
        
            ncalls  tottime  percall  cumtime  percall filename:lineno(function)
                12    1.477    0.123    1.477    0.123 {method 'poll' of 'select.epoll' objects}
             53159    0.095    0.000    0.096    0.000 {isinstance}
               469    0.083    0.000    0.510    0.001 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/byteplay.py:646(to_code)
           275/274    0.074    0.000    0.169    0.001 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/atom/atom.py:176(__new__)
             10245    0.070    0.000    0.133    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/byteplay.py:473(get_next_stacks)
               469    0.056    0.000    0.291    0.001 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/byteplay.py:439(_compute_stacksize)
               469    0.053    0.000    0.090    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/byteplay.py:319(from_code)
              5884    0.051    0.000    0.185    0.000 {method 'extend' of 'list' objects}
         1302/1301    0.049    0.000    0.051    0.000 {built-in method __new__ of type object at 0x98dfff80}
                 1    0.048    0.048    0.051    0.051 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/parse_tab/parsetab.py:4(<module>)
                 5    0.039    0.008    0.039    0.008 {method 'read' of 'file' objects}
             15969    0.037    0.000    0.062    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/byteplay.py:231(isopcode)
            315/66    0.037    0.000    0.101    0.002 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/sre_parse.py:395(_parse)
                13    0.030    0.002    0.040    0.003 {imp.load_dynamic}
         8273/8258    0.027    0.000    0.095    0.000 {getattr}
               462    0.026    0.000    0.027    0.000 {method 'pack' of 'msgpack._packer.Packer' objects}
            642/62    0.026    0.000    0.064    0.001 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/sre_compile.py:64(_compile)
           376/375    0.025    0.000    0.102    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/zope/interface/interface.py:222(changed)
               618    0.025    0.000    0.123    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enamlnative/core/bridge.py:170(__call__)
               462    0.023    0.000    0.050    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/msgpack/__init__.py:41(packb)
              3472    0.022    0.000    0.026    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/sre_parse.py:193(__next)
              1831    0.021    0.000    0.021    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/expression_engine.py:101(copy)
                11    0.020    0.002    0.026    0.002 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/collections.py:293(namedtuple)
             11848    0.020    0.000    0.020    0.000 {method 'append' of 'array.array' objects}
              2170    0.018    0.000    0.024    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/byteplay.py:668(index)
                22    0.017    0.001    0.096    0.004 {__import__}
       23203/22849    0.017    0.000    0.017    0.000 {len}
              1854    0.016    0.000    0.016    0.000 {zip}
              4227    0.016    0.000    0.018    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/byteplay.py:167(getse)
              3159    0.016    0.000    0.019    0.000 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/zope/interface/interface.py:518(__hash__)
            550/64    0.016    0.000    0.059    0.001 /home/jrm/.local/share/python-for-android/build/python-installs/enaml-native/enaml/core/comp

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
frmdstryrcommented, Mar 17, 2018

Sorry not yet. Will let you know when I start it.

0reactions
MatthieuDartiailhcommented, Oct 16, 2018

@frmdstryr did you figure out why the cache is not used ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Comparison with byteplay and codetransformer - bytecode
The peephole optimizer has strong requirements on the control flow: an optimization must not modify two instructions which are part of two different...
Read more >
byteplay/byteplay3.py at master · tallforasmurf ... - GitHub
Automatically exported from code.google.com/p/byteplay - byteplay/byteplay3.py at master ... optimized = (STORE_NAME not in opcodes and.
Read more >
byteplay - PyPI
byteplay lets you convert Python code objects into equivalent objects which are easy to play with, and lets you convert those objects back...
Read more >
modifying python bytecode - Stack Overflow
Alas the code format has changed between Python versions 1.3, 1,5, 2.0, 3.0, 3.8, and 3.10. And by the way so has the...
Read more >
Mailman 3 Exposing flat bytecode representation to optimizers ...
[^4] Just moving the optimize one step earlier in the chain solves more than ... we'd actually want something like `byteplay` builtin even...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found