Loom compatibility

Abierto
#1,136 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
java, sqlite
Área
database

Línea de trabajo

Start by reviewing the repository’s synchronized blocks and methods, then check which can perform blocking operations and how JNI calls affect virtual thread pinning. The issue also points to OpenJDK’s virtual thread documentation and pgjdbc issue 1951 for context. Done means documenting Loom usage and performance implications, or identifying code changes that improve support; the issue does not specify a concrete test or implementation scope.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

question

Wanted to check the status of this driver running with Loom (https://openjdk.org/projects/loom/).

As far as I understand, jdbc can generally benefit from running on virtual threads instead of actually blocking threads. So, I thought this would be useful for this jdbc driver, but I have not found any discussion about loom or virtual threads in this repo.

There seem to be two things to look out for though, because they can lead to still blocking threads with loom. Taken from the openjdk docs on virtual threads (https://openjdk.org/jeps/425):

There are two scenarios in which a virtual thread cannot be unmounted during blocking operations because it is pinned to its carrier:

    When it executes code inside a synchronized block or method, or
    When it executes a native method or a foreign function.

Pinning does not make an application incorrect, but it might hinder its scalability. If a virtual thread performs a blocking operation such as I/O or BlockingQueue.take() while it is pinned, then its carrier and the underlying OS thread are blocked for the duration of the operation. Frequent pinning for long durations can harm the scalability of an application by capturing carriers.

Doing a quick search in the repo for synchronized, I can see a few occurrences:
https://github.com/search?q=repo%3Axerial%2Fsqlite-jdbc+synchronized+language%3AJava&type=code&l=Java

The question is probably, which one of the synchronized blocks or methods actually contain blocking code and whether we can change them to a ReentrantLock (as proposed).

Another question I have is: We obviously rely on JNI to call the sqlite3 C api and there is no way around it. So I am guessing, this will unavoidably lead to thread pinning. Does anyone know more about that?

Is your feature request related to a problem? Please describe.

The problem for me is currently to understand, whether using this jdbc driver with a virtual thread executor makes sense, and whether we can do things to improve support.

Describe the solution you'd like

I can see two results:

  • documentation on usage with loom and whether it can have a benfit on performance
  • check whether we can do something in the code to improve support

Describe alternatives you've considered

Additional context

Relevant efforts done in pgjdbc for postgres: https://github.com/pgjdbc/pgjdbc/issues/1951

Lenguaje dominante
Java
Estrellas
3.3k
Forks
676
Merge medio
1 d 15 h
PR fusionados (30 d)
18

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de xerial/sqlite-jdbc

Todos los issues de xerial/sqlite-jdbc

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.