jemc changed the topic of #ponylang to: Welcome! Please check out our Code of Conduct => https://github.com/ponylang/ponyc/blob/master/CODE_OF_CONDUCT.md | Public IRC logs are available => http://irclog.whitequark.org/ponylang
hibnico has joined #ponylang
hibnico has quit [Quit: hibnico]
ob_ has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
jemc has joined #ponylang
jemc has quit [Ping timeout: 258 seconds]
c355e3b has quit [Quit: Connection closed for inactivity]
jemc has joined #ponylang
amclain has quit [Quit: Leaving]
SilverKey has joined #ponylang
SilverKey has quit [Client Quit]
amclain has joined #ponylang
unbalancedparen has quit [Quit: WeeChat 1.5]
copy` has quit [Quit: Connection closed for inactivity]
graaff has joined #ponylang
jemc has quit [Ping timeout: 244 seconds]
amclain has quit [Quit: Leaving]
jemc has joined #ponylang
Praetonus has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
SilverKey has joined #ponylang
tm-exa has joined #ponylang
gsteed has joined #ponylang
tm-exa has quit [Quit: Computer has gone to sleep]
SilverKey has quit [Quit: Halted.]
<srm`> could you explain me how this line works : let data: collections.Map[String, I64] = data.create()
<srm`> how can you call .create() on data which not exist ?
<srm`> documents lack of lambda sample ;)
tm-exa has joined #ponylang
ob_ has quit [Ping timeout: 276 seconds]
Matthias247 has joined #ponylang
<malthe> srm`: same as writing let data = Map[String, I64]()
tm-exa has quit [Quit: Bye bye - have a good <insert timezone day period>]
hakvroot_ has quit [Ping timeout: 260 seconds]
tm-exa has joined #ponylang
hibnico has joined #ponylang
hakvroot has joined #ponylang
ob_ has joined #ponylang
c355e3b has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]
tm-exa has quit [Quit: Computer has gone to sleep]
trapped has joined #ponylang
copy` has joined #ponylang
runehog has joined #ponylang
lispmeister has joined #ponylang
<runehog> hi folks! I've been lurking for a while. a spell of insomnia has me finally tackling a pony project... has anybody tried using the portaudio API from pony yet?
ob_ has quit [Quit: Leaving]
<runehog> I'm hoping to call into some pony code from a portaudio callback (to notify an actor responsible for filling audio buffers that it's time to fill another one), but portaudio callback fns may run in various sensitive contexts (signal handlers, etc.) so, I'm trying to figure out what a safe approach is. if I call into an actor's behavior from a C function, that'll get queued for later rather than running synchronously, r
<runehog> ight?
<shepheb> runehog: that's correct, yes.
<shepheb> you're probably safer (caveat: I've never done this) to give the C callback a synchronous function that calls an actor.
<shepheb> I don't know what will happen if you give the C code a behavior directly.
<runehog> well, I'll try it and see then :)
<runehog> thanks!
<shepheb> note that the addressof operator exists for this kind of thing too.
<shepheb> also welcome to the community, and feel free to ask questions when you're stuck.
lispmeister has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
lispmeister has joined #ponylang
<shepheb> argh, my JSON emitter API is running into problems. I was hoping I could make an iso of it and do (consume out).foo().bar().string() and get a String val.
<shepheb> but the chaining doesn't work, it ends up consuming to a ref, passing that to the first call, which returns a ref^, and then it's not an iso anymore.
<shepheb> I can do out.foo(); out.bar(); (consume out).string(), so it does work, but I'm not getting the ergonomics I was hoping for.
<malthe> shepheb: are you using (k/q)cachegrind?
<malthe> finding it a little complex with many cycles due to actor scheduling I assume
<malthe> httpserver is pretty slow and some of it's probably due to exceptions happening very unexceptionally.
<malthe> but it doesn't really explain everything.
<shepheb> I haven't been examining the performance of the server at all; for my project I don't even really care that it's a server.
<malthe> still, the unwind stack accounts for most of the cpu time spent
<shepheb> it's just that the startup time to load the data it needs is too bad to make it a one-shot command line tool.
<malthe> oh i see
<shepheb> I was using straight TCP carrying JSON payloads originally
<shepheb> but I got annoyed with its tendency to needlessly split short (~80B) messages into 2 or 3 chunks.
<shepheb> so I switched to HTTP. but that led me down a rabbit hole of rebuilding the API to pass a Request val and Response iso to server handlers.
<shepheb> (which seems to be working well)
<malthe> ya an app needs to be able to read a request and write at the same time
unbalancedparen has joined #ponylang
<shepheb> I kept having to put handler code in huge recover blocks and jump through hoops.
<shepheb> with them separated like that, you can trivially pass the immutable incoming request, build up whatever you need, and right at the end you write the response data and send it.
<shepheb> much nicer.
<shepheb> I have a broader question, too
<shepheb> several of my JSON outputting functions are partial
<shepheb> because, for example, you shouldn't be emitting key: value inside an array.
<shepheb> the trouble is that actual exceptions, like a failing Map lookup, need to be handled at runtime.
<shepheb> but if you're writing code that'll produce malformed JSON, it's broken at compile time, we just don't have the type system to say so.
<shepheb> but there's no way to express that. you can't meaningfully handle the case of trying to build bad JSON - what error message do you emit?
<shepheb> or maybe we do have sufficient type system? I could try to encode that state into the parser, I guess? no, wait, that requires dependent types.
<shepheb> when you call .endObject(), the return value depends on whether the object was nested inside an object, array, or neither.
<shepheb> really I want what Java calls an Error, rather than an Exception: things are too broken to be meaningfully recoverable.
SirWillem has quit [Read error: Connection reset by peer]
<shepheb> either that, or I remove all the error checking in the name of speed and simplicity! D:
aturley has joined #ponylang
SilverKey has joined #ponylang
lispmeister has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<runehog> ...result of today's experiment: yep, you can call behaviors directly from the FFI, but calling into either a function or a behavior from the portaudio audio callback leads to explodey things in the pony runtime
<shepheb> runehog: is it important in portaudio that things are called from particular threads?
<shepheb> that's a common trouble with some C libraries
<shepheb> and with Pony's work-stealing semantics it can be tricky to ensure you're still on the same thread.
<runehog> it's more that it will call YOU on a particular thread; worse, it's often from a very limited execution context (signal handler or even interrupt handle on some systems)
<shepheb> if you were writing in C, what's the Right Thing to do in the callback?
<runehog> copy some data you've already got buffered and return ASAP, generally
<shepheb> if it needs to be done when the callback returns, then definitely a synchronous fun
<shepheb> you caught the bit about the first argument being this?
<runehog> yep! that much works
<shepheb> well, that should work. what sorts of errors are you getting from the runtime? also, be careful about who allocated what buffers.
<shepheb> don't want Pony to GC memory that the C code expects is still valid.
<runehog> right -- I'm allocating the buffers on the C side and passing them to the pony code in a setup phase
<shepheb> okay, that should be fine.
<runehog> but then, when the C code (running in whatever weird signal handler context) calls my pony "produce next" function, I get:
<runehog> Program received signal SIGSEGV, Segmentation fault.
<runehog> [Switching to Thread 0x7fffa32e4700 (LWP 54780)]
<runehog> 0x0000000000413455 in ponyint_sched_add (ctx=0x48, actor=0x7ffff6586200) at src/libponyrt/sched/scheduler.c:461
<runehog> 461 if(ctx->scheduler != NULL)
<runehog> (gdb) print ctx
<runehog> $1 = (struct pony_ctx_t *) 0x48
<shepheb> what does your callback function look like?
<runehog> I've tried with both a direct behavior call and a function shim. the current mess:
<runehog> fun produce_cb() =>
<runehog> produce()
<runehog> be produce() =>
<runehog> try
<runehog> let buf = _buffers(_index)
<runehog> for i in Range[USize](0, _frame_count) do
<runehog> buf._1.update(i, F32(0.001))
<runehog> end
<runehog> buf._2.update(0, U8(1))
<runehog> _index = _index xor 1
<runehog> if _preroll > 0 then
<runehog> _preroll = _preroll - 1
<runehog> if _preroll == 0 then
<runehog> _env.out.print("start...")
<runehog> let start_result = @start_output_stream[I32]()
<runehog> _env.out.print("got start_result: " + start_result.string())
<shepheb> that's going to not populate the buffer until (maybe long) after the callback has returned and the C code expects it to be ready
<runehog> end
<runehog> end
<srm`> use paste system.
<runehog> end
<runehog>
<runehog> (sorry, should I be posting stuff like this as gists or whatever)
<shepheb> yes, please use Gist or something
<shepheb> three or four lines of error was okay, but 20 is way too much.
<runehog> slack habits :/
<shepheb> to expand: you're not going to be able to do this buffer-filling from a behavior at all
<shepheb> if it's supposed to be done immediately.
<shepheb> just put it all in the fun and try to be fast about it :P
<runehog> yeah, I didn't explain that very well. the buffer-filling doesn't need to be done immediately -- the system currently uses 2 buffers, and in the preroll phase, they both get filled.
<runehog> it's just a signal from the C side that the next buffer is ready to be filled, and the pony side has one buffer duration in which to make that happen.
<shepheb> I follow
<shepheb> we need someone more expert than me - I don't know what the implications of calling a behavior from a C callback are; apparently there's some problem.
<runehog> I have a hunch I'll need some other signaling mechanism that'll play nice with the weird portaudio callback model
<shepheb> I'm losing enthusiasm for this flavour of JSON processing. even in the simple code I have so far, I needed to serialize an object but then mix in an extra value - can't do that with this API easily.
lispmeister has joined #ponylang
Matthias247 has joined #ponylang
lispmeister has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<runehog> time to start doing Day Job stuff, but I just realized -- this is what the asio_event stuff is meant for, isn't it? any examples of sending events from the C side I should look at?
<shepheb> runehog: I'll ping you when people who might know are active on IRC.
<runehog> rad. thanks for all the help, shepheb!
SilverKey has quit [Quit: Halted.]
SilverKey has joined #ponylang
<srm`> where there is no link about patterns.ponylang.org on the home N
<srm`> where there is no link about patterns.ponylang.org on the home ?
<srm`> or sandbox.ponylang.org
<SeanTAllen> sandbox has been deprecated
<srm`> is there any alternative ?
<SeanTAllen> at the moment no.
<srm`> ok
<srm`> and why you don't put a forum on ponylang.org ? it's better than mailing list
<SeanTAllen> we disagree with that statement
<srm`> why ?
<SeanTAllen> if you prefer a forum style, the web interface for groups.io might meet your needs
<srm`> yes but without category or tag to regroup question/answers
hibnico has quit [Ping timeout: 244 seconds]
jemc has joined #ponylang
<SeanTAllen> we can add a question to the state of the stable next year to poll the community on interest in switching
<srm`> yes :)
<shepheb> jemc, SeanTAllen: runehog is looking for help with C calling into Pony.
<shepheb> it exceeds my expertise; I haven't done that before.
<SeanTAllen> other than a little playing, neither have i
<SeanTAllen> perhaps darach is around
aturley has quit [Ping timeout: 260 seconds]
jemc has quit [Quit: WeeChat 1.4]
jemc has joined #ponylang
akant has quit [Ping timeout: 276 seconds]
<runehog> I took a quick look at the asio_event implementation and it depends on there being a valid pony ctx (which is reasonable). Haven't dug into the language internals at all before today, so I don't know if the garbled ctx I was seeing is expected...
<runehog> what I really want here is a counting semaphore that can wake up an actor :)
aturley has joined #ponylang
amclain has joined #ponylang
<SeanTAllen> Jemc: I'll do that fix in a bit
SilverKey has quit [Quit: Halted.]
jemc has quit [Read error: Connection reset by peer]
<Praetonus> runehog: Is your C library creating threads aside of the Pony runtime threads?
jemc has joined #ponylang
<runehog> Praetonus: effectively, yes (portaudio callbacks can come from arbitrary threads depending on the OS)
<runehog> I just tried making a thread of my own that is only used to call into pony, rather than calling straight from the portaudio fn -- and it blows up the same way
<runehog> is this not allowed?
<Praetonus> Then you have to call pony_register_thread from those threads to create a pony_ctx_t for these
<runehog> ah! thanks!
rlmw has quit [Remote host closed the connection]
<runehog> it works :D
Praetonus has quit [Quit: Leaving]
<jemc> Praetonus: TIL - you should think about doing a little writeup about that :)
<jemc> or an example or some such
<SeanTAllen> jemc: we just started seeing the "broken pipe" issues that we've been having in travis in our internal CI build of ponyc. We are hoping we can track down a cause.
<jemc> can you tell if your CI workers are running out of memory?
<darach> here now, sorry was in the city
pulpfiction has quit [Quit: Leaving]
Matthias247 has quit [Read error: Connection reset by peer]
<jemc> runehog: sounds like a cool project! I've been wanting to try at some point to integrate Pony with JACK audio, but hadn't really spent any time with it yet
<jemc> runehog: I'll be interested to see what you come up with, if you post it publicly
<runehog> I'm curious how it'll turn out too. Definitely gonna share it!
<jemc> one possible hurdle is the fact that pony doesn't really like you to do blocking operations, so it may be difficult to do any meaningful interaction with actors from your library callback (which I'm assuming is synchronous)
tm-exa has joined #ponylang
aturley has quit [Ping timeout: 260 seconds]
<runehog> it's a nonblocking design, more or less. the only communication from the C side is to say "hey pony, I'm done with the next buffer, start filling it"
c355e3b has quit [Quit: Connection closed for inactivity]
<jemc> what happens when pony is done filling the buffer? another C call to say "hey C, I'm done filling the buffer"?
tm-exa has quit [Quit: Computer has gone to sleep]
tm-exa has joined #ponylang
<runehog> it sets a "buffer ready" flag. if that flag doesn't get set in time, well, the "realtime" portaudio thread can complain
<runehog> in the past, I haven't even bothered with such a flag. the two sides just move in lockstep through the same set of buffers. if the writer is late, oh well, you hear a glitch.
<jemc> I'll be interested to see when you post an example how all of the memory handling works
<jemc> anyway, as shepheb said, welcome to the community and feel free to ask here or on the mailing list when you run into trouble
<runehog> thanks for the warm welcome. I haven't been this excited about a software movement since BeOS
<jemc> the sun never sets on the pony community (thanks mostly to doublec in New Zealand), so there's usually someone around in IRC :)
Praetonus has joined #ponylang
<runehog> :) I'm off to do some stuff I get paid for, I swear. but here's my code so far: https://gist.github.com/runehog/2bac637f819318fa5d784e768f33893e
Applejack_ has joined #ponylang
<Applejack_> SeanTAllen: can we use the images of your logos in websites and all?
aturley has joined #ponylang
pulpfiction has joined #ponylang
Applejack_ has quit [Remote host closed the connection]
<jemc> runehog: tried to compile your gist, but I'm missing the `portaudio_sink` library - not sure what library that is or how it's distributed
<runehog> oh that's just portaudio_sink.c compiled to an .a. I'm currently building with: gcc -g -c portaudio_sink.c && ar -r libportaudio_sink.a portaudio_sink.o && ponyc --path=.
tm-exa has quit [Quit: Computer has gone to sleep]
Applejack_ has joined #ponylang
pulpfiction has left #ponylang ["Leaving"]
<jemc> ah right, didn't even see the C file there - thanks
Applejack_ has quit [Remote host closed the connection]
graaff has quit [Quit: Leaving]
Matthias247 has joined #ponylang
TwoNotes has joined #ponylang
c355e3b has joined #ponylang
SilverKey has joined #ponylang
<SeanTAllen> jemc: as far as we can tell, its not an OOM
lispmeister has joined #ponylang
lispmeister has quit [Client Quit]
lispmeister has joined #ponylang
aturley has quit [Ping timeout: 258 seconds]
aturley has joined #ponylang
lispmeister has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
SilverKey has quit [Quit: Halted.]
jemc has quit [Quit: WeeChat 1.4]
jemc has joined #ponylang
SilverKey has joined #ponylang
hibnico has joined #ponylang
SilverKey has quit [Quit: Halted.]
SilverKey has joined #ponylang
aturley has quit [Ping timeout: 240 seconds]
aturley has joined #ponylang
SilverKey has quit [Quit: Halted.]
aturley has quit [Ping timeout: 260 seconds]
SilverKey has joined #ponylang
Praetonus has quit [Quit: Leaving]
SilverKey has quit [Quit: Halted.]
pulpfiction has joined #ponylang
SilverKey has joined #ponylang
SilverKey has quit [Client Quit]
aturley has joined #ponylang
hibnico has quit [Quit: hibnico]
aturley has quit [Ping timeout: 272 seconds]
gsteed has quit [Remote host closed the connection]
Matthias247 has quit [Read error: Connection reset by peer]