Should we move the resowner field from JitContext to LLVMJitContext?

Started by Andreas Karlssonalmost 2 years ago3 messageshackers
Jump to latest
#1Andreas Karlsson
andreas.karlsson@percona.com

Hi,

I am implementing my own JIT plugin (based on Cranelift) for PostgreSQL
to learn more about the JIT and noticed an API change in PostgreSQL 17.

When Heikki made the resource owners extensible in commit
b8bff07daa85c837a2747b4d35cd5a27e73fb7b2 the API for JIT plugins changed
when ResourceOwnerForgetJIT() was moved from the generic JIT code to the
LLVM specific JIT code so now the resowner field of the context is only
used by the code of the LLVM plugin.

Maybe a bit late in the release cycle but should we make the resowner
field specific to the LLVM code too now that we already are breaking the
API? I personally do not like having a LLVM JIT specific field in the
common struct. Code is easier to understand if things are local. Granted
most JIT engines will likely need similar infrastructure but just
providing the struct field and nothing else does not seem very helpful.

See the attached patch.

Andreas

Attachments:

0001-Move-resowner-from-common-JitContext-to-LLVM-specifi.patchtext/x-patch; charset=UTF-8; name=0001-Move-resowner-from-common-JitContext-to-LLVM-specifi.patchDownload+8-8
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Andreas Karlsson (#1)
Re: Should we move the resowner field from JitContext to LLVMJitContext?

On 5 Jun 2024, at 10:19, Andreas Karlsson <andreas@proxel.se> wrote:

When Heikki made the resource owners extensible in commit b8bff07daa85c837a2747b4d35cd5a27e73fb7b2 the API for JIT plugins changed when ResourceOwnerForgetJIT() was moved from the generic JIT code to the LLVM specific JIT code so now the resowner field of the context is only used by the code of the LLVM plugin.

Maybe a bit late in the release cycle but should we make the resowner field specific to the LLVM code too now that we already are breaking the API? I personally do not like having a LLVM JIT specific field in the common struct. Code is easier to understand if things are local. Granted most JIT engines will likely need similar infrastructure but just providing the struct field and nothing else does not seem very helpful.

I'm inclined to agree, given that the code for handling the resowner is private
to the LLVM implementation it makes sense for the resowner to be as well. A
future JIT implementation will likely need a ResourceOwner, but it might just
as well need two or none.

--
Daniel Gustafsson

#3Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Daniel Gustafsson (#2)
Re: Should we move the resowner field from JitContext to LLVMJitContext?

On 01/07/2024 17:19, Daniel Gustafsson wrote:

On 5 Jun 2024, at 10:19, Andreas Karlsson <andreas@proxel.se> wrote:

When Heikki made the resource owners extensible in commit b8bff07daa85c837a2747b4d35cd5a27e73fb7b2 the API for JIT plugins changed when ResourceOwnerForgetJIT() was moved from the generic JIT code to the LLVM specific JIT code so now the resowner field of the context is only used by the code of the LLVM plugin.

Maybe a bit late in the release cycle but should we make the resowner field specific to the LLVM code too now that we already are breaking the API? I personally do not like having a LLVM JIT specific field in the common struct. Code is easier to understand if things are local. Granted most JIT engines will likely need similar infrastructure but just providing the struct field and nothing else does not seem very helpful.

I'm inclined to agree, given that the code for handling the resowner is private
to the LLVM implementation it makes sense for the resowner to be as well. A
future JIT implementation will likely need a ResourceOwner, but it might just
as well need two or none.

Committed, thanks!

--
Heikki Linnakangas
Neon (https://neon.tech)