ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Improving performance

Fri Jan 18, 2013 1:36 pm

Midori isn't very compatible , Netsurf is supposed to be very fast
and can work without X and only with the Framebuffer.
HTML5 and JavaScript support are ongoing efforts.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

MAA1612
Posts: 18
Joined: Thu Jan 17, 2013 11:00 am

Re: Improving performance

Fri Jan 18, 2013 2:04 pm

sam_p_lay wrote:Well the default terminal in Enlightenment 17 (Bodhi's WM) is called Terminology. Nothing happened when I rebooted though.
Hm ... I am using Raspbian with manual X startup via "startx". Here, it works.
And wouldn't this still boot into Enlightenment and just fire up a terminal?
No, global default behavior is usually specified in "/etc/X11/xinit/xinitrc". This includes window manager startup. If you create "~/.xinitrc", this should override the global default.
What's the difference by the way between .bashrc and .xinitrc? They both seem to be like DOS's autoexec.bat but run when your GUI loads?
As the names suggest: ".bashrc" is executed whenever a bash shell is started. ".xinitrc" is executed during X startup.
I didn't realise C/C++ are faster than Java.
C/C++ are translated to native machine code, whereas Java is translated to bytecode which has to be interpreted.
I was equally up for learning either but Apple's C ('Objective-C') is some kind of Apple implementation of C?
ObjC and C++ are both object-oriented extensions of C. They use different object-orientation philosophies.
I figured Java will be a more transferable skill to have. Plus I don't really want to get involved with Apple or make them any money :-D
C/C++ are not affiliated with Apple.
And I had heard about X being a bit of a dinosaur now - read it's being replaced by a display server called Wayland? I didn't know what the shortcomings of X were, but performance is always a good reason :-)
X is still quite good in the use cases it was originally intended for.

MAA1612
Posts: 18
Joined: Thu Jan 17, 2013 11:00 am

Re: Improving performance

Fri Jan 18, 2013 2:07 pm

ghans wrote:Midori isn't very compatible , Netsurf is supposed to be very fast
and can work without X and only with the Framebuffer.
HTML5 and JavaScript support are ongoing efforts.
I am using Chromium with 1280x720 resolution and all the auto completion/prefetch stuff turned off. Overclocking is set to 900 Mhz. It gives me sufficient performance on simple websites without advertisments. But AJAX stuff and sites overloaded with advertisments are still no fun.

sam_p_lay
Posts: 52
Joined: Fri Jan 11, 2013 12:15 am

Re: Improving performance

Fri Jan 18, 2013 2:32 pm

Yeah that's what I was trying to clarify - can I have X running without any GUI so effectively giving the command-line the ability to open a graphical mouse-driven browser? And then have my text editor open at the same time, both applications full screen obviously, and the ability to alt+tab between them? I don't mind using a text-based text editor - I've used nano before when I tried installing Gentoo and it didn't seem too bad.

sam_p_lay
Posts: 52
Joined: Fri Jan 11, 2013 12:15 am

Re: Improving performance

Fri Jan 18, 2013 2:39 pm

Wow I didn't spot all these new posts... what's the difference between bytecode and machine code? Machine code is 0s and 1s right? Then assembly a notch up but still very close to the hardware, and then high level languages package up assembly stuff for ease of use? I know C/C++ aren't Apple, but Objective-C is, and that's what I'd be learning for iOS dev work.

I'd be making Apple money through app sales. That's not a huge deal to be honest, more the fact that Objective-C would be a much less transferable skill than C++ or Java. I'd have nothing against taking on a bit of extra challenge with C++, but if Android dev work is with Java then that's probably my best bet.

sam_p_lay
Posts: 52
Joined: Fri Jan 11, 2013 12:15 am

Re: Improving performance

Fri Jan 18, 2013 2:45 pm

And Cloudcentric, what would I be losing with a browser that's not modern? Just HTML5/CSS3 eye candy or things like tabbed browsing etc? RiscOS is actually the first thing I tried (just for curiosity/nostalgia) but with R-Pi/Python tutorials being geared towards Raspbian, I didn't think RiscOS would be much use for me to actually use as the main OS. Plus, I couldn't get it online with my wireless anyway.

Cloudcentric
Posts: 982
Joined: Fri Sep 14, 2012 9:13 am

Re: Improving performance

Fri Jan 18, 2013 2:57 pm

Midori and IceWeasel have some HTML5, SSL and JS compatibility

Chromium 20 and 22 are still in Beta testing afaiaa

With Netsurf and Dillo you would lose HTML5 and maybe some JS, pages may not render correctly, though have not undertaken a full back-to-back comparision.


Regards multi-windows from Command Line this is an interest program which I have never used:

http://tmux.sourceforge.net


I am still a newbie at Command Line but the Pi has given me an impetus to try and learn and understand, well enough to completely wreck an install...............
I know everything about nothing"

sam_p_lay
Posts: 52
Joined: Fri Jan 11, 2013 12:15 am

Re: Improving performance

Fri Jan 18, 2013 3:13 pm

Thanks, this looks interesting! Wonder if Midori would work with it? I don't know much with the command line either, just basic navigation and file management. Really need to get my head around <, >, | and how to use grep effectively. Doing everything from the command line I think would certainly be a good way to learn, long as I can multitask.

Even if I don't get a solution out of this, I'm still glad I posted - it's been really educational.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24987
Joined: Sat Jul 30, 2011 7:41 pm

Re: Improving performance

Fri Jan 18, 2013 3:23 pm

sam_p_lay wrote:Thanks, this looks interesting! Wonder if Midori would work with it? I don't know much with the command line either, just basic navigation and file management. Really need to get my head around <, >, | and how to use grep effectively. Doing everything from the command line I think would certainly be a good way to learn, long as I can multitask.

Even if I don't get a solution out of this, I'm still glad I posted - it's been really educational.
Machine code = lowest programmable level of a CPU. 0's and 1's
Assembly code : Human readable version of Machine code, run through an assembler to convert to machine code
C/C++ : Higher level languages that are compiled in to machine code (or often assembler then machine code).
Java/Python : Even higher level languages that are converted to byte code during execution (or perhaps in advance), which is then executed by another program. You can look at byte code as a sort of CPU independent machine code - but you still need something to convert it in to something the CPU understands - a byte code interpreter, which is why it is slower.

Or something like that.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

MAA1612
Posts: 18
Joined: Thu Jan 17, 2013 11:00 am

Re: Improving performance

Fri Jan 18, 2013 3:54 pm

sam_p_lay wrote:what's the difference between bytecode and machine code? Machine code is 0s and 1s right?
On the most primitive level, every digital device can only process 0s and 1s. Thus, bytecode is saved on your SD card as 0s and 1s as well. The difference is that machine code can be executed directly by the CPU, because it is written in the "native language of the CPU". Bytecode cannot be directly executed by the CPU. It is easier to translate into machine code than Java source code, but it still has to be translated on-the-fly during execution.
I'd be making Apple money through app sales. That's not a huge deal to be honest, more the fact that Objective-C would be a much less transferable skill than C++ or Java. I'd have nothing against taking on a bit of extra challenge with C++, but if Android dev work is with Java then that's probably my best bet.
IMO C++ is not necessarily an extra challenge compared with Java.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Improving performance

Fri Jan 18, 2013 4:10 pm

Now I'm at home I have tested the twm solution. It goes like this:

Code: Select all

sudo apt-get install twm
Then create the file /home/pi/.xinitrc and put this in it:

Code: Select all

twm &
lxterminal
Now startx.
The first thing you will get is the outline of a window. Move it to where you want the lxterminal and click the left button. That happens every time you open a new window. twm is just a window manager. You don't get any icons, menus or system trays. If you close the first lxterminal, then the X session will finish.
Now in the lxterminal type "netsurf &", and see if it suits you.

To get back to how you were, close the lxterminal, get dumped back into the command line and, if it didn't suit, delete .xinitrc using the rm command.

I found midori didn't work under twm, it didn't show the navigation bar or bring up dialog boxes. YMMV.

If you like it, come back for a lesson on how to open windows and WTF the "&" is doing. ;-)

MAA1612
Posts: 18
Joined: Thu Jan 17, 2013 11:00 am

Re: Improving performance

Fri Jan 18, 2013 4:12 pm

jamesh wrote:Machine code = lowest programmable level of a CPU. 0's and 1's
Although it is a common phrase, I do not find it helpful to define machine code as consisting of 0s and 1s, because source code and bytecode are represented as sequences of 0s and 1s, too. 0 and 1 are the (only) characters of the digital alphabet. Thus, everything must be represented as sequences of 0s and 1s on digital devices.

Machine code can be executed directly by the CPU, because it is the native language of the CPU. Higher language source code and bytecode have to be translated before or during execution, because they are not the native language of the CPU.

Assembly language can be compared to a transliteration of chinese words with latin characters, i.e. it uses the same words as machine code, but written differently, so they are easier to read and write for us.

MAA1612
Posts: 18
Joined: Thu Jan 17, 2013 11:00 am

Re: Improving performance

Fri Jan 18, 2013 4:17 pm

rurwin wrote:Now I'm at home I have tested the twm solution.
I still doubt that this will improve performance significantly. LXDE has a negligible footprint compared with any current web browser.

sam_p_lay
Posts: 52
Joined: Fri Jan 11, 2013 12:15 am

Re: Improving performance

Fri Jan 18, 2013 5:00 pm

Thanks rurwin - I'm gonna re-image Raspbian (I'm guessing that's what you started with?) and give this a shot! Can I just ask now what the & is for? :-)

Thanks jamesh and MAA1612 for the languages explanation - that's actually made it a lot clearer to me. C sounds like a better way to do things then performance-wise, is that the reason it's more popular?

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Improving performance

Fri Jan 18, 2013 5:34 pm

I don't think you need to re-image :shock:


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Improving performance

Fri Jan 18, 2013 5:44 pm

Linux is based on two low-level functions: fork and exec.

fork clones the current process, so you have two processes (almost) exactly the same, a new one and an old one.
exec overwrites the current memory space with a new application from disk and runs that -- in the same process.

So what Bash is doing when you run a command is to find the file on the disk. Then it forks itself. The new process execs the file you want to execute.

Now the old process has a choice. It can hang around waiting for the new process to finish, or it can display a new prompt and get the user's next command.

That's what "&" does ("&&" is different). Usually it waits for each process to finish before putting up a new prompt. But if the command ends in "&" then bash does not wait for the new process to finish. It just displays the process ID of the new process and puts up a new command prompt.

So "netsurf &" runs the browser but still leaves you a command prompt to type the next command.

In .xinitrc, it isn't bash that's reading the file, and the action is a little different but has a similar effect: that file is being read by a program called xinit. xinit is started by startx, and the first thing it does is to start the X server (/usr/bin/X), and the second thing it does is to read .xinitrc. Because each line except the last has an "&", it just starts each one as a separate process without waiting for them to finish before going on to the next. When it gets to the end of the file, it closes the Xserver and exits. The last one is lxterminal and it doesn't have a "&", so xinit waits for it to finish before continuing on to the end of the file, and so lxterminal becomes the "controlling process"; when you close lxterminal, xinit stops the X server and exits. In the case of LXDE, the controlling process is the widget that includes the "logout" menu option. Clicking that makes the widget exit and so xinit closes down the X server and exits.

Cloudcentric
Posts: 982
Joined: Fri Sep 14, 2012 9:13 am

Re: Improving performance

Fri Jan 18, 2013 5:51 pm

Do you not have a spare SD Card ?
I know everything about nothing"

MAA1612
Posts: 18
Joined: Thu Jan 17, 2013 11:00 am

Re: Improving performance

Fri Jan 18, 2013 7:30 pm

sam_p_lay wrote:C sounds like a better way to do things then performance-wise, is that the reason it's more popular?
I would not say that C is more popular than C++ or Java. It depends on the context. The history of the C programming language is strongly connected with the history of the UNIX operating system. Even today, almost all UNIX kernels are written in C. Thus, you can be pretty sure, that every UNIX derivate comes with a powerful C compiler. For this reason, C is still the widely spreadest language in the UNIX world.

Also, C is much closer to assembly language than most other programming languages that are widely used today. Some even say that C is nothing more than assembly language with syntactic sugar. For example, an array in C is just represented by the memory address that contains the first field of the array. In assembly language, you would implement it pretty much in the same way. Although modern C compilers make a lot of optimizations that go beyond the "C with syntactic sugar" claim, compiling a C program is still very fast compared with C++ or Java.

However, if you need to realize big software systems, an object-oriented programming language as C++ or Java is probably the better choice. C++ can be just as efficient as C, although it usually takes much longer to compile.

Best regards,
Alexander

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24987
Joined: Sat Jul 30, 2011 7:41 pm

Re: Improving performance

Fri Jan 18, 2013 7:43 pm

MAA1612 wrote:
jamesh wrote:Machine code = lowest programmable level of a CPU. 0's and 1's
Although it is a common phrase, I do not find it helpful to define machine code as consisting of 0s and 1s, because source code and bytecode are represented as sequences of 0s and 1s, too. 0 and 1 are the (only) characters of the digital alphabet. Thus, everything must be represented as sequences of 0s and 1s on digital devices.

Machine code can be executed directly by the CPU, because it is the native language of the CPU. Higher language source code and bytecode have to be translated before or during execution, because they are not the native language of the CPU.

Assembly language can be compared to a transliteration of chinese words with latin characters, i.e. it uses the same words as machine code, but written differently, so they are easier to read and write for us.
I used the 1 and 0's because that's what the OP referred to.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

Re: Improving performance

Fri Jan 18, 2013 9:53 pm

I was looking for a fast web browser a couple of months ago and tested quite a few, the best i found for my purposes was uzbl although dillo didn't seem too bad either. Things may have changed now but these two may still be worth a try if they handle what you want to do with them.

robwriter
Posts: 114
Joined: Sat Feb 25, 2012 6:26 pm

Re: Improving performance

Fri Jan 18, 2013 11:21 pm

I'm less worried about the lack of a fast modern browser meaning the Pi can't a desktop replacement, because that's not what it was meant to be.

However, the web is the #1 resource for learning how to code. So if the Pi can't do this well enough, suddenly you need to use your PC to google stuff, which is far from ideal.

It's far beyond my skills, but is it possible that the community could fork a browser and rewrite some of it to make it more Pi friendly? Or is that too big a project?

sam_p_lay
Posts: 52
Joined: Fri Jan 11, 2013 12:15 am

Re: Improving performance

Fri Jan 18, 2013 11:29 pm

rurwin - thanks for the explanation. I feel I may have skipped ahead a couple of chapters there but I'm just about following you :-) I've tried your solution and had no luck. I tried to output the error using

startx > error.txt

but just got an empty file. Guess that doesn't work for everything? Or I did it wrong? Anyway the gist of it was that X server failed, X server tried to shut down, X server terminated successfully. Still, at least my xinitrc is actually trying to run now!

ghans - I needed to re-image because Bodhi wasn't running my xinitrc scripts at all for some reason. Every time I booted I'd end up in Enlightenment.

cloudcentric - nope, I purchased one SD card specifically for the R-Pi. Not into photography or carrying around a huge media collection on my phone, so didn't have any floating around.

Alexander - thanks for the clarification on the languages. If I was looking at non-mobile development (or if Android SDK was primarily C++) then C++ is what I'd do. As it is, Java is probably the way to go (after getting started with Python for the basics). I don't even know object-oriented PHP (apparently what I write is called 'procedural PHP') so I really am starting from scratch. Is Java is higher level and more user-friendly, readable etc then it might make life a bit easier anyway. C++ can always follow :-)

Hiro - I had heard good things about uzbl. Isn't it keyboard-driven? I may give it a look. I don't think dillo is still in development is it?

Robwriter - sounds good to me and I expect the situation will improve with time. As people have said, the quality of the coding is a major factor. Thinking back to nVidia's Detonator XP / Detonator 3 drivers in around 2000, it really demonstrated what a huge difference the software can make to performance. The Pi does indeed need decent browsing capabilities in order to fulfil its intended purpose. Unless of course you learn from paper learning materials instead.

Thanks to everyone for the helpful and educational responses - keep em coming :-)

sam_p_lay
Posts: 52
Joined: Fri Jan 11, 2013 12:15 am

Re: Improving performance

Fri Jan 18, 2013 11:44 pm

rurwin it actually began with "xinit: connection to X server lost".

sam_p_lay
Posts: 52
Joined: Fri Jan 11, 2013 12:15 am

Re: Improving performance

Fri Jan 18, 2013 11:56 pm

Logging in with an Openbox session by the way is faster. Still slow, but definitely an improvement. No taskbar, but seems I can launch stuff by just right clicking on the desktop. Midori looks a bit different now but it's working fine.

Would still like to get twm working if possible though. I tried logging in to a twm session with the GUI login box but just got a blank white screen and huge lag on mouse cursor movement (and no response to clicking).

MAA1612
Posts: 18
Joined: Thu Jan 17, 2013 11:00 am

Re: Improving performance

Sat Jan 19, 2013 8:42 am

Hi Sam,
sam_p_lay wrote:I tried to output the error using startx > error.txt but just got an empty file. Guess that doesn't work for everything? Or I did it wrong?
I'd recommend reading the Wikipedia article on standard streams.

Appending "> file" to a command will only redirect the standard output stream, but not the standard error stream. In order to redirect the standard error stream, you would have to append "2> file". If you want standard out and standard error stream to be redirected into the same file, you would have to append "2>&1 file".

"startx 2> error.txt" should redirect only the error messages into the file "error.txt".
"startx 2>&1 error.txt" should redirect everything into the file "error.txt".

Best regards,
Alexander

Return to “Troubleshooting”