puzza007_ has quit [Quit: Connection closed for inactivity]
jemc has joined #ponylang
jemc has quit [Ping timeout: 248 seconds]
<endformationage>
I wish to pass a Pony object to a FFI function, to be treated opaquely on the C-side, but passed to a bare lambda provided as a callback. Should this work?
<endformationage>
Hmm, I believe I have this working.
* endformationage
gets it working! Yeah, woohoo!
vaninwagen has joined #ponylang
endformationage has quit [Quit: WeeChat 1.9]
phifty has joined #ponylang
<phifty>
hi, I have a question regarding capabilities and HTTPHandler
<phifty>
I want to save the responded headers that are supplied via the apply function of the HTTPHandler and send it - after the body has been received - to another handler
phifty has quit [Client Quit]
<vaninwagen>
phifty do you have some example code to show? this would make your problem clearer and easier to help.
<theodus>
Calls to Debug are seriously reducing the performance of my programs by one or two orders of magnitude when optimized. When the calls to Debug.out are commented out everything runs much faster. Is this expected?
<theodus>
I suspect that they reduce inlining, but it seems like the inlining should happen after the Debug calls are removed since it's not being compiled in debug mode.
tscho has quit [Read error: Connection reset by peer]
tscho has joined #ponylang
<SeanTAllen>
well
<SeanTAllen>
theodus: can you share an example of debug usage
<SeanTAllen>
i see a definite problem
<SeanTAllen>
well maybe a problem
<SeanTAllen>
it would be interesting to look at the generated code theodus
<SeanTAllen>
could you open an issue for this with generated code with and without?
<theodus>
I'll see if I can get a minimal example.
<theodus>
I'm not sure if it's exactly the same issue, but it does show that the Debug call isn't being optimized out entirely.
<theodus>
And be careful, memory is consumed quickly
<theodus>
when the debug call isn't commented
<SeanTAllen>
have you looked at the generated code in each case?
<theodus>
When uncommented, the generated llvm-ir is 22% larger and the assembly is 27% larger.
<theodus>
Other than that, I'm not sure what to look for since it's all been optimized
jemc has joined #ponylang
<jemc>
theodus: note that `ifdef debug` is the only construct that is eliminated at compile time when compiling in non-debug mode
<jemc>
`Debug.apply` is implemented with `ifdef debug` inside it
<jemc>
but the expression for the argument you pass to it will not be eliminated
<jemc>
so I'm not surprised that your `"total: " + total.string()` expression is still being executed in both debug and release mode
<theodus>
But Debug.out only calls _print, which is also implemented with `ifdef debug`. Shouldn't the argument then be eliminated as dead code?
<jemc>
I personally don't know a lot about the LLVM IR optimizer - I'm not sure whether it can be sure that the String.add doesn't have "side effects" that have to be kept
<theodus>
I see, well in that case it's not a big deal except that it makes Debug unusable if you care about performance.
<SeanTAllen>
ah o missed that
<SeanTAllen>
so theodus this is why the Logger works the way it does
<theodus>
But I guess they could just be commented out
<SeanTAllen>
or wrap it in an ifdef debug
<SeanTAllen>
that is what we do with similar code in our codebase
<SeanTAllen>
Benoit and Sylvan are probably best to discuss with in general for further optimization
<SeanTAllen>
I think that's a good sync topic
<SeanTAllen>
jemc: are you back from traveling?
<jemc>
"unusable" is a bit of a strong word, though it may be unsuitable for a given purpose in a given situation - it's still quite useful if your `Debug.out` argument doesn't do any computation (like, you already have the string or stringable ready to give it)
<jemc>
it may be possible that we could tweak some things to make the LLVM IR optimizer be smart enough to get rid of the "dead code" in the argument
<jemc>
as SeanTAllen mentioned, it would be a good sync topic to discuss
<jemc>
another option would be to have a variant of `Debug` that accepts a lambda
<jemc>
and you could do your computation inside the lambda, which is never called if the `ifdef debug` branch is removed
<theodus>
That is an option, but I personally prefer wrapping the call in an ifdef.
<jemc>
theodus: as a workaround, I think your example would be significantly more efficient if you just didn't do the `+`, and made two `Debug` calls
<jemc>
since you'd just be passing an existing string to the first call and an existing stringable to the second call, and no computation would be done when not in debug mode
vaninwagen has quit [Ping timeout: 240 seconds]
<jemc>
this pattern could be interesting if combined with some operator sugar
<jemc>
for example:
<jemc>
Debug << "total: " << total
<jemc>
C++ folks would be happy :)
<jemc>
C++ haters, less so
<jemc>
SeanTAllen: still traveling, but I may have some time later to do the thing you were asking me about
<jemc>
s/later/later today/
Matthias247 has joined #ponylang
jemc has quit [Ping timeout: 260 seconds]
<SeanTAllen>
jemc we ran into perf issues with lambdas in our "Invariant" code that is like Debug
<SeanTAllen>
and had to wrap in ifdef debug
<SeanTAllen>
so sync conversation is good
<SeanTAllen>
o jemc: i wasnt looking to get you to do anything, was merely curious
theo has joined #ponylang
theo has quit [Quit: Bye]
Matthias247 has quit [Read error: Connection reset by peer]