Live data from Hacker News

Copy-and-Patch: A Copy-and-Patch Tutorial

transactional.blog

1–10 of 22 posts

Re: Copy-and-Patch: A Copy-and-Patch Tutorial

#4
Related:

Copy-and-Patch: Fast compilation for high-level languages and bytecode (2020) https://news.ycombinator.com/item?id=40553448 - June 2024 (51 comments)

A copy-and-patch JIT compiler for CPython - https://news.ycombinator.com/item?id=38769874 - Dec 2023 (68 comments)

Copy-and-Patch: Fast JIT Compilation for SQL, WebAssembly, and Others - https://news.ycombinator.com/item?id=28547057 - Sept 2021 (7 comments)

Re: Copy-and-Patch: A Copy-and-Patch Tutorial

#5

I think this technique also lies at the heart of the Cranelift project. https://cranelift.dev/

IIRC Cranelift doesn't use copy-and-patch. It uses e-graphs [0] as part of its optimization pipeline, though.

Closest thing in (relatively) recent news that uses copy-and-patch I can think of is CPython's new JIT.

[0]: https://github.com/bytecodealliance/rfcs/pull/27

Re: Copy-and-Patch: A Copy-and-Patch Tutorial

#6

I think this technique also lies at the heart of the Cranelift project. https://cranelift.dev/

IIRC Cranelift doesn't use copy-and-patch. It uses e-graphs [0] as part of its optimization pipeline, though. Closest thing in (relatively) recent news that uses copy-and-patch I can think of is CPython's new JIT. [0]: https://github.com/bytecodealliance/rfcs/pull/27

My understanding is that e-graphs take care of selecting the best patch (by examining many options in parallel) but fundamentally it is still copy-and-patch.

Re: Copy-and-Patch: A Copy-and-Patch Tutorial

#7

Earlier quoted context omitted.

IIRC Cranelift doesn't use copy-and-patch. It uses e-graphs [0] as part of its optimization pipeline, though. Closest thing in (relatively) recent news that uses copy-and-patch I can think of is CPython's new JIT. [0]: https://github.com/bytecodealliance/rfcs/pull/27

My understanding is that e-graphs take care of selecting the best patch (by examining many options in parallel) but fundamentally it is still copy-and-patch.

Could you elaborate more on "fundamentally it is still copy-and-patch"? From what I can recall when I had first read about copy-and-patch a not-uncommon comparison was against Cranelift, which to me would imply that different approaches were taken. I don't recall any discussion about Cranelift's use of the technique, either, so your claim that it's at the heart of Cranelift is new information to me. Has Cranelift adopted copy-and-patch (maybe for a specific compilation stage?) in the meantime?

Re: Copy-and-Patch: A Copy-and-Patch Tutorial

#8

Earlier quoted context omitted.

My understanding is that e-graphs take care of selecting the best patch (by examining many options in parallel) but fundamentally it is still copy-and-patch.

Could you elaborate more on "fundamentally it is still copy-and-patch"? From what I can recall when I had first read about copy-and-patch a not-uncommon comparison was against Cranelift, which to me would imply that different approaches were taken. I don't recall any discussion about Cranelift's use of the technique, either, so your claim that it's at the heart of Cranelift is new information to me. Has Cranelift ado…

You are right. Somehow I had in my mind that e-graphs worked with pre-compiled snippets of code but it seems Cranelift does not do that.

Re: Copy-and-Patch: A Copy-and-Patch Tutorial

#10

Earlier quoted context omitted.

My understanding is that e-graphs take care of selecting the best patch (by examining many options in parallel) but fundamentally it is still copy-and-patch.

Could you elaborate more on "fundamentally it is still copy-and-patch"? From what I can recall when I had first read about copy-and-patch a not-uncommon comparison was against Cranelift, which to me would imply that different approaches were taken. I don't recall any discussion about Cranelift's use of the technique, either, so your claim that it's at the heart of Cranelift is new information to me. Has Cranelift ado…

Indeed, the original copy-and-patch paper explicitly compares against Cranelift: https://fredrikbk.com/publications/copy-and-patch.pdf
Post reply on HN