|
|
Up |
|
|
  |
Author: DavidMDavidM Date: Aug 3, 2008 15:45
As we all know, all VMs regardless of the language can impose huge run-
time performance penalties, compared to native coding in native compiled
languages.
An STC-based Forth with optimal hand-coded assembler primitives can evade
this cost to a large degree, so I won't be talking about that here. I'm
thinking more of DTC, ITC and TTC-based forths.
What I am interested in is: when is it better to sweat over the coding of
forth words, squeezing every last ounce of speed out of them at the very
likely cost of readability/maintainability, as opposed to just taking the
time critical stuff and coding it as C and/or assembler primitives?
Cheers
Dave
|
| |
|
| | 39 Comments |
|
  |
Author: roger.levyroger.levy Date: Aug 3, 2008 17:27
On Aug 3, 6:45 pm, DavidM nowhere.com> wrote:
> As we all know, all VMs regardless of the language can impose huge run-
> time performance penalties, compared to native coding in native compiled
> languages.
>
> An STC-based Forth with optimal hand-coded assembler primitives can evade
> this cost to a large degree, so I won't be talking about that here. I'm
> thinking more of DTC, ITC and TTC-based forths.
>
> What I am interested in is: when is it better to sweat over the coding of
> forth words, squeezing every last ounce of speed out of them at the very
> likely cost of readability/maintainability, as opposed to just taking the
> time critical stuff and coding it as C and/or assembler primitives?
>
> Cheers
> Dave
I'd say ... you shouldn't sweat over Forth code at all. Do what's
necessary and no more. You want to finish your application (if you're
writing one), not torture yourself.
|
| Show full article (1.75Kb) |
|
| | no comments |
|
  |
Author: Jonah ThomasJonah Thomas Date: Aug 3, 2008 19:41
DavidM nowhere.com> wrote:
> What I am interested in is: when is it better to sweat over the coding
> of forth words, squeezing every last ounce of speed out of them at the
> very likely cost of readability/maintainability, as opposed to just
> taking the time critical stuff and coding it as C and/or assembler
> primitives?
If your code is already fast enough running on your particular Forth on
your particular hardware, then you don't need to do either one, you're
done.
So, you have your Forth code that works but it isn't fast enough. Step
back and notice whether you see some other method that would run
faster. You can try out new methods faster in Forth. See which one looks
like it's actually doing the least work. If you find a better algorithm
and it's fast enough, then you're done.
|
| Show full article (6.45Kb) |
| no comments |
|
  |
Author: Elizabeth D RatherElizabeth D Rather Date: Aug 3, 2008 20:09
DavidM wrote:
> As we all know, all VMs regardless of the language can impose huge run-
> time performance penalties, compared to native coding in native compiled
> languages.
>
> An STC-based Forth with optimal hand-coded assembler primitives can evade
> this cost to a large degree, so I won't be talking about that here. I'm
> thinking more of DTC, ITC and TTC-based forths.
>
> What I am interested in is: when is it better to sweat over the coding of
> forth words, squeezing every last ounce of speed out of them at the very
> likely cost of readability/maintainability, as opposed to just taking the
> time critical stuff and coding it as C and/or assembler primitives?
>
> Cheers
> Dave
|
| Show full article (2.75Kb) |
| no comments |
|
  |
Author: Jerry AvinsJerry Avins Date: Aug 3, 2008 20:28
Elizabeth D Rather wrote:
...
> A story I've told here before is applicable (sorry if you've already
> heard it): FORTH, Inc. was asked to recode a baggage handling system
> for American Airlines. The original program was all assembler...
|
| Show full article (1.19Kb) |
| no comments |
|
  |
Author: John PassanitiJohn Passaniti Date: Aug 4, 2008 00:11
On Aug 3, 6:45 pm, DavidM nowhere.com> wrote:
> As we all know, all VMs regardless of the language can impose huge run-
> time performance penalties, compared to native coding in native compiled
> languages.
The key word is "can." The slowest VM can still outperform the
fastest native code if the algorithms used are superior. What matters
is the performance of the system as a whole, not the VM. That's a
trap that you see endlessly here in comp.lang.forth-- a preoccupation
with speed. But not speed of some concrete real-world application,
but the speed of some small primitive in the system. The theory, I
guess, is that by focusing on speeding up all the primitives, the
performance of the overall system is improved. To which I say,
nonsense-- if I choose a superior algorithm, that is going to give me
a far better pay-off in terms of performance than if I manage to
reduce a routine I hardly ever call by a few cycles.
> What I am interested in is: when is it better to sweat over the coding of
> forth words, squeezing every last ounce of speed out of them at the very
> likely cost of readability/maintainability, as opposed to just taking the
> time critical stuff and coding it as C and/or assembler primitives?
|
| Show full article (2.81Kb) |
| no comments |
|
  |
Author: Elizabeth D RatherElizabeth D Rather Date: Aug 4, 2008 05:59
Jerry Avins wrote:
> Elizabeth D Rather wrote:
>
> ...
>
>> A story I've told here before is applicable (sorry if you've already
>> heard it): FORTH, Inc. was asked to recode a baggage handling system
>> for American Airlines. The original program was all assembler, and
>> too expensive to maintain. We were required to reproduce the user
>> interface and basic bag handling procedures, but could do whatever
>> else seemed appropriate. Our program was written entirely in
>> polyFORTH (ITC), running native on an LSI-11 (yeah, it was quite a few
>> years ago). When it was sufficiently complete to run some timing
>> tests, everyone was astonished: our system could handle 25%% more
>> bags/minute than the previous one. polyFORTH was obviously not faster
>> than pure assembler; the point was that our internal design was far
>> more efficient than its predecessor.
|
| Show full article (1.69Kb) |
| no comments |
|
  |
Author: Thomas PorninThomas Pornin Date: Aug 4, 2008 06:23
According to DavidM nowhere.com>:
> As we all know, all VMs regardless of the language can impose huge run-
> time performance penalties, compared to native coding in native compiled
> languages.
It can but it is not necessarily doomed to. A VM is a "virtual machine":
it emulates a hardware system which does not actually exist, but for
which the code was written. The VM thus converts the code for the
virtual hardware into something that the real processor can process,
through a mixture of static (translation before execution) and dynamic
(during execution) operations. For instance, if using an ITC-based
Forth, then the static part is the conversion of word names (which are
strings) into addresses (pointers to CFA) cunningly layed out for proper
execution. The dynamic part entails the double-indirections and jumps
(the famous NEXT code snippet).
Traditional Forth implementations rely on threaded code (they are all
some kind of *TC) in which the translation transforms the virtual
machine code into a sequence of addresses (or subroutine calls or...
|
| Show full article (4.74Kb) |
| no comments |
|
  |
Author: Bernd PaysanBernd Paysan Date: Aug 4, 2008 06:21
John Passaniti wrote:
> The key word is "can." The slowest VM can still outperform the
> fastest native code if the algorithms used are superior. What matters
> is the performance of the system as a whole, not the VM. That's a
> trap that you see endlessly here in comp.lang.forth-- a preoccupation
> with speed. But not speed of some concrete real-world application,
> but the speed of some small primitive in the system.
You don't see the forrest in the trees. When we argue here, we are quite
often concerned about speed. You then step in and say "there's no
requirement to be performant here". That's sloppy thinking - there's no
requirement for performance here and there, so you implement CPU hogs here
and there and then wonder why your application is dog slow.
You forget that a fast, low-memory solution is often straight-forward and
clean design, too. It's easy to maintain, as well. That's the goal. If your
performance improvements are a burden for a small, clean implementation,
forget it.
|
| Show full article (1.50Kb) |
| no comments |
|
  |
|
|
  |
Author: Elizabeth D RatherElizabeth D Rather Date: Aug 4, 2008 06:59
Bernd Paysan wrote:
> John Passaniti wrote:
>> The key word is "can." The slowest VM can still outperform the
>> fastest native code if the algorithms used are superior. What matters
>> is the performance of the system as a whole, not the VM. That's a
>> trap that you see endlessly here in comp.lang.forth-- a preoccupation
>> with speed. But not speed of some concrete real-world application,
>> but the speed of some small primitive in the system.
>
> You don't see the forrest in the trees. When we argue here, we are quite
> often concerned about speed. You then step in and say "there's no
> requirement to be performant here". That's sloppy thinking - there's no
> requirement for performance here and there, so you implement CPU hogs here
> and there and then wonder why your application is dog slow.
>
> You forget that a fast, low-memory solution is often straight-forward and
> clean design, too. It's easy to maintain, as well. That's the goal. If your
> performance improvements are a burden for a small, clean implementation,
> forget it.
> ...
|
| Show full article (2.58Kb) |
| no comments |
|
|
|
|