Tuesday, September 28, 2021

Monday, September 27, 2021

FSF CFarm results

FSF graciously granted me access to their compile farm. So far, the Egel interpreter doesn't compile on a lot of machines because it relies on a lot of modern software.

It needs cmake (3.13), libicu (65.0), and libfmt (8.0) and those are not installed on the majority of machines.

I also get wildy varying results back on the performance of the microbenchmark million.eg (summation of a list of the first million integers). Below, the results:

gcc185.fsffrance.org (centos, aarch64)   - succesful compile and local install. 22 sec on million

gcc202.fsffrance.org (debian, sparc64)   - succesful compile and local install. 1.22 min on million

gcc203.fsffrance.org (debian, powerpc64) - succesful compile and local install. 25 sec on million

I'll try a number of other machines (some I am interested in seem to be down). Next steps are to create rpm and deb packages.

Thursday, September 9, 2021

Dynamic dispatch in Egel

 An example how to do dynamic dispatch in Egel. This is a cool language.

# Just a showcase how one could do dynamic dispatch in Egel over a table.
#
# This is of course an extremely slow implementation over a lookup table
# represented as a list. But moving the combinators to C++ would help.

import "prelude.eg"

using System
using List

namespace Dispatch (

    val dispatch_table = ref {}

    def dispatch_register =
        [ TAG FUNC ->
          let TABLE = get_ref dispatch_table in
          let TABLE = cons (TAG FUNC) TABLE in
          set_ref dispatch_table TABLE ]

    def dispatch_findrec =
        [ TAG nil -> throw (format "dispatch for {} failed" TAG)
        | TAG0 (cons (TAG1 FUNC) TABLE) ->
	    if TAG0 == TAG1 then FUNC [ _ -> dispatch_findrec TAG0 TABLE ]
	    else dispatch_findrec TAG0 TABLE ]

    def dispatch_on =
	[ TAG -> let TABLE = get_ref dispatch_table in 
                     dispatch_findrec TAG TABLE ]

)

def ++ = Dispatch:dispatch_on "++"

val plus_float_register =
    let FUNC = 
        [ K EXPR0 EXPR1 -> if [ E::float -> true | E -> false ] EXPR0 then (+) EXPR0 EXPR1 else K nop EXPR0 EXPR1
	| K -> K nop ]
    in
    Dispatch:dispatch_register "++" FUNC

val plus_text_register =
    let FUNC = 
        [ K EXPR0 EXPR1 -> if [ E::text -> true | E -> false ] EXPR0 then (+) EXPR0 EXPR1 else K nop EXPR0 EXPR1
	| K -> K nop ]
    in
    Dispatch:dispatch_register "++" FUNC

def main = 
    print (1.0 ++ 2.0) "\n";
    print ("hello " ++ "world") "\n";
    print (1 ++ "failure")

Wednesday, September 8, 2021

Egel interpreter runs twice as fast in VM

 Okay, so I ported the interpreter to Fedora 34 (arm64) in a virtual machine on the Air. Now the microbenchmark runs twice as fast than on native, 2.5 seconds.

I thought I might have messed up and the thing doesn't garbage collect, so tested that and: 

[marco@fedora debug]$ valgrind ./egel ../examples/million.eg 

==2653== Memcheck, a memory error detector

==2653== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.

==2653== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info

==2653== Command: ./egel ../examples/million.eg

==2653== 

500000500000

==2653== 

==2653== HEAP SUMMARY:

==2653==     in use at exit: 3,374 bytes in 4 blocks

==2653==   total heap usage: 40,051,242 allocs, 40,051,238 frees, 2,275,766,965 bytes allocated

==2653== 

==2653== LEAK SUMMARY:

==2653==    definitely lost: 0 bytes in 0 blocks

==2653==    indirectly lost: 0 bytes in 0 blocks

==2653==      possibly lost: 0 bytes in 0 blocks

==2653==    still reachable: 3,374 bytes in 4 blocks

==2653==         suppressed: 0 bytes in 0 blocks

==2653== Rerun with --leak-check=full to see details of leaked memory

==2653== 

==2653== For lists of detected and suppressed errors, rerun with: -s

==2653== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

So that isn't it. Maybe the VM thinks it's a uniprocessor.

Tuesday, September 7, 2021

Moved to MacOS (arm64). Egel interpreter now twice as fast

The microbenchmark 'million.eg' which computes the sum of the first million numbers ran in 16 seconds on my old intel laptop. It's just a fold: foldl (+) 0 (fromto 0 1000000)

Observe:

egel % time egel examples/million.eg 

 

500000500000

egel examples/million.eg  6.94s user 0.10s system 99% cpu 7.061 total