Welcome, Guest. Please login or register.

Author Topic: New improved intuition.library version from the Kickstart 3.1  (Read 73559 times)

Description:

0 Members and 12 Guests are viewing this topic.

Offline wawrzon

Re: New improved intuition.library version from the Kickstart 3.1
« Reply #119 on: August 27, 2014, 02:16:45 PM »
Quote from: Joloo;771848

Fortunately for me as user of the AmigaOS 3: No one is allowed to break the functionality of Intuition, because that what I would expect if once it would become unmaintained Open-Source...

why do you think that breaking backwards compatibility with some os element would be more accepted by community if it was open source? i feel quite the opposite. as long as it is closed source community has to live with design decisions of a small group, whether they are competent or not. open source involvement discussion and users feedback, i expect the decisions taken would be a good trade of between progress and compatibility, given in contrary to linux amiga depends on a pool of applications that cannot be adopted to random api changes. and even if it happened, someone would fork it for compatibility. as example see aros v0 and v1 and deadwoods work bringing v1 advantages to v0 on trunk where possible.

@matthey

+1
 

guest11527

  • Guest
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #120 on: August 27, 2014, 06:57:49 PM »
Quote from: matthey;771852
So called "hackers" and "cycle counters" like Cosmos and I have found and (sometimes) reported several important bugs.  
So what's the problem in reporting them? Apparently, it's asking for too much.  
Quote from: matthey;771852
At times you have been condescending and ignored anything below major algorithm changes. Ignoring the fact that your compiler is generating awful code greatly increases the chances that people like Cosmos and I are going to come along and optimize away half your code even if it only saves some memory.  
Why, instead of making such claims, you don't go ahead and make an experiment. Write a small AREXX script that opens and closes a couple of windows, multiple times, and measure the time it takes. Make them overlap, move, resize, whatever. Take the time for the full execution, measure several times, probably 20 times for the same script. Then run the script with the original specs, with the hacked intution, and the replacement layers. Measure the time again. Now check whether there is any substantial difference - substantial = larger than the variance of the measurements.

*After* that, you can argue.  

Currently, I don't see why I should waste my time with that kind of stuff. Actually, it's even worse - you get someting for free, yet complain.  
Quote from: matthey;771852
 The Amiga is in you just as much as Cosmos whether you are willing to admit it or not.

I don't care what they are like - it's time to learn something basic about software and computer science then. It's plain stupid to optimize on the wrong end. It's actually the 101 of computer science.
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #121 on: August 27, 2014, 06:58:03 PM »
Quote from: Cosmos;771831
Another example who make coders cry : R_DrawImage
Wow, that's some amazing crapz0r code right there :( Compilers that produce such crap should be burned :(
 

Offline TheMagicM

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2857
    • Show only replies by TheMagicM
    • http://www.BartonekDragRacing.com
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #122 on: August 27, 2014, 11:40:29 PM »
Quote from: Cosmos;771831
I need to explain somethings :
8/ PPC is a complete dead-end, created since the beginning by the ennemies of the Amiga Classics
9/ for of course Atari and Commodore goodbye
10/ with PPC, many Amiga coders loose times & energy for nothing (= no success, only about 5000 AmigaNG users actually versus 5 millions Amiga68k users in the past) : superb trap...



68k is even moreso a dead-end than PPC..but thats another thread for someone else to battle.  I personally dont care for 68k other than for retro gaming.
PowerMac G5 dual 2.0ghz/128meg Radeon/500gb HD/2GB RAM, MorphOS 3.9 registered, user #1900
Powerbook G4 5,6 1.67ghz/2gb RAM, Radeon 9700/250gb hd, MorphOS 3.9 registered #3143
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #123 on: August 28, 2014, 02:20:13 AM »
Quote from: TheMagicM;771869
68k is even moreso a dead-end than PPC..
Everything Amiga is a dead end, except for hobby purposes, which is fine with me. I'm not into Amiga because it's going to get up to date, I have a peecee for that.
 

Offline olsen

Re: New improved intuition.library version from the Kickstart 3.1
« Reply #124 on: August 28, 2014, 08:15:37 AM »
Quote from: Thorham;771862
Wow, that's some amazing crapz0r code right there :( Compilers that produce such crap should be burned :(

Excuse me, this is very little code to judge the compiler by. You're looking at one toenail of the left forepaw of the elephant, so to speak.

Intuition was built with the same 'C' compiler which was used for building the entire original Amiga operating system (Green Hills 'C'). That 'C' compiler was truly excellent, and just to put this into perspective, it took the Lattice/SAS 'C' compiler almost ten years to catch up to it in terms of code quality.

The one big difference between Green Hills 'C', and the Amiga-native Lattice and SAS/C compilers is in how parameters are passed to functions. Lattice and SAS/C could pass function parameters in registers (a0/a1/d0/d1, other registers could be specified as needed), whereas Green Hills 'C' exclusively passed parameters on the stack.

Passing parameters on the stack was not an indication of poor code generation, it was merely how the ABI of the operating system target platform wanted it to be done: Green Hills 'C' was a *Unix* targeted optimizing compiler (back then the focus was on portable 'C' compilers and optimizing 'C' compilers were rare), for the Sun 2 and Sun 3 workstations, which was cleverly reworked into a cross-compiler for the Amiga.

If you want to critique the quality of the Intuition code, please cast your eye on the meat, bones and nervous system of the beast.
« Last Edit: August 28, 2014, 09:16:09 AM by olsen »
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #125 on: August 28, 2014, 10:23:51 AM »
Quote from: olsen;771880
Excuse me, this is very little code to judge the compiler by. You're looking at one toenail of the left forepaw of the elephant, so to speak.
Okay, perhaps it's crap because it was compiled from crap C code? This crap had to come from somewhere, and if it's the compiler's fault, then that's not good. After all, if such simple code is already crap, then what on earth is it going to do with more complex code?

If it's the programmers fault, then they should've been fired :D

Quote from: olsen;771880
If you want to critique the quality of the Intuition code, please cast your eye on the meat, bones and nervous system of the beast.
That's going to be hard without the source code, isn't it?
 

Offline Cosmos AmigaTopic starter

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 954
    • Show only replies by Cosmos Amiga
    • http://leblogdecosmos.blogspot.com
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #126 on: August 28, 2014, 10:42:17 AM »
Quote from: olsen;771880
Excuse me, this is very little code to judge the compiler by. You're looking at one toenail of the left forepaw of the elephant, so to speak.

Intuition was built with the same 'C' compiler which was used for building the entire original Amiga operating system (Green Hills 'C'). That 'C' compiler was truly excellent, and just to put this into perspective, it took the Lattice/SAS 'C' compiler almost ten years to catch up to it in terms of code quality.

The one big difference between Green Hills 'C', and the Amiga-native Lattice and SAS/C compilers is in how parameters are passed to functions. Lattice and SAS/C could pass function parameters in registers (a0/a1/d0/d1, other registers could be specified as needed), whereas Green Hills 'C' exclusively passed parameters on the stack.

Passing parameters on the stack was not an indication of poor code generation, it was merely how the ABI of the operating system target platform wanted it to be done: Green Hills 'C' was a *Unix* targeted optimizing compiler (back then the focus was on portable 'C' compilers and optimizing 'C' compilers were rare), for the Sun 2 and Sun 3 workstations, which was cleverly reworked into a cross-compiler for the Amiga.

If you want to critique the quality of the Intuition code, please cast your eye on the meat, bones and nervous system of the beast.

All my intuition.library source is full of examples I gave... This library is the slowest of the Kickstart 3.1 for me...

I'll show you another example for the beta 7 release if you want...

Note : passing args with registers is more 4 or 5 times faster than by the stack, specially on 000/010/020 who don't have datacache... And we don't need the addq/lea after the subroutine...

And making thousand supertinysubroutines (3 or 4 mnemonics) called by bsr/jsr is not a sign of a good compilator... Inlining is MUCH faster, really...


:(

Offline olsen

Re: New improved intuition.library version from the Kickstart 3.1
« Reply #127 on: August 28, 2014, 11:25:54 AM »
Quote from: Cosmos;771885
All my intuition.library source is full of examples I gave... This library is the slowest of the Kickstart 3.1 for me...

I'll show you another example for the beta 7 release if you want...

Note : passing args with registers is more 4 or 5 times faster than by the stack, specially on 000/010/020 who don't have datacache... And we don't need the addq/lea after the subroutine...

There are, give or take, some 800 functions which make up intuition.library V40, each of which passes parameters on the stack, and that's not counting the function calls made through amiga.lib stubs. This may be a ripe field for peephole optimizations, but my best guess is that the impact any such optimizations could have on overall system performance will be rather low.

Intuition is largely event-driven: its main purpose is capturing user input and routing these events to the clients which consume and react to them. This type of operation is very slow to begin with and typically does not happen more than 60 times per second (e.g. moving the mouse pointer), and more likely happens less than 10 times per second (hitting a key, clicking a mouse button). These operations happen as fast as the user can produce these events.

Aside from the event processing and routing, Intuition also contains API wrapper code which makes interacting with screens and windows, and rendering into them, possible (and nicer, too, from a programmer's point of view). These wrappers connect directly to graphics.library and layers.library, respectively.

Then there's the rest of the code, which consists of utility functions. For example, if you click on a gadget in a window Intuition will need to figure out if the click hit the gadget or the window. Utility functions such as the one which figures out geometric relationships are written in pure 68k assembly in intuition.library V40.

The parts of Intuition which interface to graphics.library and layers.library are more likely to produce improvements if optimized than those parts which merely react to the user's input in his own time.

If the work you are doing in order to optimize code is fun for you, then that's OK, no harm done.

For the record, I would like to point out which scope your optimizations fit into, and where you might want to make specific choices on what to look into.

You could chip away at the code which reacts to user input in user time and you would see no benefit whatsoever (if a mouse click is processed a microsecond faster than without optimization, the user will most definitely not notice the difference), but changes in the interaction between intuition.library and graphics.library/layers.library might have an impact. Assuming that you can measure it, and not just imply that the impact will be there because the number of cycles spent in the modified code is smaller than they used to be.

Quote from: Cosmos;771885
And making thousand supertinysubroutines (3 or 4 mnemonics) called by bsr/jsr is not a sign of a good compilator... Inlining is MUCH faster, really...


:(

The Green Hills 'C' compiler had, for its time, really great data flow analysis capabilities, which allowed it to optimize the operations carried out by a single function. The compiler knew well how the function-local operations were carried out but it did not have an idea of the bigger picture of which function called which.

As far as I can tell Intuition was not written to benefit from function inlining, which would be constrained by the size of the respective function (back then they used preprocessor macros instead). You would have had to mark local functions as being 'static' and let the compiler decide whether inlining them would make sense.

Anyway, as great as the compiler was, it needed help from the programmer to tell it what to do, and this being absent, no function inlining happened. You are asking too much of an optimizing compiler which was a product of its time.
« Last Edit: August 28, 2014, 11:30:57 AM by olsen »
 

Offline kamelito

Re: New improved intuition.library version from the Kickstart 3.1
« Reply #128 on: August 28, 2014, 12:31:27 PM »
Green Hill compiler is still available for 68k.
http://www.ghs.com/products/68k_development.html

I read somewhere that Atari Mint uses a more recent GCC that is producing better code. Maybe we should port it to Amiga?
Kamelito
 

Offline olsen

Re: New improved intuition.library version from the Kickstart 3.1
« Reply #129 on: August 28, 2014, 01:03:24 PM »
Quote from: Thorham;771882
Okay, perhaps it's crap because it was compiled from crap C code? This crap had to come from somewhere, and if it's the compiler's fault, then that's not good.
As far as I can tell Intuition is not poorly written. Poorly written code could would lack structure, function and variable names would be poorly chosen and fail to convey their respective purpose, the purpose and intent behind the code as written would be hard to fathom and comments would either be absent, meaningless or wrong. I have seen code like that: I've written it myself.

How could one reasonably hope to measure code quality on such a small scale? The disassembly is of stub code which calls DrawImageState() with two additional parameters (state=IDS_NORMAL, drawinfo=NULL) which are absent in the basic DrawImage() function.

How could the compiler optimize this? Try squeezing blood from a turnip, there is not enough substance here. An optimizing compiler tries to remove redundancies from the flow of control through a function, and how it uses data: it tries to change the implementation of an algorithm without changing the result. There is no control flow to speak of here, it's just reusing function parameters and calling a different function with these. There is no algorithm to change here.

Quote from: Thorham;771882
After all, if such simple code is already crap, then what on earth is it going to do with more complex code?

If it's the programmers fault, then they should've been fired :D
Throw more complex code at the optimizer, and it will get shorter and/or faster, assuming that it can be optimized.

The disassembly of the stub code is a poor example in this context because there is no algorithmic optimization possible (pulling parameters off the stack and pushing them back onto the stack is mandated by how the platform wants this to be done, so this does not count as a fault of the compiler).

Here's the thing: an optimizing compiler allows you to spend more time on getting your code to work correctly and still be readable.

Most of the time, and I'm not making this up, attempting to optimize code is a futile effort. For one thing, optimization requires effort to transform your code, and you need to verify that it still does the job as the original code, just better. This transformation inevitably results in more complex code that is hard to verify as correct.

Put another way, in your attempt to make things better you might not just have to spend a lot of time in getting there, you will probably make things less robust than they were before.

Even if you did succeed, the chances that your change will have any positive impact will be very low. There are rare exception to this, e.g. if the optimization is prompted by prior analysis which exposed the target of the optimization as a bottleneck. The rest of the time you will both have difficulties figuring out which code to optimize and justifying why you spent so much time on trying to optimize it.

Quote from: Thorham;771882
Quote
If you want to critique the quality of the Intuition code, please cast your eye on the meat, bones and nervous system of the beast.
That's going to be hard without the source code, isn't it?
Sure, but so is trying to optimize the code at the instruction level, viewing a translated version of the original 'C' code. At the instruction level the knowledge which would inform the choices the original programmer made in implementing algorithms is hard to fathom.

In this thread the absence of this information was, so far, considered completely beside the point. This thread is more about the challenge and the sport of peephole optimization than about global optimization.
« Last Edit: August 28, 2014, 01:24:39 PM by olsen »
 

Offline olsen

Re: New improved intuition.library version from the Kickstart 3.1
« Reply #130 on: August 28, 2014, 01:10:53 PM »
Quote from: kamelito;771889
Green Hill compiler is still available for 68k.
http://www.ghs.com/products/68k_development.html

I read somewhere that Atari Mint uses a more recent GCC that is producing better code. Maybe we should port it to Amiga?
Kamelito

Green Hills charges big bucks for the use of the compiler.

Amiga, Inc. (the Los Gatos operation) bought the compiler with complete source code, so that it could be built on the respective workstation (Sun 2 program code does not necessarily run on a Sun 3 workstation, and the other way round).

Incidentally, the Green Hills 'C' compiler used for building the Amiga operating system was written in Pascal.
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #131 on: August 28, 2014, 01:38:40 PM »
Quote from: Cosmos;771831
_DrawImage
move.l   d2,-(sp)
move.l   8(sp),d0
move.l   $C(sp),d1
move.l   $10(sp),d2
clr.l   -(sp)
clr.l   -(sp)
move.l   $1C(sp),-(sp)
move.l   d2,-(sp)
move.l   d1,-(sp)
move.l   d0,-(sp)
bsr.w   _DrawImageState
lea   $18(sp),sp
move.l   (sp)+,d2 ; make the wrong CCR for BenchTrash 1.73
rts

FYI if BenchTrash is assuming CCR is set (unless explicitly documented in autodocs) then it is fault in BenchTrash. (Edit: when reading thread back to beginning it looks like this call was missing return code completely? Or?)

And another note. Now when you have optimized away function setup you still have problem with slow gfx output. What you have achieved is CopyMemQuick() optimization of intuition...
« Last Edit: August 28, 2014, 02:16:41 PM by itix »
My Amigas: A500, Mac Mini and PowerBook
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #132 on: August 28, 2014, 01:54:29 PM »
To olsen:

Perhaps you're right, but I'm a 68k coder and when I see crap code like that I can't help but think what I wrote earlier.
 

guest11527

  • Guest
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #133 on: August 28, 2014, 03:58:40 PM »
Quote from: itix;771892
FYI if BenchTrash is assuming CCR is set (unless explicitly documented in autodocs) then it is fault in BenchTrash.  
Yes, it is. There is a new release in Aminet that was fixed. Actually, that discussion is long over, please see above.

Actually, this specific function returns a condition code, not a value.
Quote from: itix;771892
And another note. Now when you have optimized away function setup you still have problem with slow gfx output. What you have achieved is CopyMemQuick() optimization of intuition...

I don't quite understand what you want to say here...
 

guest11527

  • Guest
Re: New improved intuition.library version from the Kickstart 3.1
« Reply #134 from previous page: August 28, 2014, 04:01:51 PM »
Quote from: Thorham;771893
To olsen:

Perhaps you're right, but I'm a 68k coder and when I see crap code like that I can't help but think what I wrote earlier.

But look, this is exactly the difference between a "coder" and a "software engineer". In essence, the "register-ping-pong" costs pobably like 20-30 cycles per function per call, probably in total around 400 cycles. Consider that in perspective with the amount of cycles you can save by *not* copying a cliprect by an improved algorithm.