From 9e22eeb777c9bf7d88acb50e8bd9fda3a4525906 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 13:11:45 -0400 Subject: [PATCH 01/11] wip outline --- ...023-04-02-recursive-meta-interpretation.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 _posts/2023-04-02-recursive-meta-interpretation.md diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md new file mode 100644 index 000000000..de488d246 --- /dev/null +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -0,0 +1,39 @@ +--- +title: "Recursive meta interpretation with PyPy" +layout: post +date: 2023-04-01 +--- + +* pypy is a fast python runtime with a tracing just-in-time compiler +* pypy is a big project with a lot of subprojects +* it includes rpython, a python-looking language that compiles to c +* it includes a python interpreter written in rpython +* it includes a system to transform interpreters written in rpython into + tracing jits +* these three component parts are used primarily to create a jit + for python +* but people have written other jits using rpython + * lox: + * https://github.com/cfbolz/yaplox/tree/jit + * https://github.com/hardbyte/pylox + * haskell: + * https://ntnuopen.ntnu.no/ntnu-xmlui/handle/11250/253137?locale-attribute=en + * racket: + * https://github.com/pycket/pycket + * php: + * https://github.com/hippyvm/hippyvm +(below bullet might be removed because it's not necessarily relevant to the +research problem) +* this is hard, for a couple reasons + * rpython is python2 and the world has moved on + * the tooling is slow, which leads to long write-test cycles + * the tooling has tricky error messages, which further exacerbates slow dev + cycles + * rpython type annotations do not use standard PEP 484 type hints, but + instead assertions +* why not upgrade to python 3? that is a lot of work for pypy authors and does + not solve all the other gripes +* other motivation: + * write jits in other languages + * can we go "deeper" in the implementation hierarchy without losing + performance? From 8cca9a67d530f80f5aea57f8ff65cbd7dee39b2a Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 13:52:40 -0400 Subject: [PATCH 02/11] wip --- _posts/2023-04-02-recursive-meta-interpretation.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index de488d246..05a3b50eb 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -31,9 +31,12 @@ research problem) cycles * rpython type annotations do not use standard PEP 484 type hints, but instead assertions +(end "irrelevant" bullet) * why not upgrade to python 3? that is a lot of work for pypy authors and does not solve all the other gripes * other motivation: * write jits in other languages + * avoid the slow development cycle because rpython has been cut out * can we go "deeper" in the implementation hierarchy without losing performance? + * how much warmup do we need? From 47c79061c78ef88eeb730ac9ba1444f486f4cc14 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 14:08:10 -0400 Subject: [PATCH 03/11] wip --- _posts/2023-04-02-recursive-meta-interpretation.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index 05a3b50eb..dead6a11e 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -40,3 +40,14 @@ research problem) * can we go "deeper" in the implementation hierarchy without losing performance? * how much warmup do we need? +* cfbolz has written an interpreter metaslf https://hg.sr.ht/~cfbolz/metaslf +* it is several things: + * an interpreter for a language called slf written in rpython + * wrappers for the rpython jit bindings to expose them to the slf language + * an interpreter for slf written in slf that uses the exposed jit bindings + * (implicitly,) a jit for slf +* questions: + * what is the performance of the rpython-slf implementation? + * what is the performance of the slf-slf implementation? + * if there is a difference, can it be removed by improving rpython or the + client use of the jit bindings? From 223f210b08bb949a3c33861ac952ce415bb8853d Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 14:13:16 -0400 Subject: [PATCH 04/11] wip --- _posts/2023-04-02-recursive-meta-interpretation.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index dead6a11e..3ef8306d2 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -51,3 +51,10 @@ research problem) * what is the performance of the slf-slf implementation? * if there is a difference, can it be removed by improving rpython or the client use of the jit bindings? + * what are the most useful bindings to surface? +* further questions + * can we make a fast jit with only a couple of bindings? + * can we make a fast jit without any bindings---by discovering and + transforming interpreters automatically? + * to find loops, cfbolz proposes value profiling to watch for + slow/never-changing values From 93993c5bf086df61ad57e008758806016e76b743 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 14:50:03 -0400 Subject: [PATCH 05/11] add ocaml rpython --- _posts/2023-04-02-recursive-meta-interpretation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index 3ef8306d2..708e5c61a 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -22,6 +22,8 @@ date: 2023-04-01 * https://github.com/pycket/pycket * php: * https://github.com/hippyvm/hippyvm + * ocaml: + * https://github.com/zielmicha/ocamlpypy (below bullet might be removed because it's not necessarily relevant to the research problem) * this is hard, for a couple reasons From 069b8343f9e030e1a6ed7e352b9035bd8f11fe86 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 15:06:27 -0400 Subject: [PATCH 06/11] Add more impls --- _posts/2023-04-02-recursive-meta-interpretation.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index 708e5c61a..23fcef62d 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -24,6 +24,15 @@ date: 2023-04-01 * https://github.com/hippyvm/hippyvm * ocaml: * https://github.com/zielmicha/ocamlpypy + * RISC-V: + * https://github.com/pydrofoil/pydrofoil + * Ruby: + * https://github.com/topazproject/topaz + * SQLite bytecode vm: + * https://github.com/hpi-swa-lab/SQPyte + * Io: + * https://bitbucket-archive.softwareheritage.org/projects/py/pypy/lang-io.html + * https://github.com/edcrypt/lang-rio (below bullet might be removed because it's not necessarily relevant to the research problem) * this is hard, for a couple reasons From d534a7504169870d9a9e5de7058d09be6397c3ea Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 15:10:23 -0400 Subject: [PATCH 07/11] whitespace --- _posts/2023-04-02-recursive-meta-interpretation.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index 23fcef62d..c6a573846 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -33,8 +33,10 @@ date: 2023-04-01 * Io: * https://bitbucket-archive.softwareheritage.org/projects/py/pypy/lang-io.html * https://github.com/edcrypt/lang-rio + (below bullet might be removed because it's not necessarily relevant to the research problem) + * this is hard, for a couple reasons * rpython is python2 and the world has moved on * the tooling is slow, which leads to long write-test cycles @@ -42,7 +44,9 @@ research problem) cycles * rpython type annotations do not use standard PEP 484 type hints, but instead assertions + (end "irrelevant" bullet) + * why not upgrade to python 3? that is a lot of work for pypy authors and does not solve all the other gripes * other motivation: From cb4a360791faacc7481f943ff29ec6bc798fe9d5 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 15:19:02 -0400 Subject: [PATCH 08/11] add note about webservers --- _posts/2023-04-02-recursive-meta-interpretation.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index c6a573846..b0bfe5df6 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -69,6 +69,9 @@ research problem) * what are the most useful bindings to surface? * further questions * can we make a fast jit with only a couple of bindings? + * interpreters don't always look like interpreters. a webserver could be an + interpreter of web requests. what annotations need we add, if any, to get + pypy to "understand" the webserver loop? * can we make a fast jit without any bindings---by discovering and transforming interpreters automatically? * to find loops, cfbolz proposes value profiling to watch for From 12124232134980a5f04678aa27d0f657503ad367 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 17:33:05 -0400 Subject: [PATCH 09/11] move question --- _posts/2023-04-02-recursive-meta-interpretation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index b0bfe5df6..44d52af4c 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -52,9 +52,6 @@ research problem) * other motivation: * write jits in other languages * avoid the slow development cycle because rpython has been cut out - * can we go "deeper" in the implementation hierarchy without losing - performance? - * how much warmup do we need? * cfbolz has written an interpreter metaslf https://hg.sr.ht/~cfbolz/metaslf * it is several things: * an interpreter for a language called slf written in rpython @@ -76,3 +73,6 @@ research problem) transforming interpreters automatically? * to find loops, cfbolz proposes value profiling to watch for slow/never-changing values + * can we go "deeper" in the implementation hierarchy without losing + performance? + * how much warmup do we need? From a097a6a96c8822f101764b9b955f8f83f6b1e8f4 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Mon, 20 Mar 2023 17:35:32 -0400 Subject: [PATCH 10/11] nit --- _posts/2023-04-02-recursive-meta-interpretation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index 44d52af4c..3dca8e3ec 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -58,6 +58,8 @@ research problem) * wrappers for the rpython jit bindings to expose them to the slf language * an interpreter for slf written in slf that uses the exposed jit bindings * (implicitly,) a jit for slf +* clarification: the fact that this is possible has nothing to do with the + surface-level syntactic similarity between the two languages * questions: * what is the performance of the rpython-slf implementation? * what is the performance of the slf-slf implementation? From b079b2e0465f456af29983f7782027bb723dd601 Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Tue, 28 Mar 2023 17:22:26 -0400 Subject: [PATCH 11/11] Add note on graal/pe --- _posts/2023-04-02-recursive-meta-interpretation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_posts/2023-04-02-recursive-meta-interpretation.md b/_posts/2023-04-02-recursive-meta-interpretation.md index 3dca8e3ec..66d91c210 100644 --- a/_posts/2023-04-02-recursive-meta-interpretation.md +++ b/_posts/2023-04-02-recursive-meta-interpretation.md @@ -78,3 +78,5 @@ research problem) * can we go "deeper" in the implementation hierarchy without losing performance? * how much warmup do we need? +* related work + * graal is the other big meta-jit, but they use partial evaluation