Leonidas changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.13.0 released: https://ocaml.org/releases/4.13.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
<d_bot> <Shon> Yeah, I can see the downside of that for sure. I guess this exactly the kind of place where having linear types, or something else that could track the effects at play, would really be helpful.
<d_bot> <Shon>
<d_bot> <Shon> I know there's nothing novel about the insight, but I'm finding it interesting to think about the impedance mismatch between trying to get input from inherently stateful sources like in channels and trying to express the program logic in a maximally declarative, and FP-friendly way (without just giving up on predictability or performance).
<d_bot> <Shon> What about something like `fold_over_in_channel: ('acc -> string -> 'acc) -> 'acc -> in_channel`
Techcable has joined #ocaml
<companion_cube> sure
<companion_cube> I also have this `iter` library just for that :p
<companion_cube> but the downside is, you lose expressiveness even more
<companion_cube> you can't do stuff like, say, read 2 sorted files and sort-merge them
<d_bot> <Shon> Ah yeah, I see the downside there.
namkeleser has quit [Quit: Client closed]
namkeleser has joined #ocaml
perrierjouet has joined #ocaml
perrierjouet has quit [Client Quit]
<companion_cube> Otoh it seems to optimise very well.
Anarchos has quit [Quit: Vision[]: i've been blurred!]
mro_ has quit [Quit: Leaving...]
<d_bot> <Shon> Yeah. I guess more residue from the impedance mismatch!
rgrinberg has joined #ocaml
Anarchos has joined #ocaml
<companion_cube> on flambda it was sometimes the case that a `range n |> flat_map |> filter |> map |> iter` (or sth like that) would become a proper loop 😍
perrierjouet has joined #ocaml
<d_bot> <Shon> Oh wow. that's very nice!
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<companion_cube> (iter is: `'a iter = ('a -> unit) -> unit`)
Anarchos has quit [Quit: Vision[]: i've been blurred!]
rgrinberg has joined #ocaml
<rgrinberg> relying on the optimization gods is not the ocaml way
<companion_cube> not like we have any choice.
<companion_cube> this would all be reliable if we had staging or compile time evaluation…
<rgrinberg> those would be nice, but i think we're suffering from the lack of control over memory layout much more
<rgrinberg> companion_cube ocamlopt seems awfully conservative with inlining. have you noticed?
<companion_cube> the vanilla one? yeah
<companion_cube> well, I think it's both
<companion_cube> memory layout, _and_ lack of good inlining which means a lot of things will produce tons of closures
<d_bot> <Shon> I do find it nice to be able to write things in the most clear and declarative way you can work out, since it's often easier to reason about, and then go back through and try to optimize if needed.
<companion_cube> (including iterators)
<d_bot> <Shon> But flambda helps make that need less frequent, that is nice! Tho I of course also agree that I'm not eager to be in a situation like Haskell, where it seems you have to be an advanced expert to have any hope of reasoning about what optimizations are making your code feasible to run.
<rgrinberg> worse than that, they've introduced a whole new class of crippling performance problems - space leaks
<companion_cube> in the compiler, you mean, right?
<companion_cube> ah sorry, haskell.
<companion_cube> flambda is nice but some packages fail to compile with it
<companion_cube> so flambda2 is where hope lies
<companion_cube> alright Shon, you might have speedrun the PR
<d_bot> <Shon> lol, well it was a nice, well defined, tiny problem, and I had the benefit of the feedback here in advance 🙂 Thanks for the quick review!
zebrag has joined #ocaml
<companion_cube> :)
xd1le has joined #ocaml
Corbin has joined #ocaml
<d_bot> <Et7f3> What is space leak ?
<d_bot> <Shon> > A space leak occurs when a computer program uses more memory than necessary. In contrast to memory leaks, where the leaked memory is never released, the memory consumed by a space leak is released, but later than expected
<d_bot> <Shon> So basically you end up allocating more memory (e.g., perhaps you're constructing a bunch of intermediary lists you don't actually) for operations that they should need.
<d_bot> <Shon> But it's not that those things are slipping out of view of the garbage collector or anything (or that you're failing to deallocate).
<d_bot> <Et7f3> Oh so program that use free list and free all at end is space leak ?
<d_bot> <Shon> I wouldn't think that'd also be a space leak.
<d_bot> <Shon> More details here: https://stackoverflow.com/a/46009036/1187277
<d_bot> <Shon> iiuc, basically just where your language/program/compiler whatever uses a bunch of allocations that wouldn't expect, and shouldn't actually need, to perform your computations.
mbuf has joined #ocaml
<rgrinberg> more concretely, in haskell every computation no matter how cheap it is allocates a cell due to lazy evaluation
perrierjouet has quit [Quit: WeeChat 3.3]
<rgrinberg> So 2 + 3 is more like lazy (2 + 3) in OCaml
<companion_cube> except for strict computations, but it's opt-in, yeah
<rgrinberg> it turns out that there's a lot of things that are cheaper to compute immediately than to delay
<rgrinberg> so laziness is a huge waste
<companion_cube> I'd tend to agree yep
<companion_cube> unsurprisingly, successor languages like Idris are strict
perrierjouet has joined #ocaml
<d_bot> <darrenldl> do people opt for slightly more restrictive licenses these days? say <https://commonsclause.com/>
<d_bot> <darrenldl> licenses which make predatory commercialisation more(?) difficult
<Corbin> Sure; I like AGPL.
<d_bot> <darrenldl> do a lot of opam packages use agpl?
zebrag has quit [Quit: Konversation terminated!]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <darrenldl> hm, janestreet just uses mit it seems
rgrinberg has joined #ocaml
namkeleser has quit [Quit: Client closed]
namkeleser has joined #ocaml
Techcable has quit [Quit: ZNC - https://znc.in]
Techcable has joined #ocaml
kadir has joined #ocaml
Serpent7776 has joined #ocaml
chrisz has quit [Ping timeout: 250 seconds]
chrisz has joined #ocaml
haesbaert has joined #ocaml
waleee has joined #ocaml
bartholin has joined #ocaml
kadir has left #ocaml [WeeChat 3.3]
mbuf has quit [Quit: Leaving]
bartholin has quit [Ping timeout: 252 seconds]
waleee has quit [Ping timeout: 252 seconds]
bartholin has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bartholin has quit [Ping timeout: 252 seconds]
<Leonidas> why wouldn't they? they're not in the software commercialization business
<d_bot> <darrenldl> true
<Leonidas> commons clause has the problem that it cannot be included e.g. in Debian
<Leonidas> so, any software that would use your project, couldn't
<d_bot> <darrenldl> oh huh
<d_bot> <darrenldl> good to know : o
<Leonidas> (notably, AGPL doesn't have this problem)
<d_bot> <darrenldl> ah a fair few big ocaml packages are in mit or bsd 2, not much point in overthinking it i guess
<d_bot> <darrenldl> thanks for the info~
bartholin has joined #ocaml
waleee has joined #ocaml
Tuplanolla has joined #ocaml
waleee has quit [Ping timeout: 260 seconds]
hackinghorn has quit [Ping timeout: 256 seconds]
mro has joined #ocaml
waleee has joined #ocaml
mro has quit [Quit: Leaving...]
<aru> Hi, I'm pretty new to ocaml and I've hit a bit of behavior that I can't really grasp. I'm putting together a solution for one of the advent of code challenges and I have something which works just fine, but breaks as soon as I open core. Could anyone point me in the right direction with this https://pastebin.com/X8UQd5UX ?
<aru> I wanted to add core to have access to fold_until, but the same typechecking error hits me there
<aru> I mean I'm destructuring two lists of chars and comparing their elements, how can it assume of the items is an int?
chrisz has quit [Ping timeout: 260 seconds]
chrisz has joined #ocaml
<d_bot> <NULL> Core's (=) is not polymorphic, it is only equality for ints
<aru> oh
<aru> I didn't expect that one
jlrnick has joined #ocaml
<aru> so Base.Char.equal?
* qwr would say that deciding to use Core is matter of taste, it has some decisions that not everybody agrees - but you can do Stdlib.(foo = blaah) :)
<aru> cool, thanks a bunch
bartholin has quit [Ping timeout: 256 seconds]
hackinghorn has joined #ocaml
<d_bot> <Shon> You can also do `let (=) = Int.equal` to set your definition of equality within the scope you need it be for into.
bartholin has joined #ocaml
gravicappa has joined #ocaml
tomku has quit [Ping timeout: 260 seconds]
jlrnick has quit [Ping timeout: 268 seconds]
waleee has quit [Ping timeout: 260 seconds]
tomku has joined #ocaml
namkeleser has quit [Quit: Client closed]
bartholin has quit [Ping timeout: 256 seconds]
bartholin has joined #ocaml
<Soni> dmbaturin: poke?
waleee has joined #ocaml
<dmbaturin> Hi Soni!
<d_bot> <Et7f3> Sone: ball
SpiceGuid has joined #ocaml
waleee has quit [Ping timeout: 268 seconds]
jlrnick has joined #ocaml
waleee has joined #ocaml
bartholin has quit [Ping timeout: 252 seconds]
SpiceGuid has quit [Quit: Client closed]
xd1le has quit [Quit: xd1le]
bartholin has joined #ocaml
spip has joined #ocaml
spip is now known as Guest4123
perrierjouet has quit [Ping timeout: 260 seconds]
perrierjouet has joined #ocaml
<d_bot> <zakkor> aru: hahaha, what the hell man. I literally hit this exact same problem, on the exact same AOC problem, and asked about it here earlier
<d_bot> <zakkor> not sure if you can see this through the bridge
<aru> heh
bartholin has quit [Ping timeout: 260 seconds]
<aru> well, now we know
<d_bot> <RegularSpatula> Does anyone know of any examples repos fuzzing do fuzzing in CI?
thizanne` has joined #ocaml
aru has quit [Quit: WeeChat 3.0]
mro has joined #ocaml
<Soni> dmbaturin: what happened to you? haven't seen you in #soupault in forever
aru has joined #ocaml
mro has quit [Remote host closed the connection]
bartholin has joined #ocaml
thizanne` has quit [Quit: WeeChat 3.3]
thizanne` has joined #ocaml
mro has joined #ocaml
thizanne has quit [Quit: WeeChat 2.3]
thizanne` is now known as thizanne
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
<d_bot> <undu> @RegularSpatula I'd like to see one as well, I'm curious about how to automate it, how to avoid limits in the CI runners, periodicity, etc
<d_bot> <RegularSpatula> Yeah i was planning on working on it at some point this week, but I’m hoping to find an example first to avoid reinventing the wheel
gdd has quit [Ping timeout: 252 seconds]
gdd has joined #ocaml
waleee has quit [Ping timeout: 250 seconds]
waleee has joined #ocaml
mro has joined #ocaml
namkeleser has joined #ocaml
mro has quit [Remote host closed the connection]
waleee has quit [Ping timeout: 268 seconds]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
bartholin has quit [Ping timeout: 250 seconds]
bartholin has joined #ocaml
namkeleser has quit [Quit: Client closed]
rgrinberg has joined #ocaml
mro has joined #ocaml
<rgrinberg> thizanne using a native popcnt does absolutely nothing for performance ^_^
<thizanne> rgrinberg: does it?
<rgrinberg> Yes, I just tried it
<thizanne> I remember gasche doing these experiments and finding that it wasn't zero
<d_bot> <rgrinberg> I can put up a PR if you want to experiment measuring it
<thizanne> nah I trust you
<rgrinberg> I think the issue is that C calls aren't free
<rgrinberg> I used no [@@noalloc] but still the call cannot be inlined
mro has quit [Remote host closed the connection]
<thizanne> yeah I read the old mails again and it seems consistent with your result
<thizanne> what he did was actually implementing popcount as a compiler primitive, but with C code that does the bit shifting stuff
<thizanne> which seems to be the opposite of what you did, which is having a function that's not a primitive but uses the native instruction
<thizanne> and then on some benchmark the time spent in popcnt went from 17% to 11% if I can read correctly
<rgrinberg> i wonder why he didn't upstream. having a popcount primitive in the compiler seems quite useful
mro has joined #ocaml
<thizanne> probably because it was 2013, so "upstreaming in the compiler" was a dark path
<thizanne> anyway it's nice to see that, apart from a builtin, we don't really gain something on optimised popcount
<thizanne> I was wondering if we should try some implementations that maybe could be a little faster than all the shifting
sagax has quit [Excess Flood]
<rgrinberg> at key does the shifting a little faster
<rgrinberg> let bottom5 = skey land 0x1f in
<rgrinberg> *atkey
<rgrinberg> doesn't have that masking like we do
<rgrinberg> (h asr shift) land mask
<thizanne> wikipedia (hamming weight) has several implementations that seem to have different tradeoffs (eg. the last one is faster if one has fast multiplications)
mro has quit [Remote host closed the connection]
<thizanne> but if a native operation has no observable effect, then there is no point in trying non-native-slightly-optimised ones
gravicappa has quit [Ping timeout: 256 seconds]
<rgrinberg> just to give a rough idea where we're at:
<rgrinberg> fetching from a 10 element map is roughly twice as as slow than from an stdlib map
<rgrinberg> we catch up when there's around 100 elements
<rgrinberg> and at around 1k, we're about twice as fast
<rgrinberg> this is on integer keys, which of course favor the stdlib map
<rgrinberg> but it's good to have a pessimistic baseline
<rgrinberg> we should copy how atkey is doing the shifting
mro has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<thizanne> but what's the point if even a native popcnt isn't faster?
<thizanne> oh he left.
bartholin has quit [Ping timeout: 268 seconds]
jlrnick has quit [Ping timeout: 250 seconds]
bartholin has joined #ocaml
<companion_cube> yeah popcount directly in the compiler would be nice
oisota has quit [Quit: The Lounge - https://thelounge.chat]
<thizanne> I'm not sure I have the energy for this
Anarchos has joined #ocaml
oisota has joined #ocaml
oisota has quit [Quit: The Lounge - https://thelounge.chat]
oisota has joined #ocaml
Anarchos has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
Anarchos2 has joined #ocaml
<rgrinberg> a native popcnt would be faster if there was no function overhead i bet
<companion_cube> ocamlopt doesn't seem to have too many architecture dependent features like that, though
<thizanne> yes that seems to be the result gasche got
<thizanne> but until then it doesn't seem very worth to try and optimise popcnt
<rgrinberg> Hmm, that's exactly what I'm saying?
<companion_cube> like, it'd also make a lot of sense to have some primitives for vectorizing (for all the `Foo.blit`)
<rgrinberg> There's plenty of other things to optimize
<companion_cube> a faster blit would be quite useful though
<companion_cube> I mean, talking about IOs and all that, imagine if buffer management was 8x or 16x faster :p
<rgrinberg> companion_cube blitting is already done in C what would be gained?
<thizanne> rgrinberg: I was talking of "rgrinberg | we should copy how atkey is doing the shifting"
<thizanne> unless I misunderstood that?
<rgrinberg> thizanne that's not about the popcnt, but how he extracts the hash fragments
<thizanne> oh
<thizanne> then I misunderstood indeed
<thizanne> I really need to dive into the code again...
<rgrinberg> at least blitting for bigarrays
<thizanne> might have some time in the beginning of january
<Armael> blitting for normal array is also a memcpy afair
<companion_cube> damn, shows what I know
<companion_cube> I thought I'd see blit as a loop somewhere…
<companion_cube> yeah, and for bytes it's a call to memmove
<rgrinberg> we are missing fast functional updates to arrays though
<companion_cube> how would that work?
<rgrinberg> do the same thing, but don't do caml_modify
<companion_cube> right
mro has quit [Remote host closed the connection]
mro has joined #ocaml
Anarchos2 has quit [Ping timeout: 265 seconds]
bartholin has quit [Ping timeout: 250 seconds]
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
mro has quit [Quit: Leaving...]
helicopterHelico has joined #ocaml
helicopterHelico has left #ocaml [#ocaml]
Anarchos has joined #ocaml
ts2 has quit [Ping timeout: 250 seconds]
ts2 has joined #ocaml