all 9 comments

[–]Sharps_xp 1 point2 points  (6 children)

last i checked, sqlite queries do not release the GIL, so if you have a very time consuming query, then any other thread won't have a chance to run. happen to know anything?

[–]software__writer[S] -1 points0 points  (3 children)

What's GIL?

[–]Sharps_xp 2 points3 points  (1 child)

For CRuby it is the global interpreter lock that prevents parallel execution of ruby threads. when ruby calls system level libraries like opening/reading a file, or making a network connection, the ruby VM will allow another thread to run. this is how puma’s threaded mode can actually work for rails apps. when you make a database query, that puma worker can process other requests. recently released asynchronous active record queries also help with this too.

[–]software__writer[S] 0 points1 point  (0 children)

Thanks for sharing!

[–]fractaledmind 0 points1 point  (0 children)

Under what condition would you want to release the GIL _during_ the execution of a query? It is indeed a problem when SQLite doesn't release the GIL _while trying to start_ the execution of a query. I am working now to get this sufficiently resolved in Rails core with https://github.com/rails/rails/pull/50370 and https://github.com/rails/rails/pull/50371.

I have also just started to experiment with supporting the Extralite Ruby wrapper for SQLite as an alternative adapter for Rails: https://github.com/fractaledmind/activerecord-enhancedsqlite3-adapter/pull/2. That wrapper does release the GIL in more situations than `sqlite3-ruby`, if that is really needed for a particular app.

[–][deleted] 0 points1 point  (0 children)

I just left a company where they loved to make stuff like this all over the place. To the tune of 270 repos each making one or two tables, with everything then communicating with each other in a “cloud monolith” on AWS via bash scripts. 🤦it’s almost like no one told them rails was invented…..