Arc Forumnew | comments | leaders | submitlogin
2 points by akkartik 5080 days ago | link | parent

3) get the Racket people to do something (create a "no-gc-here" special form, make it possible to make all pairs mutable by default, something).

Hmm, isn't this just a vanilla racket bug to be filed? GC should be transparent to the program.



1 point by aw 5080 days ago | link

isn't this just a vanilla racket bug to be filed? GC should be transparent to the program.

Nope. If you're creating or manipulating Racket data structures yourself, you have to cooperate with the garbage collector to avoid confusing it. http://docs.racket-lang.org/inside/im_memoryalloc.html#(part... describes how.

I don't know how to cooperate with the GC from Racket (instead of from C, as described in the manual) while using pointers to modify Racket data structures. If it's possible, you might be able to get help on how to do it on the Racket mailing list. But it's not a Racket bug.

-----

1 point by akkartik 5080 days ago | link

I don't understand; that link is for the C API, but we're purely in racket land, right?

Edit: Oh, is this because of arc modifying scheme's immutable pairs? <slaps head> Talk about going against the grain of the platform..

-----

3 points by aw 5080 days ago | link

The issue here with GC isn't that we're modifying immutable pairs. It's that we're modifying a Racket data structure ourselves, without letting Racket do it for us, and without cooperating with the garbage collector. (If we modify a Racket data structure ourselves it doesn't matter if we do it from Racket or from C, it's the same issue). We'd have the same GC issue if we were using pointers to modify any Racket data structure, whether mutable pairs or immutable pairs or vectors or whatever.

(That's what performing "unsafe" operations means: we can cause seg faults or mess up the garbage collector. "Safe" operations are ones where we let Racket do the data structure manipulation for us, and so it's a Racket bug if there's a seg fault or GC problem).

That we're modifying Racket's immutable pairs could potentially give us a another bug though. When lists are immutable,

  (let ((x (list 1 2 3)))
    (foo x)
    (car x))
and if the compiler knows that the built-in Racket list and car are being called by "list" and "car" through the module system, the compiler could figure out that it can go ahead and return 1 for this expression without actually having to perform the car operation: the compiler can perform optimizations with immutable pairs that it can't do with mutable pairs. I haven't seen any evidence that this issue has bitten us yet, but it remains a possibility that some future implementation of Racket might perform new optimizations that would mess us up when we're modifying immutable pairs.

-----

1 point by akkartik 5080 days ago | link

Ok, makes sense. I hadn't followed that by 'data structure' you meant 'internal data structure'.

Arc's not just a userland racket program; ptr-set! and ptr-ref are low-level creatures. I hadn't focused on this fact, even though I'd seen the comments at set-ca/dr!

-----

2 points by aw 5080 days ago | link

Exactly. Back in the MzScheme 3xx days Arc was, to MzScheme, just an ordinary (if rather large) MzScheme program. And, with my runtime project (if successful), Arc will once again to Racket be just a big Racket program, so any bugs with Racket will be legitimate Racket bugs that we can go ahead and file a Racket bug report on ^_^

-----

2 points by akkartik 5079 days ago | link

This is actually a pretty big realization for me. Between the documentation thread 2 months ago (http://arclanguage.org/item?id=12860) and this realization that the queue bug is all the fault of our arc implementation, my opinion of the racket runtime is entirely rehabilitated. (http://arclanguage.org/item?id=12302 was the closest thing to a flame war I've been involved in here)

Now my only complaint with mzscheme in general is that it isn't dynamic enough, and forces us to use its module system :) But even that's just because we're using racket in this weird 'backwards compatibility' mode. I'm looking forward to ar because it'll let arc use all of racket's modern goodies (keyword args, extensible equality, ...)

Edit: I suppose we're still stuck with scheme's phase-separated macros.

-----