all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Cuirass news
Date: Sun, 28 Jan 2018 22:47:34 +0100	[thread overview]
Message-ID: <87fu6pzmdl.fsf@gnu.org> (raw)
In-Reply-To: <20180127181852.42f0bcbf@scratchpost.org> (Danny Milosavljevic's message of "Sat, 27 Jan 2018 18:18:52 +0100")

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> I've now forked guile-sqlite3 and put the stuff that makes sense for a
> low-level binding there (not sqlite-exec - that would still be in guix-cuirass).
>
> These are:
> - stmts hash-table is now in guile-sqlite3's <db>.
> - sqlite-finalize adapted to update <db>'s stmts list
> - sqlite-finalize* variant which doesn't update <db>'s stmts list
> (because the updating by value is slow)
> - sqlite-prepare* macro which stores and reuses existing <stmt>s.
> - sqlite-bind-args convenience function which just binds all the parameters
> in sequence.
> - SQLITE_CONSTRAINT and SQLITE_CONSTRAINT_PRIMARYKEY, moved from guix-cuirass
>
> https://notabug.org/dannym/guile-sqlite3

Good you’re giving it some love.  :-)

I’ve already applied two commits in civodul/guile-sqlite3.  I think the
statement cache requires some more work though (see below).

> If that's OK I'll replace the reference in guix-master, or we could do a
> pull request to the civodul repository.

I think we should stick to a single repo for guile-sqlite3, though it
prolly shouldn’t be called “civodul/”.  Perhaps you can create
guile-sqlite3/guile-sqlite3 and add the two of us plus Andy there for a
start?

>> I’m not sure what ‘sqlsym’ is.  Apparently it’s a symbol derived from
>> the SQL statement, right?  I don’t think it’s necessary.
>
> Yes, the idea is to prevent it from having to do string comparison/hashing
> to find an existing stmt.  It's interned at macro-expansion time - so at
> runtime it shouldn't traverse the sql text after the stmt is created.
>
>> Instead you can simply make that hash table a regular (non-weak) hash
>> table that maps strings (SQL text) to prepared statements.  You’d also
>> need to use ‘hash-set!’ and ‘hash-ref’ instead of ‘hashq-set!’ and
>> ‘hash-ref’ since strings should be compared with ‘equal?’, not ‘eq?’.
>
> That's what I tried to avoid, having it compare 80 character strings
> every time I want to reuse a prepared statement. :-)
>
> What I wanted more is something like a new thread-local variable being
> declared every time a new SQL statement is used, otherwise the existing
> variable being used.

The problem is that interned symbols are potentially not GC’d (though I
think with Guile 2.2 and its weak sets they may be subject to GC.)

The other issue is that we’d still be caching potentially a lot more
than needed.  For instance, we don’t know whether a statement is a
one-off statement (used only once, for instance because it’s derived
from user parameters passed through the HTTP API or something), or if
it’s a statement that’s regularly used.  Excessive caching could be a
real issue for long-running processes like cuirass.

Thinking more about it, I’m inclined to not try to be smart and instead
let users explicitly ask for caching when they want to.

WDYT?

Thanks,
Ludo’.

  parent reply	other threads:[~2018-01-28 21:47 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 22:12 Cuirass news Ludovic Courtès
2018-01-25 10:55 ` Mathieu Othacehe
2018-01-25 10:59   ` Mathieu Othacehe
2018-01-25 13:09     ` Ludovic Courtès
2018-01-26 14:30       ` Danny Milosavljevic
2018-01-27 16:01         ` Ludovic Courtès
2018-01-27 17:18           ` Danny Milosavljevic
2018-01-27 19:12             ` Danny Milosavljevic
2018-01-28 21:47             ` Ludovic Courtès [this message]
2018-01-28 22:23               ` Danny Milosavljevic
2018-01-29  9:57               ` Andy Wingo
2018-02-08 13:37             ` Ludovic Courtès
2018-02-08 16:29               ` Danny Milosavljevic
2018-02-08 22:21                 ` Ludovic Courtès
2018-02-08 23:05                   ` Danny Milosavljevic
2018-02-09  6:17                     ` Gábor Boskovits
2018-02-09  9:41                     ` Ludovic Courtès
2018-02-09 11:29                       ` Danny Milosavljevic
2018-02-09 16:53                         ` Ludovic Courtès
2018-02-09 17:06                           ` Danny Milosavljevic
2018-02-10 11:18                             ` Ludovic Courtès
2018-02-13  9:12                               ` Danny Milosavljevic
2018-02-14 13:43                                 ` Ludovic Courtès
2018-02-14 23:17                                   ` Ludovic Courtès
2018-02-19 15:35                                     ` Danny Milosavljevic
2018-02-19 15:35                                       ` [PATCH] database: Simplify 'db-get-builds' Danny Milosavljevic
2018-02-19 17:52                                       ` [PATCH] database: db-get-builds: Inline output selection Danny Milosavljevic
2018-02-19 22:08                                       ` Cuirass news Danny Milosavljevic
2018-03-02 13:21                                         ` Ludovic Courtès
2018-03-02 22:06                                           ` Ludovic Courtès
2018-03-02 23:29                                           ` Danny Milosavljevic
2018-02-14 23:21                                   ` Ludovic Courtès
2018-01-25 21:06 ` Ricardo Wurmus
2018-01-26 11:12   ` Ludovic Courtès
2018-01-25 22:28 ` Danny Milosavljevic
2018-01-26 10:47   ` Ludovic Courtès
2018-01-28 12:33     ` Cuirass frontend Danny Milosavljevic
2018-01-29 17:42       ` Ludovic Courtès
2018-01-26  0:46 ` Cuirass news Danny Milosavljevic
2018-01-27 17:27   ` Danny Milosavljevic
2018-01-28 21:48     ` Ludovic Courtès
2018-01-26 17:55 ` Jan Nieuwenhuizen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fu6pzmdl.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=dannym@scratchpost.org \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.