<gasche>
well avsm could do a "fastest speaker in the world" show
<ggole>
Is it a bot?
lobo has joined #ocaml
grouzen has quit [Ping timeout: 250 seconds]
govg has joined #ocaml
ely-se has quit [Quit: leaving]
kushal has joined #ocaml
mcorbin has joined #ocaml
mcorbin has quit [Remote host closed the connection]
octachron has quit [Ping timeout: 260 seconds]
mcorbin has joined #ocaml
kushal has quit [Quit: Leaving]
badkins has joined #ocaml
kushal has joined #ocaml
octachron has joined #ocaml
ceryo has joined #ocaml
BhavyaM has quit [Quit: Quit the channel]
<struktured>
gasche: is that an actual bug?
<struktured>
gasche: I thought it was correct but confusing...
<gasche>
well
<ollehar>
is copy-on-write possible without ref counting?
<gasche>
it's not a correctness bug
<gasche>
but the point of user interaction is to be clear, not confusing, so "confusing" means that it should be improved
<gasche>
if it is easy to do so, there is no reason not to
<Enjolras>
ollehar: of course, but that means that you will always copy, even for a single owner
<gasche>
I would argue that "confusing" is a defect (bug ?) in messages
nightuser has joined #ocaml
<ollehar>
Enjolras: how much slowdown would that be?
<Enjolras>
you could say that a langage with immutable data is copy on write
<ggole>
ollehar: I don't see any reason why not
<Enjolras>
like, a list or a map in ocaml could be called "copy on write"
<gasche>
ollehar: I think the context should be clarified
<struktured>
gasche: ok I will file a report then. thanks
<Enjolras>
even if the term is usually for mutable things
<gasche>
("ref counting" could reference a specific in-language runtime mechanism, or something manual the programmer does, or something a library does)
<gasche>
(and "slowdown" need use-cases to make sense)
<ollehar>
use-case is PHP arrays, which have copy on write semantics
<gasche>
you mean they have a value semantics, implemented with CoW?
<Enjolras>
is it ? does it copy the whole array or is it a map under it ?
<Enjolras>
because, if it is a persistant array implemented as a map, the slowdown is for every access. If it copies the whole array, it is linear in the number of write
<gasche>
I think you could amortize the copy cost of persistent array
<gasche>
use a "array plus diff" representation, reading is O(diff size)
<gasche>
sum the diff size over all accesses, and whenever you are larger than the array size, renormalize the array by doing a copy
<Enjolras>
right. That's how virtual memeory is implemented in kernel
<gasche>
I think your point was that the interaction of "copy on write" and "ref counting" is to know that you can skip the copy when there is a unique owner, but that is only an optimization
<gasche>
(not central to CoW, or in fact value semantics in general)
<ggole>
In the case of arrays, it seems like a pretty necessary optimisation
<gasche>
well my amortization suggestion would suggest that it is only a constant-factor optimisation
<gasche>
and it probably depends a lot on the read/write workflow
<Enjolras>
i have troubles seing the difference between value semantic and cow. It's just two names of the same thing in different contexts, isn't it ?
<ggole>
Wouldn't an update to every element in an array would result in unacceptable (O(n) instead of O(1)) access times to elements?
<gasche>
I understand "value semantics" as a specification (referential transparency, if you want) and CoW as a specific implementation technique to implement unique ownership (share aliased mutable values, unshare on mutation)
<Enjolras>
ggole: not if you use diffs as gaschee explained
<gasche>
there is another trick you can play with persistent arrays, which is to have the last writer to the array always see a plain array, and grow the diff "backward" for other owners
<gasche>
(this is how Filliatre semi-persistent arrays work, for example)
<ggole>
That's what I was assuming, but perhaps it can be done more efficiently than I had in mind
<gasche>
I guess if you do this you can get pretty close to the constant factors of CoW
<gasche>
ggole: my suggestion is to count how much you paid on diff-traversal on the past array accesses, and renormalize the array whenever you reach the array size
<gasche>
hm
<gasche>
actually that means you pay O(n) copy cost every O(sqrt n) operations, so not great
govg has quit [Ping timeout: 255 seconds]
<Enjolras>
how do you store diffs ? especially sparse ones. If you have a list of arrays, with option, the memory cost is high for sparse diffs. If you have a tree of sequential diffs, your need some code to compact the diffs
<Enjolras>
the complexity of this is not 100% clear to me
<gasche>
in particular, this implementation has optimal properties for many typical CoW workflows
<gasche>
many owners can share a reference to an array value
<gasche>
the last person to read or write pay an O(1) cost by reading or writing again
<gasche>
if someone that is not the last accessor tries to read or write, a copy happens
<gasche>
if you assume a typical "transfer of ownership" pattern with agents passing the value around, each doing a bunch of read/writes then never touching it again, you have O(1) all the way
<gasche>
(but note that, with this implementation, the copy is O(diff size), not O(array size), which may be costly if a very very old owner resumes activity)
<gasche>
and this is not reference counting; in particular, an old owner can keep a reference of the value as long as it wants, without incurring any cost at all if the reference is not used (which may be very hard to prove statically, and in particular wrong in some exceptional cases)
antkong has joined #ocaml
tane has joined #ocaml
BitPuffin has joined #ocaml
nightuser has quit [Ping timeout: 255 seconds]
antkong has quit [Quit: antkong]
kushal has quit [Quit: Leaving]
kushal has joined #ocaml
darkf_ has joined #ocaml
jabesed has joined #ocaml
thomasga has joined #ocaml
darkf has quit [Ping timeout: 246 seconds]
struktured has quit [Ping timeout: 250 seconds]
adrien_znc has quit [Ping timeout: 256 seconds]
kushal has quit [Ping timeout: 256 seconds]
adrien_znc has joined #ocaml
mcorbin has quit [Remote host closed the connection]
pyon is now known as misanthro-pyon
ollehar has quit [Ping timeout: 255 seconds]
jaseemabid has joined #ocaml
jabesed has quit [Quit: Konversation terminated!]
<jaseemabid>
I get a type mismatch error. Google is not helping at all. What is this? `unit Async.Std.Deferred.t = unit Async_kernel.Deferred0.t` ?
tmtwd has joined #ocaml
<jaseemabid>
How many types of deferred at there in the same library?
struktured has joined #ocaml
ely-se has joined #ocaml
<octachron>
jaseemabid, are you sure that your type error is here? It looks like Async.Std.Deferred.t and Async_kernel.Deferred.t could be just aliases pointing to the same type.
<jaseemabid>
octachron: I think I have to type cast a unit to this deferred thing.
<jaseemabid>
This is confusing.
NingaLeaf has quit [Read error: Connection reset by peer]
<jaseemabid>
octachron: `Error: This expression has type unit but an expression was expected of type unit Async.Std.Deferred.t = unit Async_kernel.Deferred0.t`
<octachron>
jaseemabid, so the equality on the right is just saying that Async.Std.Deferred.t is an alias for Async_kernel...
<jaseemabid>
There is practically zero documentation :(
<octachron>
you can (probably) create a deferred value by using Deferred.return
dhil has joined #ocaml
BitPuffin has quit [Ping timeout: 246 seconds]
NingaLeaf has joined #ocaml
mcorbin has joined #ocaml
<jaseemabid>
Terribly terribly missing hoogle or type holes while programming in OCaml. Sometimes I'm just hunting for the right function for hours. Lack of any documetation makes it really sad. I'm surprised that the state of tooling is really bad for a language almost as old as me.
ely-se has quit [Quit: leaving]
<jaseemabid>
</ sad rant>
mcorbin has quit [Remote host closed the connection]
slash^ has joined #ocaml
grouzen has joined #ocaml
misanthro-pyon is now known as grum-pyon
<ggole>
Async is "documented", just not very well
vanila has joined #ocaml
tnguyen has quit [Quit: tnguyen]
emias has quit [Ping timeout: 264 seconds]
<gasche>
jaseemabid: why did you choose to use Async if you value documentation?
<gasche>
also, what is it that you actually mean when you "miss type holes"?
<jaseemabid>
gasche: I picked the most popular, which led me there.
whirm has quit [Ping timeout: 264 seconds]
<jaseemabid>
I get warnings like 'Need a deferred, you are returning a unit`. The obvious thing to look for is a function of type `unit -> deferred unit`. Which I can do with hoogle or type holes.
<gasche>
how did you measure "most popular"?
<gasche>
I don't know what you mean by "type holes", in my book they do not do search for you
<gasche>
in this particular example, you are looking for the "return" of the deferred monad
<gasche>
I would bet on "return"
<jaseemabid>
Ah, First google result for *learn ocaml* :)