Raspberry Pi DSI port and GPU performance

Got a hardware problem? ask for help

Raspberry Pi DSI port and GPU performance

Postby evansste » February 22nd, 2017, 7:20 pm

I'm working on a project which requires extreme performance of the Raspberry Pi's graphics capability. My program takes multiple screen shots, and I've noticed that it works slower on the Raspberry Pi, than it does on an obsolete laptop. I'm fairly sure that the screen shots are causing the slowdown, so here's my question. Could I expect better performance if I used a touch display which connects to the Raspberry Pi's DSI port?

So far, I've only run my program while the Pi is connected to a TV via the HDMI port, or the composite port. When using the composite, the screen has a lower resolution (646 x 416). Despite the lower resolution, the screen shots still run relatively slow. The official Raspberry Pi touchscreen display has a resolution of 800 x 480, but it connects via the DSI port. Will the DSI port offer better performance than the HDMI, or composite, ports?

I've never used the DSI port, and know very little about it. If you have a good understanding of the DSI port, and whether or not it should provide better GPU performance, I'd love to hear from you. Would the DSI port be faster for screen shots, or would you expect no difference in performance.

Thanks for your time.
evansste
 
Posts: 102
Joined: October 8th, 2014, 8:19 am

Re: Raspberry Pi DSI port and GPU performance

Postby edugimeno » February 23rd, 2017, 3:40 am

Don't take my answer as "official" as I have never done what you're saying before, but a screenshot doesn't really depend on the physical screen that it's graphic adapter is connected to. It DOES depend on the resolution you have set (which may or may not change automatically, for different screens), but the screen resolution is something you can always change without touching or connecting a real display to any video output

How is your screendump being taken? Have you programmed that function? If so you may be using single byte read/writes instead of blocks which may slow down the process a lot.
edugimeno
 
Posts: 33
Joined: February 5th, 2016, 2:40 am

Re: Raspberry Pi DSI port and GPU performance

Postby bandersnatch » February 23rd, 2017, 3:45 am

Hi,

I'm not an expert on the PI HW architecture but I doubt that changing the external video interface will
have much effect on the screenshot performance.

My guess is that you have an IO bottleneck somewhere.
Are you saving each screenshot immediately to disk (=SSD/SD-CARD/etc.)?
This will always slow you down.....

One possible option is the old memory/speed tradeoff.
You could try pre-allocating 10/20/100 screenshot memory buffers (depending on your available RAM)
and save each screenshot to a different memory buffer during the calculation loops.
You can then save these buffers to disk when the calculations are finished or on a periodic basis.
The main idea is to reduce disk activity to a minimum within the computation-intensive loops...

I hope this helps.

STFB
bandersnatch
 
Posts: 150
Joined: September 17th, 2014, 12:06 pm

Re: Raspberry Pi DSI port and GPU performance

Postby evansste » February 23rd, 2017, 6:20 pm

Thanks, edugimeno and bandersnatch. All of your insight has been very helpful.

Until your posts, I haven't considered the bottleneck as having anything to do with writing to the hard drive (in this case SD card). I'm using the same program which has always been run on a laptop. The laptop wrote all information to the hard drive, and that wasn't a problem in terms of speed. I was using scrot in order to take the screenshots, but have since started using maim. maim allows me to take shots of smaller portions of the screen with ease. However, I don't know the internal workings of their program. I don't know if it's taking an entire screenshot, and then returning a cropped output, or if it's just taking a smaller screenshot (which is what I want). I haven't noticed much of an increase in speed since using maim, so I'm beginning to think that it, too, is taking entire screenshots first. I'm also beginning to wonder whether or not the problem is with the actual function of taking the screenshots, or if its the Octave imread function which reads the information, from the screenshot picture, into RAM.

As edugimeno pointed out, and as I mentioned earlier, you'd think that resolution would play a key role in performance. Fewer pixels should mean less work, which should greatly increase performance. However, I don't see a change in performance when switching pixel resolutions, or even taking portion screenshots. So maybe I'm barking up the wrong tree altogether. All I know is that the process slows down with automated screen interaction, but appears to be just as fast with everything else (This is when comparing the Raspberry Pi to my old laptop).

edugimeno mentioned screendump. This is a function I've never heard of. After doing a quick search, it seems to mean the same thing as taking a screenshot. Other than that, I haven't been able to find anything in terms of an actual function. Am I misunderstanding something?

I've recently ordered a Raspberry Pi 3. It should arrive in the mail within the next few days. I'm currently running this on a Raspberry Pi 2, so it'll be interesting to see if the upgrade makes a noticeable difference.
evansste
 
Posts: 102
Joined: October 8th, 2014, 8:19 am

Re: Raspberry Pi DSI port and GPU performance

Postby edugimeno » February 24th, 2017, 1:10 am

Well you will get a newer and faster processor so it will hopefully help.
Sorry with screendump I was actually refering to screenshot as well, for me (not english native) I thought they were both meaning the same, maybe it was the specific name of the tool we used once with a client and not the general funcionality

Good luck and keep us posted
Eduardo
edugimeno
 
Posts: 33
Joined: February 5th, 2016, 2:40 am

Re: Raspberry Pi DSI port and GPU performance

Postby evansste » February 24th, 2017, 10:55 am

Thanks, Eduardo, for clearing things up concerning "screendump". All that you have said is exactly what I found online. I'll remember that "screendump" and "screenshot" are the same thing.

I did a little test and have learned that maim (the program I'm using to take screenshots), does only take a screenshot of the portion of the screen that I specify. Because of this, my program is as lean, and efficient, as it'll probably ever be. I'm beginning to think that the slowdown is simply due to the Raspberry Pi. Sometimes it hesitates to open new windows, and things like that, so it may have less to do with the actual screenshots, and more to do with the Pi working with the GUI. Sometimes it hesitates, and sometimes it doesn't. Because of this, my best hope really is the better hardware of the Raspberry Pi 3.

I always rated the performance of my program, on the Raspberry Pi, in correlation to how my program ran on my old laptop. However, there are probably more differences, between the two systems, than what I bothered to recognize. My laptop (now dead) was pretty old, and was running Windows XP. I also don't know how much memory it had. It was an old machine, but it may have had more RAM than the Raspberry Pi. So maybe there are other differences which are the cause for varying performance. I just know that it was seen most blatantly with the GUI, and taking screenshots deals mostly with GUI operations.

Once I get my Raspberry Pi 3, I'll update whether or not there's a change in performance. But I definitively know that maim really does only target the portion of the screen that I'm interested in. Taking 10, full-screen, successive screenshots took 26 seconds. When targeting only a 10-by-10 section, 10 shots only took about 2 seconds. So the bottleneck probably has more to do with working thorough the GUI, in general (opening new windows, and that sort of thing).

Thanks again for the help, and attention, from both of you.
evansste
 
Posts: 102
Joined: October 8th, 2014, 8:19 am

Re: Raspberry Pi DSI port and GPU performance

Postby edugimeno » February 24th, 2017, 4:40 pm

Yes Rasp-PI isn't a platform that outstands by its speed and performance. It's small, cheap, and pretty good for its price, but you can't expect too much.
Also, the operating system as it comes, is probably running many services than you may not need. So you can probably trim a lot of stuff to make it run smoother. Althugh I've been intermitently with Linux for the last 22 years, I haven't done much in any Linux variant in the last 5 years, so I may not be the best source of information but I'm pretty sure that a quick google search on "trimming" or "minimal services" or something like that +"rasp-pi" will show a bunch of helpful directions on how to slim down what's being run on a "default" Raspbian image

Hope that helps
edugimeno
 
Posts: 33
Joined: February 5th, 2016, 2:40 am

Re: Raspberry Pi DSI port and GPU performance

Postby bandersnatch » February 25th, 2017, 2:17 pm

Hi again,

evansste wrote: So the bottleneck probably has more to do with working thorough the GUI, in general (opening new windows, and that sort of thing).


I reckon you are on the right track here in the sense that you are thinking about the possible causes from an OS level.
GUI rendering has a high overhead in many systems and one common trick is to disable rendering until all the GUI elements have been
created in the screen buffer. Screenshots not only read the screen contents but also convert the data into a bitmap & (possibly) write to disk.

If you really want to spend time on this issue, I would suggest the approach I described in a previous forum entry.
Surround the critical code segments with timestamp code & gather some hard data:
- Do the screenshots always take the same amount of time or do they get slower over time?
- Does changing the resolution actually affect the speed of the screenshots?
- Can you speed up the screenshots by disabling/enabling rendering?
- Can you speed up the screenshots by terminating unncessary Daemons & processes in your Raspi linux environment
- Can you use any other different methods for taking the screenshots
- I'm only guessing but I assume you are using an Octave function for screenshots.
- Directly calling a Raspi linux screenshot function might be faster...
- You might also be able to directly read the screen buffer, store each copy in a pre-allocated array in memory
and then render all the array elements to bitmaps & save them to disk at the end of the program.

My main point is that there are many different ways of speeding things up and having hard data on the actual
speeds resulting from each idea will be a real help....

Keep up posted on your progress!

STFB
bandersnatch
 
Posts: 150
Joined: September 17th, 2014, 12:06 pm

Re: Raspberry Pi DSI port and GPU performance

Postby evansste » February 27th, 2017, 7:05 pm

Thanks bandersnatch and Eduardo for your huge range of suggestions.

My Raspberry Pi 3 arrived today and I quickly swapped out my Raspberry Pi 2. I didn't get to run it as many times as I wanted, but from what I could tell, there was no noticeable difference with the Raspberry Pi 3. I simply put the mini SD card, from my Pi 2, into the Pi 3. It booted up and I was able to run my program. That's when I didn't notice much of a difference. However, after rebooting again, the Pi 3 apparently changed some settings, and I wasn't able to get it to boot with an HDMI output. The program is currently configured to work with the HDMI setting, so rather than try to get it to work with the Raspberry Pi 3, I just went back to the 2. I wanted to run it a few more times on the Pi 3, but it currently isn't worth starting over from scratch.

bandersnatch raised some excellent questions. Ultimately, I think the best way to speed things up would be to use a smaller, simpler, operating system. I'm currently using the most recent Raspbian Jessie with PIXEL. I could probably get away with Raspbian Jessie Lite (without PIXEL), or maybe even an earlier version than that. Running that, on the Raspberry Pi 3, may run faster. Although, I'd have to be careful not to go back too far with operating systems, in order to avoid incompatibility. An operating system, which is designed to run with 512 MB of RAM, may run a lot faster with the Pi 3, which has the fastest Pi processor with 1 GB of RAM. However, installing a different operating system would mean starting over (recompiling Octave from source, which I barely got to work).

bandersnatch asked if the screenshots always take the same amount of time. What I've noticed most is that opening, and closing, windows, takes different amounts of time. That's why I'm now less inclined to simply blame the screenshots. Changing resolution didn't make a noticeable difference in the actual program. However, it made a huge difference in a test where I took several screenshots back-to-back. As for speeding up screenshots by disabling/enabling rendering -- I don't know how to do that. It's something I'd have to look into.

Octave doesn't take screenshots with its own function. It uses maim, as a Linux system function, in order to take the screenshots. I simply use Octave's "system" function, which uses maim.

As for stopping Daemons and other processes; that would probably speed things up, but I'm currently not familiar with how to do it. My approach would be to install the most minimalistic operating system, that I could get my hands on, that would also run on a Raspberry Pi 3.

Hands down, the most effective way for me to really speed things up, would be to get rid of GUI interfacing altogether. I'm sure it's possible for me to do this, and I superficially looked into it. What held me back is that it would require major changes to my website, which I wrote nearly 3 years ago. I'd essentially have to re-learn all of the details, since the algorithm is centered around GUI interfacing. I'd then have to learn how to automate uploading files to my web host. Once again, this is certainly possible, but I'm currently not familiar with the details of how to do it. If I were dealing with these issues 3 years ago, and had known of the Raspberry Pi back then, then I'd probably go for it.

Switching to the Pi has caused greater efficiency in certain areas, even though it's not as efficient with the GUI. Its slower with the GUI, but it uses it less often than the laptop. So, all in all, the overall speed is fairly comparable. But I can't help but think of how fast it would be if the Pi were faster with the GUI, or if I ditched GUI automation altogether. It's mostly a matter of how dirty I want my hands to get. I'd have to be less lazy.

Anyway, there's my update on using the Raspberry Pi 3. I didn't notice a real difference with the GUI. Thanks, again, for all of your suggestions.
evansste
 
Posts: 102
Joined: October 8th, 2014, 8:19 am

Re: Raspberry Pi DSI port and GPU performance

Postby edugimeno » February 28th, 2017, 1:08 am

No worries.
Quick answer to a question.
To list running services:

sudo service --status-all
The [+] will indicate "Running".
To disable a service (daemon), just run

sudo update-rc.d service_name disable

There are ways also just by editing start up scripts, which can be found for each runlevel, but using commands is recommended

See if this makes any difference
edugimeno
 
Posts: 33
Joined: February 5th, 2016, 2:40 am

Next

Return to Help me! Hardware

Who is online

Users browsing this forum: No registered users and 2 guests