ryanc
2020-12-17 08:44:05

The db library currently only creates one extra place to perform queries. One solution would be to create a separate non-place connection for the query you expect to be short. Or I can add the ability to create db places and choose which one is used by a new connection. (Place creation and initialization is somewhat expensive, so I didn’t want to create a new place per connection by default.)


jxonas
2020-12-17 12:48:48

I see. To give some context:

On a cliente, we have a “document format” built on top of SQLite, each document being a SQLite file on the server. Currently we have a Java web app to expose and manage the documents (versioning, editing, generating reports, etc). Depending on the day of the month, we can have about 200 people working simutaneously on 150 different documents. So basically we have lots of shortlived connections to multiple SQLite databases. This app is in production for some time and is working fine, but…

We are working on a prototype for a 2.0 version that builds on this “conceptual core” and adds workflow, data validation, custom users scripts, etc. We’ll build it from scratch, and hopefully in Racket =)

Given the strong dependency on SQLite as our data storage format (and we don’t have any reasons to change that in the forseable future), is there alternatives for this use case? Maybe we can build a specific SQLite API via FFI?


jxonas
2020-12-17 14:09:47

I think now I understand the problem: Racket threads are not “OS threads”, so if a ffi call take some time, the whole thing blocks. Places are “OS threads”, that’s why we need them…


samth
2020-12-17 14:56:07

Just opened a PR for the define-inline bug


samdphillips
2020-12-17 19:30:10

Does anyone have useful tricks in hunting down memory leaks in long running Racket programs?


jonathan.arrender.smi
2020-12-17 19:39:41

@jonathan.arrender.smi has joined the channel


samth
2020-12-17 19:52:03

The not-very-documented (dump-memory-stats) is helpful here.


samth
2020-12-17 19:52:21

particularly because you can get backtraces indicating what keeps objects alive


laurent.orseau
2020-12-17 19:53:01

One thing I’ve learned I should keep in mind is ‘reachability’. The GC can’t claim objects that may still be reachable later.


laurent.orseau
2020-12-17 19:55:31

(like an if where you know the condition is false but the compiler doesn’t figure it out)


samdphillips
2020-12-17 20:07:50

Wow, (dump-memory-stats) does look helpful


yilin.wei10
2020-12-17 20:55:44

Is there a way to get a struct with prop:struct-info and prop:rename-transformer to play nicely together?


yilin.wei10
2020-12-17 20:55:57

#lang racket (require (for-syntax racket/struct-info)) (begin-for-syntax ;; Simplified compile-time metadata (struct my:struct-info [info] #:transparent ;; If the rename-transformer doesn't exist, the match expander works #:property prop:rename-transformer (λ (stx) (cadr (my:struct-info-info stx))) #:property prop:struct-info (λ (stx) (my:struct-info-info stx)))) (define-syntax foo (my:struct-info (list #f #'cons #'pair? (list #'car #'cdr) (list #f) #t))) (foo 1 1) ;; Illegal syntax error in pattern (match '(1 . 2) [(foo x y) x])


samth
2020-12-17 20:58:08

Can you add a layer of indirection?


yilin.wei10
2020-12-17 20:58:53

Sorry, I don’t quite understand what you mean by a layer of indirection (not sure where it would help?).


samth
2020-12-17 20:59:28

A macro that expands into something that has the struct info property


samth
2020-12-17 20:59:46

alternatively you could make it a match expander


yilin.wei10
2020-12-17 21:00:53

Oh I see - you mean the rename expands into something with a struct-info?


samth
2020-12-17 21:01:19

Yes


yilin.wei10
2020-12-17 21:02:41

Yeah - I think I can do that. (I’d ideally not go down the match-expander route because I wanted them to have the same id).


samdphillips
2020-12-17 21:08:02

What do each of the columns generally mean?


gknauth
2020-12-17 21:18:24

maybe objects and bytes?


gknauth
2020-12-17 21:21:03

hex number or do I have much more memory than I thought? # of installed finalizers: 4e34


samdphillips
2020-12-17 21:21:38

I’m on CS so I think the format may be a little different. At least according to the docs.


yilin.wei10
2020-12-17 21:25:46

Hmm - I’m not sure it works; it expands the rename recursively so no-matter how many levels of indirection I’m using, if I have a rename at that level (which I need to otherwise the constructor isn’t bound). @samth maybe I’m misunderstanding your suggestion?


sorawee
2020-12-17 23:06:35

I’m working on a language that simulates variables using set!-transformer. How should I deal with #%variable-reference?

More elaborately, I transform:

(define-values (x) v) into

(splicing-let ([x* (box v)]) (define-syntax x (syntax-id-rules (set!) [(set! _ b) (set-box! x* b)] [(_ . args) ((unbox x*) . args)] [_ (unbox x*)]))) x is now a macro, so it doesn’t have a location, so (#%variable-reference x) fails. I also try changing it to (#%variable-reference x*), but that somehow fails too.


sorawee
2020-12-17 23:11:51

This is a transformation at #%module-begin, FWIW, since I want to catch everything that expands to define-values.


soegaard2
2020-12-17 23:16:12

I suppose you could change (define-values (x) v) to (define-values (x) v) (define-values (x-loc) 'dummy) and let the location of x-loc represent the location of x.

But maybe there is something simpler?


sorawee
2020-12-17 23:18:36

Oh, of course, splicing-let will fail because x* is out of scope outside splicing-let, duh


sorawee
2020-12-17 23:18:53

Yep, an additional define-values should do the trick, thanks!


soegaard2
2020-12-17 23:19:13

I see that (#%variable-reference) produces an anonymous variable reference. Could (#%variable-reference x) simply expand to (#%variable-reference) ?


sorawee
2020-12-17 23:22:04

Confirmed define-values works! I honestly am not sure about the semantics of #%variable-reference, so I would leave it alone for now.


kellysmith12.21
2020-12-18 03:42:02

I have learned that managing srclocs for good errors is an art, and syntax/loc is your friend.