Discussion
Loading...

#Tag

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
algernon the zellij stan
@algernon@come-from.mad-scientist.club  ·  activity timestamp 4 weeks ago

In iocaine, every request is served by a script, and there can be any number of them in flight at the same time. I do not control the threads, and I do not want to. Anything thread bound is a no-go.

Any scripting language I'd even consider embedding needs to separate runtime from environment/context/whatever it ends up calling that thing, and must be able to run any number of scripts concurrently, in isolation.

I pretty much need the engine to be Send + Sync, really.

algernon the zellij stan
@algernon@come-from.mad-scientist.club replied  ·  activity timestamp 4 weeks ago

Interpreters are out aswell, they're never going to match the speed of a compiled language (Roto & wasmtime are compiled to machine code via cranelift).

There are fast-ish languages, like Lua, but my experiments indicate that for iocaine's use-case, neither LuaJIT nor LuaU provide any gains (they usually measured below Lua 5.4!) - my scripts are short, and don't live long, JIT doesn't help much there, as far as I can tell.

I'm willing to add new languages to iocaine, if they match or exceed the speed of Lua, but that's already stretching it. The only reason I have Lua support in iocaine is because of #Fennel. I desperately wanted a lisp. Even if I won't be using it myself, I wanted iocaine to support one. Lua, and thus Fennel, are considerably slower than Roto, but they run at an acceptable speed nevertheless.

Most languages I tried were waaay slower than Lua.

  • Copy link
  • Flag this comment
  • Block
algernon the zellij stan
@algernon@come-from.mad-scientist.club  ·  activity timestamp 3 months ago

I'm currently writing #Fennel examples, and this is delightful. I even managed to make the decide function even more beautiful than it was!

(local ruleset [is-in-ai-robots-txt?
default])

(fn decide [request]
(accumulate [outcome nil
_ f (ipairs ruleset)
&until (not= outcome nil)]
(f request)))

This is perfection.

algernon the zellij stan
@algernon@come-from.mad-scientist.club replied  ·  activity timestamp 3 months ago
Getting started with iocaine is now online.

From nothing to running iocaine + Caddy with ai.robots.txt's robots.json and a few metrics as a starting point.

Contains #Roto, #Lua, and #Fennel - and a few tests too, for each.

  • Copy link
  • Flag this comment
  • Block
algernon the zellij stan
@algernon@come-from.mad-scientist.club  ·  activity timestamp 3 months ago

Woke up, and realized that the thing I though I could maybe add to iocaine 2.6 is far easier to do in a 3.0 context.

So after the 2.5 release tomorrow, I will branch off for 3.0 stuff. Branch, so that I can release 2.6 or 2.5.1 if need be - 3 will take a while.

algernon the zellij stan
@algernon@come-from.mad-scientist.club replied  ·  activity timestamp 3 months ago

I'm currently writing #Fennel examples, and this is delightful. I even managed to make the decide function even more beautiful than it was!

(local ruleset [is-in-ai-robots-txt?
default])

(fn decide [request]
(accumulate [outcome nil
_ f (ipairs ruleset)
&until (not= outcome nil)]
(f request)))

This is perfection.

  • Copy link
  • Flag this comment
  • Block
algernon the zellij stan
@algernon@come-from.mad-scientist.club  ·  activity timestamp 3 months ago

I'm on a bit of a roll lately, and have released #iocaine version 2.4.0 just a few moments ago.

This does not bring that many significant changes as 2.3.0 did, but it does introduce #Lua and #Fennel as languages you can script its decision making with, on top of #Roto, which was introduced in 2.2.0.

While these languages run slower than Roto, they're still very fast, and are not going to be a bottleneck - they do provide a more familiar language to write the decision making in!

Oh, and metrics can now be persisted across restarts.

  • Copy link
  • Flag this post
  • Block
algernon the zellij stan
@algernon@come-from.mad-scientist.club  ·  activity timestamp 3 months ago
[server.request-handler]
path = "tmp/fennel/handler"
language = "fennel"
options = { compiler = "tmp/fennel/fennel.lua" }

Look, 'ma! No Lua shim. The Fennel code is about 40 lines of Rust, a bit of boilerplate wrapping the Lua code.

algernon the zellij stan
@algernon@come-from.mad-scientist.club replied  ·  activity timestamp 3 months ago

And because I give funny names to my structs, the one dealing with #Fennel is called ElegantWeapons.

  • Copy link
  • Flag this comment
  • Block
algernon the zellij stan
@algernon@come-from.mad-scientist.club  ·  activity timestamp 3 months ago

In other #iocaine news, I'm doing some final polishing on #Lua scripting support, to make it as convenient as #Roto.

Right now, there's a differenc between how Lua and Roto scripts are loaded: with Roto, one needs to give a path to a directory, and pkg.roto will be loaded from there, and any imports will be relative to that directory.

With Lua, one gives iocaine a file path, and - currently - needs to set up the package.path search path manually.

So here's what I'll do: I'll make iocaine require a directory for Lua too, and it will add it to package.path, and will require("main"). The required module will also have to return a table with at least a decide key, and an optional run_tests key. This will simplify finding the functions to run, and will greatly reduce the number of special cases.

algernon the zellij stan
@algernon@come-from.mad-scientist.club replied  ·  activity timestamp 3 months ago

After that, I'll try to figure something about how to support #Fennel better, natively. The current idea is to have it exposed as another scripting language, built as a wrapper around the Lua engine, with some additional setup at init time:

  • Load the fennel compiler from somewhere
  • Update fennel.path
  • Run fennel.install()

I could embed the fennel compiler, it is small enough, and releases aren't frequent. So that's an option. I don't want to pull it into the sources, though, so I'd need a way to do grab it during build or something. That's a bit problematic, however.

So the next best thing I could come up with is:

[server.request-handler]
path = "/path/to/some/fennel/code"
language = fennel
options = {
compiler = "/path/to/fennel.lua"
}

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.1 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login