[Factor-talk] Threaded Code?

2017-01-31 Thread Alexander Ilin
Hello!

  Does Factor use threaded code in any way?
  https://en.wikipedia.org/wiki/Threaded_code

---=--- 
 Александр

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Threaded Code?

2017-01-31 Thread Björn Lindqvist
Probably not! I've never heard of that technique. From skimming that
Wikipedia article it seem to be a compiler optimization invented a
long time ago. We have an instruction called ##dispatch, used for
method dispatching, but it is not nearly as dynamic as the method
described. Probably for the best because on modern processors jumping
to addresses kept in memory or in registers is very bad for
performance.


2017-01-31 21:11 GMT+01:00 Alexander Ilin :
> Hello!
>
>   Does Factor use threaded code in any way?
>   https://en.wikipedia.org/wiki/Threaded_code
>
> ---=---
>  Александр
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Startup time

2017-01-31 Thread John Benediktsson
Part of the startup time is calling all of our "startup hooks", of which I
have 35 right now in my Factor instance, in all of these vocabularies:

{
"alien"
"destructors"
"alien.strings"
"io.backend"
"source-files.errors"
"compiler.units"
"vocabs"
"io.files"
"vocabs.loader"
"command-line"
"threads"
"cpu.x86.features"
"io.thread"
"core-foundation.run-loop"
"environment"
"io.backend.unix:signal-pipe-thread"
"io.launcher"
"random.unix"
"bootstrap.random"
"io.sockets:ipv6-supported?"
"openssl"
"tools.crossref"
"cocoa"
"io.files.temp"
"tools.deprecation"
"core-foundation"
"vocabs.cache"
"vocabs.refresh.monitor"
"opengl.gl"
"opengl"
"ui"
"core-text.fonts"
"core-text"
"tools.errors.model"
"ui.tools.error-list"
}

I'm sure a lot of that could be delayed in smart ways to make startup time
faster, that's what I meant by low hanging fruit, but also not something
that anyone is working on right now.

Best,
John.

On Mon, Jan 30, 2017 at 12:40 PM,  wrote:

> On 2017-01-30 18:14, Timothy Hobbs wrote:
> > If you are on linux, you might try this very new feature:
> > https://criu.org/Main_Page
> >
> > On 01/30/2017 17:29, Jim Mack wrote:
> >> You could also set up factor as a local web server, and send bash
> >> requests to it through a web page, and it would be able to accomplish
> >> them locally (or remotely) and report you the results.  It would be a
> >> quick round-trip cycle with great feedback and the ability to bookmark
> >> commands.
> >>
> >> On Sun, Jan 29, 2017 at 1:39 PM,  >> > wrote:
> >>
> >> On 2017-01-29 16:20, John Benediktsson wrote:
> >> > It would be nice to improve startup time. I imagine some low
> >> hanging
> >> > fruits if we looked deeply into it. I'll make a note to get that
> >> on my
> >> > list, unless someone looks into it sooner.
> >> >
> >> >
> >> >
> >> >> On Jan 28, 2017, at 2:25 PM, pet...@riseup.net
> >>  wrote:
> >> >>
> >> >> I spend a lot of time writing small scripts, often in bash.
> >> That is
> >> >> becoming a more and more painful task as bash is a nice-enough
> >> >> language
> >> >> on the first look but in the end it seems to go out of it's way
> >> to
> >> >> trip
> >> >> you up with every character you type. I don't mean to rant, I
> >> know
> >> >> it's
> >> >> an old language that has to keep a lot of backward
> >> compatibility and
> >> >> it
> >> >> actually still serves very well for what it was designed for,
> >> as long
> >> >> as
> >> >> your script stays <100 lines. Still, there's a lot to be
> >> desired.
> >> >>
> >> >> Factor is a cool language, it's very expressive, mature, has a
> >> lot of
> >> >> libraries and has all sorts of tricks up its sleaves to bend it
> >> to
> >> >> your
> >> >> will (much like lisp in that regard). It would be a fun
> >> experiment to
> >> >> write a library or EDSL (embedded DSL) for bash-like scripting.
> >> >> However
> >> >> there's a bone to be picked:
> >> >>
> >> >> $ time bash -c ''
> >> >> bash -c ''  0.00s user 0.00s system 94% cpu 0.004 total
> >> >>
> >> >> $ time factor-vm -e=''
> >> >> factor-vm -e=''  0.12s user 0.05s system 99% cpu 0.178 total
> >> >>
> >> >> I know one can create a custom image and maybe cut down on the
> >> startup
> >> >> a
> >> >> bit, but my question is - would it be possible to cut it down
> >> to
> >> >> bash's
> >> >> startup time *and* still have all the necessary vocabularies in
> >> it? I
> >> >> don't want to know the startup time with a small image that has
> >> like
> >> >> nothing in it, I can quickly test that myself. I'd need help to
> >> answer
> >> >> -
> >> >> if you imagine the use case I'm talking about, include all the
> >> vocabs
> >> >> that use case would need and make all other possible
> >> optimizations (if
> >> >> there are) without sacrificing too much, can the startup reach
> >> similar
> >> >> times?
> >> >>
> >> >> --
> >> >> 
> >> >>   Peter Nagy
> >> >> 
> >> >>
> >> >>
> >>
> >> 
> --
> >> >> Check out the vibrant tech community on one of the world's most
> >> >> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> >> >> ___
> >> >> Factor-talk mailing list
> >> >> Factor-talk@lists.sourceforge.net
> >> 
> >> >> https://lists.sourceforge.net/lists/listinfo/factor-talk
> >> 
> >> >
> >> >
> >>
> >> ---

Re: [Factor-talk] Threaded Code?

2017-01-31 Thread Levi Pearson
https://concatenative.org/wiki/view/Factor/Non-optimizing%20compiler

Apparently the JIT for the interactive non-optimizing compiler generates
subroutine threaded code with some inlining.

I wouldn't call it a compiler optimization; maybe an interpreter
optimization or a simple compiling technique. I think you hear about it a
lot with respect to Forth and its family because of the proportion of Forth
users who implemented the language or at least learned how it was
implemented, although often modern Forth implementations have optimizing
compilers. But the earliest academic reference I've seen for threaded code
was in reference to a Fortran compiler for the PDP-11:
http://home.claranet.nl/users/mhx/Forth_Bell.pdf

I'm pretty sure that 1971 article was more of a description of a technique
already widely in practice (i.e. a description of "folklore") rather than a
new invention, so it's definitely been around a whlie.

I wrote a simple threaded code interpreter in C as an exercise to
understand them better a while back; including some conditionally-compiled
debug code and a fairly small complement of core Forth words and an outer
interpreter loop, it's still well under 1k lines of source.

--Levi

On Tue, Jan 31, 2017 at 3:23 PM, Björn Lindqvist  wrote:

> Probably not! I've never heard of that technique. From skimming that
> Wikipedia article it seem to be a compiler optimization invented a
> long time ago. We have an instruction called ##dispatch, used for
> method dispatching, but it is not nearly as dynamic as the method
> described. Probably for the best because on modern processors jumping
> to addresses kept in memory or in registers is very bad for
> performance.
>
>
> 2017-01-31 21:11 GMT+01:00 Alexander Ilin :
> > Hello!
> >
> >   Does Factor use threaded code in any way?
> >   https://en.wikipedia.org/wiki/Threaded_code
> >
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk