2

(I know this is probably the most overkilled question but)

I've designed a pretty heavy code/script in python, which yes would have been better implemented in c, but in saying that short of over clocking I would rather prefer to allow as much memory for the actual code to access as possible.

I know I can kill startx which makes my code access resources slightly faster, but are there any other stock applications that I can kill on the raspbian image that could aid in a better performance output, e.g. Xorg?

4
  • 2
    You should concentrate on optimizing your script instead of thinking about killing other programs, because well written python programs can run at almost the same speed as C/C++ code, and sometimes even faster.
    – lenik
    Oct 7, 2014 at 5:28
  • Yeah ive optimised the code left right and centre, and its running a lot better but i just want to see where else i can improve
    – Pariah
    Oct 7, 2014 at 6:05
  • 3
    keep optimizing. maybe rewrite critical parts using a different algorithm. there's no point tweaking the system.
    – lenik
    Oct 7, 2014 at 13:55
  • Well I've pretty much optimised the code as much as humanly possible, could you recommend a compiler because i was about to try to use pyinstaller
    – Pariah
    Oct 7, 2014 at 23:10

3 Answers 3

2

Assuming you have a piece of code that does some processing, and you want it to process more within a given time frame there are certainly things you can do.

1) The most important thing is, of course, to write your code correctly. You say you have optimized the code as much as possible, but try to get a pair of fresh eyes on it. If you don't have a performance expert within reach, you can probably find some here: https://codereview.stackexchange.com/

2) Make sure your machine isn't busy doing something else. Research the command top. Programs you don't want running on your machine, ever, you could remove using (generally) sudo apt-get remove <program>. If you need more memory, specifically, you can sort the top-list with the interactive command M.

3) Give higher priority to you process. Research nice. Be careful not to starve your own process, tough - that is, if your program consumes data provided by another program, and your process has much higher priority, data might not be available in the pace it can me processed.

4) And the obvious answer: get another machine. The pi is not really made to be a fast cruncher - it's a lab board. If you need to get something done quickly, it's simply not the right HW.

1
  • Thanks for the info and sorry about the late reply. I did make my code as efficient as humanly possible but i do now fully understand the limitations of using the pi board as it is more of a lab enviroment.
    – Pariah
    Jul 15, 2015 at 12:09
0

Apart from optimising code & setting nice values, here's a couple of things which you can do to optimise your RPI for performance:

  • disable some services which you don't need to lessen the load (e.g. bluetooth, wifi, avahi, sound, anything you can)
  • update your python version
  • overclock with arm_freq in config.txt
  • install a small (or big) heatsink to bring the temperatures down - not sure how much this actually helps performance
  • update firmware & kernel (check rpi-update which does both)
  • Turn off HDMI
-2

if you only want your thing to work a great thing to do is compile the python vm as a lklm

1
  • 2
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here. Oct 7, 2014 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.