peschkaj
2017-10-27 15:35:25

@peschkaj has joined the channel


dedbox
2017-10-27 16:54:28

Hey, everyone. It’s good to see chatter in here.


dedbox
2017-10-27 17:06:33

The net2 design docs are easy to read. After the concepts are flushed out and the API starts to form, I should be more helpful.


notjack
2017-10-27 18:00:36

@peschkaj hi! :wave:


notjack
2017-10-27 18:03:12

@dedbox which reminds me: Axon is very interesting. I want net2 to allow transports between named agents in different Racket threads, and it might be easier to design that by integrating it with Axon to prove the concept


peschkaj
2017-10-27 18:03:22

hello, @notjack


dedbox
2017-10-27 18:33:51

@notjack named agents, as in actors or maybe pi calculus channels?


notjack
2017-10-27 18:37:37

@dedbox named agents as in “things that can answer authoritatively for a specific URI authority”


dedbox
2017-10-27 18:38:39

@notjack ok, so universally named agents.


notjack
2017-10-27 18:39:12

yes, so non-axon networks can communicate with axon networks and vice versa


dedbox
2017-10-27 18:42:21

Cool! I see a lot of overlapping concepts between net2 and axon.


notjack
2017-10-27 18:43:08

agreed


notjack
2017-10-27 18:43:41

I think I want net2 to be responsible for providing what’s needed for Racket concurrency / distribution abstractions to talk to the wider internet


notjack
2017-10-27 18:43:49

so, URIs


notjack
2017-10-27 18:44:19

I’m not planning on implementing any new sort of concurrency paradigm like axon / marketplace / syndicate


notjack
2017-10-27 18:44:51

but I do want a racket program to be able to run servers implemented in axon / marketplace / syndicate all at once in the same Racket process, and I want non-racket programs to be able to talk to those servers


dedbox
2017-10-27 18:45:11

It’s tempting to keep plugging on code,. Maybe it’s better to document concepts first, to discuss?


notjack
2017-10-27 18:45:53

I wrote some of this in the ROADMAP.md doc, described as “Racket Transport Addresses” (or something like that, not remembering off the top of my head)


notjack
2017-10-27 18:46:32

more discussion here gladly welcomed


dedbox
2017-10-27 18:56:46

Ok, so axon gives TCP connectors and listeners, and sexp (and json and HTTP1) messengers.


dedbox
2017-10-27 18:58:08

A core design principle is to hoist ordinary functions to network-bound actor-like filters.


notjack
2017-10-27 19:00:22

gotcha, looking over the tests I was able to see how it let you take functions and (in my basic, fuzzy understanding) turn them into unix processes with lifetimes that can send and receive their results and arguments


dedbox
2017-10-27 19:02:16

Close! It uses racket threads l.


notjack
2017-10-27 19:02:40

right, each “process” wraps a thread that can be both gracefully and forcibly killed by other “processes”


notjack
2017-10-27 19:02:51

and a process can have shutdown / termination logic


notjack
2017-10-27 19:03:21

and they’re racket green threads, so super cheap and you can have a million of ’em


notjack
2017-10-27 19:07:24

(I’m assuming you’re typing stuff? no rush but slack keeps changing its mind on whether you are)


dedbox
2017-10-27 19:07:39

Yeah, that’s pretty much the whole of it. Re-reading ROADMAP.md now.


dedbox
2017-10-27 19:08:00

On phone. Slack gets extra confused


notjack
2017-10-27 19:08:04

gotcha


notjack
2017-10-27 19:08:06

how familiar are you with http virtual hosting?


dedbox
2017-10-27 19:10:00

I built out a few large HTTP virtual hosting services, before “the cloud.”


notjack
2017-10-27 19:10:12

perfect


notjack
2017-10-27 19:13:29

so an explicit feature I want net2 to enable is for a single Racket process with a single Racket thread to offer multiple http APIs to the internet by way of virtual hosting and using racket transport addresses to locate distinct in-memory servers and communicate their locations to arbitrary internet clients


notjack
2017-10-27 19:15:41

basically I want a single racket program to be able to run multiple http services / proxies / gateways etc, and I want client code in that racket program to interact with those services without having to know that they’re local so that deployment topology is transparent to the client


notjack
2017-10-27 19:16:23

which means URI trickery


dedbox
2017-10-27 19:18:53

So, you want all agents to appear “remote,” even though some might be local?


notjack
2017-10-27 19:19:32

yes - or at least, I want the interface to remote and local agents to allow changing an agent from local to remote without requiring that clients of that agent be restarted or redeployed


notjack
2017-10-27 19:20:30

otherwise, distributed programming will never be simple


notjack
2017-10-27 19:22:14

oops - in the part above where I said “for a single Racket process with a single Racket thread” I meant “OS thread” in the second part


dedbox
2017-10-27 19:34:59

That’s starting to sound like agent mobility.


dedbox
2017-10-27 19:35:28

but lower level


dedbox
2017-10-27 19:35:35

agent interface mobility?


notjack
2017-10-27 19:36:02

that sounds reasonable


notjack
2017-10-27 19:37:07

the broader problem I’m trying to solve here is making it easier to do things in heterogeneous distributed systems, rather than homogenous ones


dedbox
2017-10-27 19:37:13

You wrote that chains of ports would imact performance. So, routing occurs at the bytes level?


notjack
2017-10-27 19:37:26

yes, because in a heterogenous distributed system messages are a lie


notjack
2017-10-27 19:37:28

there are only bytes


dedbox
2017-10-27 19:38:30

go tit


dedbox
2017-10-27 19:38:32

*got it


notjack
2017-10-27 19:39:11

in net2, communication between authorities will always occur over transports and transports only send and receive bytes


notjack
2017-10-27 19:39:56

to send and receive messages, you have to build messaging protocols on top of byte transports and that is a userland responsibility, not something defined by some common runtime that all parties in the network share


notjack
2017-10-27 19:41:26

because requiring that all agents in the system share a common runtime or a common definition of what bytes are what means you can’t horizontally scale, and it means you can’t communicate at all with agents outside the system that don’t share that runtime - so you end up with two notions of networking, one for “actors inside my collection of distributed erlang nodes” and one for “ugh this is how I do tcp connections to everybody else”


dedbox
2017-10-27 19:42:10

That’s what turned me away from ZeroMQ


dedbox
2017-10-27 19:43:06

The “lower” half of axon tries to solve that problem.


notjack
2017-10-27 19:43:28

which bits are the lower half?


dedbox
2017-10-27 19:44:05

the encoder, for example


dedbox
2017-10-27 19:44:35

it ties a printer to an output-port


dedbox
2017-10-27 19:45:03

then it prints the messages it receives onto the port


dedbox
2017-10-27 19:45:40

I guess by “lower” I meant closer to actual byte IO


notjack
2017-10-27 19:45:49

gotcha


notjack
2017-10-27 19:46:00

yes, that part I imagine net2 being responsible for


notjack
2017-10-27 19:46:43

(in an ideal world, Hackett would be in a position where there’d be ways to easily derive strongly typed, performant byte serializations and deserializations for message types and net2 users would just use that)


dedbox
2017-10-27 19:47:12

That’s good for axon.


dedbox
2017-10-27 19:49:10

It’s supposed to be for concurrent messaging over the network.


dedbox
2017-10-27 19:51:14

All of its major bugs have involved closing ports


notjack
2017-10-27 19:51:52

oh! that’s good to know, because it means choosing to integrate the disposable package directly with net2 is a good idea


notjack
2017-10-27 19:52:36

net2 connectors will (hopefully) manage all connection pooling and connection lifecycles


dedbox
2017-10-27 19:55:16

That’s the only feature from python asyncio I miss in Racket


notjack
2017-10-27 19:55:45

I’ve heard of python asyncio but haven’t used it, how does it handle that?


dedbox
2017-10-27 19:57:23

It just makes the sockets you open play nicely with the cooperative event loop.


dedbox
2017-10-27 19:58:07

But it gives you a way to group sockets together and time events precisely


dedbox
2017-10-27 19:58:24

Racket is more of a thread soup.


dedbox
2017-10-27 19:59:23

End up using more semaphores.


notjack
2017-10-27 20:00:57

interesting



notjack
2017-10-27 20:01:58

heh, they even call abstract bidirectional streams “transports”


dedbox
2017-10-27 20:03:09

I thought so too


dedbox
2017-10-27 20:03:41

I mean, I thought of that doc while reading the roadmap


notjack
2017-10-27 20:04:41

yeah there’s a lot of similar ideas, which is good to see


notjack
2017-10-27 20:05:30

I think the main differentiator net2 will focus on is making host/port/protocol parameters suitably abstract, so we can do weird things like hook up Axon networks to the internet


notjack
2017-10-27 20:07:24

also connection management responsibilities will be divided between disposables and racket custodians and explicitly controllable by those means, instead of just being something magic that the framework does for you


dedbox
2017-10-27 20:07:54

That would be great. I’m writing a multiplayer game server right now. The first version was in python using asyncio, as an exercise. It was not so pleasant.


notjack
2017-10-27 20:08:19

ah, games will be tricky


notjack
2017-10-27 20:08:42

since they often use udp and datagram-based network logic


notjack
2017-10-27 20:09:16

net2 is explicitly not touching that kind of I/O, at least for the near future


dedbox
2017-10-27 20:09:37

That was conspicuously missing from the roadmap. Can you elaborate?


notjack
2017-10-27 20:09:51

sure


notjack
2017-10-27 20:10:11

the gist of it is: that level of I/O is too low for me to get anything useful done if I try to integrate it into racket


notjack
2017-10-27 20:10:37

net2 will assume reliable bidirectional bytestreams exist, and build a pile of stuff on top of that


notjack
2017-10-27 20:10:39

however!


notjack
2017-10-27 20:11:37

if a different library implemented ways to define reliable bidi bytestream protocols on top of datagram based sockets, possibly in ways that let programs assume things you can’t assume in TCP so you can get better perf, then that library could use net2 to make transports that the rest of net2 could work on top of


notjack
2017-10-27 20:12:29

and if that doesn’t work, it ought to be possible to adapt net2 codecs and messengers to work with datagram communication without serious effort


notjack
2017-10-27 20:13:19

so there’s parts of net2 that could in theory work with that sort of communication, but making it a design constraint means I’d have to do a lot more work before I could make interesting things with http on top of net2


notjack
2017-10-27 20:14:23

many multiplayer games that don’t have very strict latency requirements can often be made to work over TCP though, so it’s not a total loss


notjack
2017-10-27 20:15:49

also, the Tokio framework in Rust is breaking a lot of new ground in this area already so I’d like to give them more time to figure these design problems out so I don’t have to :p


notjack
2017-10-27 20:17:08

tonyg has done a bunch of stuff in that space too (have you seen his library for talking to ethernet directly in racket? so cool)


dedbox
2017-10-27 20:18:28

I thought it might fit nicely. Generalize port+address to URI. Provide encoders to chunk or truncate messages over ~64K. Do not provide UDP transport. That takes care of at least 80% of UDP use cases and keeps me in the library.


notjack
2017-10-27 20:19:24

it’s definitely possible, and likely possible to do quite nicely


notjack
2017-10-27 20:19:36

just not gonna spend time thinking about it yet


dedbox
2017-10-27 20:19:46

axon has code for that right now


dedbox
2017-10-27 20:20:40

the only missing Racket piece to this game server is a user-friendly linear algebra engine


notjack
2017-10-27 20:20:50

the udp.rkt module I presume?


notjack
2017-10-27 20:20:52

oh!


notjack
2017-10-27 20:20:58

there’s a package for that I think



notjack
2017-10-27 20:21:15

raco pkg install glpk


notjack
2017-10-27 20:21:37

hmm, I’m not sure if that’s for general linear algebra though


notjack
2017-10-27 20:21:51

seems to only be for limited kinds of optimization problems involving linear algebra?


notjack
2017-10-27 20:22:01

….it’s been a very long time since I took classes on this stuff


dedbox
2017-10-27 20:23:41

Cool, thanks.


notjack
2017-10-27 20:35:43

@dedbox btw I peeked at your game server, specifically the sqlite querying parts. I think @royall is considering how to make sql nicer in Racket so you two might have stuff to talk about there.


dedbox
2017-10-27 21:42:33

dedbox
2017-10-27 21:43:09

It shows TCP and UDP in action together.


dedbox
2017-10-27 21:44:27

At top, it listens for UDP broadcast pings for local server discovery.


dedbox
2017-10-27 21:44:40

Then, it uses TCP for asset data exchange.


dedbox
2017-10-27 21:45:34

Finally, it uses UDP again to blast world state updates l.


dedbox
2017-10-27 21:47:19

This hybrid approach is convenient, reliable, and performant in the right places, and the API for both protocols is similar.


notjack
2017-10-27 21:48:08

what performance are you targeting? in terms of latency between clients seeing state changes


dedbox
2017-10-27 21:48:25

The SQL is a necessary evil at this point. I wouldn’t mind a friendlier persistence API.


dedbox
2017-10-27 21:49:16

Low latency for world updates, low complexity for asset exchange and session management.


notjack
2017-10-27 21:51:41

low latency as in less than a second, less than a few frames in 60fps, or less than a millisecond? ballpark guesses are fine


dedbox
2017-10-27 21:52:13

Single digits milliseconds.


notjack
2017-10-27 21:53:00

okay, that’s entirely doable with TCP and nontrivial messages


notjack
2017-10-27 21:53:22

depending on ping latency


dedbox
2017-10-27 21:54:46

Sure. This hybrid pattern represents a more general use case, for things like VoIP and RTSP.


notjack
2017-10-27 21:55:50

gotcha


dedbox
2017-10-27 22:09:05

Cool, so now I can imagine how axon would use net2. Maybe I can sketch some example uses.


notjack
2017-10-27 22:12:11

I’ll need to figure out and document how racket transport addresses work first, which I’ll do after I get connectors, listeners, and TCP/TLS/Unix transports implemented


royall
2017-10-27 22:30:19

I’m thinking specifically of some database conveniences along the lines of Clojure’s HugSQL. Probably a good excuse to build myself a #lang and include some conveniences like optionally using transactions for bulk writes or returning large result sets via generator.


royall
2017-10-27 22:30:33

partial markdown be damned


royall
2017-10-27 22:30:56

tbqh I don’t understand half of today’s conversation, so this will all be a nice learning experience for me


royall
2017-10-27 22:33:17

I want to finish my current project of building a knockoff of the Symfony CLI component before starting something else in earnest


royall
2017-10-27 22:33:59

It’s not a good language, but PHP’s widespread adoption means there’s lots of handy libraries for it. I’d like to see Racket have the same level of off-the-shelf convenience for common tasks.


notjack
2017-10-27 22:36:28

@royall the practical upshot of the stuff talked about is that if you’ve got some racket code that needs to talk to some http API, and that API does something weird, your racket code can easily start a proxy server between you and that API and that proxy can translate the weird API into a much cleaner API. So it’s easy to make reusable standards-based HTTP client libraries that do really powerful and neat things, but you still use them with actual real-life non-standards-based HTTP services.


royall
2017-10-27 22:37:47

When you put it that way, it sounds really superb


notjack
2017-10-27 22:39:28

like, HTTP auth schemes are really incredible and can be dynamically discovered and reconfigured on the fly. But fucking nobody uses them (pardon my french). So a client library that does those fancy things is useless unless it’s easy to translate between existing services like AWS or whatever the startup kids are using these days.


dedbox
2017-10-28 01:34:35

@royall hello!


dedbox
2017-10-28 01:35:51

@notjack will net2 support half-open TCP connections?


notjack
2017-10-28 01:39:43

@dedbox I would like it to, though at the moment I’m relying on the kernel tcp / ip stack which doesn’t grant as much control over that


dedbox
2017-10-28 01:42:15

I had trouble making the client side see when the serving side closes its out-port.


dedbox
2017-10-28 01:42:33

when the client was already waiting to receive


dedbox
2017-10-28 01:42:59

Do you know if that’s expected TCP or Racket behavior?


notjack
2017-10-28 01:43:28

It depends on whether the connection was closed gracefully, forcibly, or just abandoned


dedbox
2017-10-28 01:43:56

close-output-port


notjack
2017-10-28 01:46:16

That’s a graceful close. The kernel will send a TCP FIN packet which should cause the kernel on the other end to close the connection, then in racket land you’ll get an eof? value when you try to read from the port


notjack
2017-10-28 01:46:32

Assuming both sides of connection are implemented in racket?


dedbox
2017-10-28 01:47:08

yes


notjack
2017-10-28 01:48:59

Forceful close is sending TCP RST packet, abandoned is one side just stops sending anything at all (like if network connectivity dropped) and the other side closes when it can’t receive ACKs on either sent data or heartbeat packets


notjack
2017-10-28 01:49:52

With the racket/tcp module, there is no way for racket code to send anything other than a FIN packet


notjack
2017-10-28 01:50:19

Only kernel is capable of RST or abandoning


dedbox
2017-10-28 01:56:16

Ok, good to know.