« first day (3618 days earlier)      last day (1327 days later) » 
00:00 - 21:0021:00 - 00:00

12:30 AM
magic?
 
 
3 hours later…
3:06 AM
What's the correct way to free a hash table and all the entries in it? I thought zend_array_destroy would do it, but I'm still seeing memory leaks from things allocated in zend_hash.c.
Code examples appear to only use zend_array_destory, so I must be doing something wrong. I'm adding entries with zend_hash_next_index_insert_ptr.
 
 
1 hour later…
4:09 AM
I'm also unclear on when to use zval_ptr_dtor vs. Z_TRY_DELREF/Z_DELREF.
 
Wes
4:28 AM
\o
 
 
1 hour later…
5:42 AM
Good morning.
 
6:32 AM
Any idea to optimize the following solution?

http://sandbox.onlinephpfunctions.com/code/edcbc8d236be2fd692cf8fd00d01b14b38c10d41
Following is the question
14
Q: Programming: Minimum steps required to convert a binary number to zero

roger_thatI was working on a programming exercise and was stuck on figuring out the correct algorithm. Here is the problem: Given a decimal number, how many minimum possible steps are required to convert this to zero provided: Change the bit i if the next bit i+1 is '1' and all the other bi...

Failing to execute for the binray "10000001100001101011100010111100010101100111" within the time limits
9 seconds
 
7:08 AM
morns
 
7:49 AM
@Trowski zval_ptr_dtor, unless you know what you're doing
@Trowski zend_array_destroy is for standard arrays, you need to be using zend_hash_destroy etc.
In particular, zend_array_destroy does not support custom destructors, which you're probably using if you're inserting pointers
 
8:19 AM
@cmb Okay, because it's still failing :-) ci.appveyor.com/project/derickr/xdebug/build/job/… — I guess the 8.0 runs aren't nightlies?
 
8:48 AM
@Derick Can you please have a look at github.com/php/php-src/pull/6081 I tried to refactor the ZPP of DatePeriod::__construct(). Nikita was not particularly impressed ^^ but I think it's a useful change.
 
can you link me to the right line?
 
I'm with NIkita here. I think I'd rather deprecate this __construct and create three new factory methods.
 
@Derick I'd be more than happy with that :) I'll include this to the 8.1 deprecations list
 
cmb
@Derick the 7.2 builds are supposed to fail; ci.appveyor.com/project/cmb69/xdebug/builds/35148907 hopefully fixes that (will PR if good)
8.0 aren't nightlies (but rather QA releases), because there are no snapshots of PHP 8
 
9:01 AM
ah, OK
the PHP 8 snapshots exist, it's called "git clone" :D
 
@Derick you know you can do git checkout, right? You don't have to clone the whole thing every time you want a different commit ref
:-P
 
I know, but that really doesn't work well with in-tree source builds with different PHP versions as there are some leaky generated files at times.
 
Missing getName documentation ・ Documentation problem ・ #80091
 
reminds me of a guy at a customer (lawyers) years ago, who used to print out the entire email chain for filing every time he got an email, sometimes there would be 60-70 messages in the chain that he printed every single time, like half a ream of paper
@Derick I know it just looked odd
 
cmb
@Derick well, do you want to build PHP on AppVeyor first? ;)
 
9:08 AM
not again!
tbh, I should see if I can move it to azure pipelines, as that seems to be much faster
 
cmb
@Derick possibly; the issue is that AppVeyor apparently doesn't run the tasks in parallel (likely a limitation of the free account; maybe ask for more ressources?)
 
only their premium $99/month plan allows for more than one concurrent job: appveyor.com/pricing
 
We should also migrate away from appveyor ... opened github.com/php/php-tasks/issues/21
 
Right now, I have a different issue and that is that suddenly some of Xdebug's profiler tests are memleaking. I suspect the Observer API that's now merged in PHP ... but investigating now
 
cmb
@Derick php-src has two (I believe Anatol ask for that back then)
 
9:18 AM
considering I would really want to build more than I do now... and I have no idea how to tool to get Artifacts out of Azure either. I have a little script to do that with appveyor, and I cba to redo all of that :P
@NikiC If I have used USE_ZEND_ALLOC=0, how can I still see a Zend MM memory leak?
 
@Derick You can't...
 
Right, but I do.
 
Uh, environment not propagating? ^^
 
cmb
@NikiC but wouldn't we need a dedicated machine for that? Anhow, Dale is working on Azure pipeline builds, and is planning to open-source that when ready.
 
@NikiC It never failed before
 
9:21 AM
@Derick no idea
 
layer 8 problem
 
@cmb Why would that need a dedicated machine?
 
=-0 isn't =0
 
cmb
aren't our Azure builds already quite busy?
 
@cmb They are busy, but we do have 15 parallel jobs there, so there doesn't tend to be much queing
We'd handle windows the same as the other cases and do one PR job and run the rest as scheduled
Would probably also kick one of our x64 builds from PRs and replace it with windows
So we do one each of linux 64, linux 32, windows, macos
Well, depends on how slow the windows build is of course...
 
cmb
9:28 AM
Okay, that would be nice (was rejected back then, though). The basic issue with the slow builds are the tests, from what I can tell, and these are slow because all available exts are loaded every time (multiple times per test). Running without exts is way faster (3x - 4x)
 
9:41 AM
@cmb Is the loading itself (of the DLLs) the bottleneck, or PHP module startup code?
 
I found the PHP commit that introduced the memory leak: github.com/php/php-src/commit/7620ea15 (one of yours @NikiC)
 
@Derick Yeah you'll likely have to change your filename handling
 
Can you add a hint to upgrading.internals? :-)
 
@Derick it will not be more informative than the commit message
 
OK
 
10:23 AM
@NikiC Turned out that there was already a leak without your change too. Fixing that also fixed the new one that your change made show up → github.com/xdebug/xdebug/pull/639/files
 
11:07 AM
@NikiC I assume it's a hint for ext devs that something changed and needs to be looked at
 
11:52 AM
GOOOOOOOOOOOOOD MORNING, ROOM 11!!
@DaveRandom Wake up, Dave! It's Friday!
 
12:02 PM
ಠ_ಠ
 
@Sara Are you handling next week's release?
 
12:23 PM
I need to select 3 different tables, which have no relationship. Would INNER JOIN be used?
 
You're going to need to clarify the intent.
 
or UNION
 
Union would be the usual method if they're unrelated
 
12:46 PM
@Jeeves is this Mr. Ban Avoider?
 
cmb
yup
 
😒
 
1:32 PM
Well, I finally have the rename patch working again, except in appveyor.
 
1:48 PM
presented without comment (well unless you ask nicely) for your consideration
bah
no preview for you. click the damn link peasants.
 
it's only after travelling, that I became aware that the Department of Transport in the UK is a world leader in designing safe roads and signals.....most other countries have at least one 'feature' in their road designs that are inherently unsafe.
 
ZTS + preload = segfault on shutdown ・ opcache ・ #80092
 
Typical Nenechi
 
2:07 PM
@MarkR Example. On a finance screen, I need to list all the checkists, and all the OS that have been generated.
 
@Danack Yeah, basically.
 
cmb
@Tiffany yes, that matches my search results. We could change the ... to ...args for now, but the problem is that PhD automatically adds a leading $ to parameters names, so that would be rendered as $...args, whereas it should be ...$args. quick-and-dirty POC for PhD
 
@Danack France is not that bad, is it?
 
2:22 PM
the unsafe feature about roads is called Car
 
SELECT checklist.id, checklist.nomeCliente, checklist.nomeLoja, checklist.dataIni, checklist.arrayMaterialUsado, checklist.arrayComprovantes  FROM checklist
	UNION
SELECT os.id
	INNER JOIN os_mensagens ON os.id = os_mensagens.id_os
where am i wrong This is showing up:
Query 1 ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INNER JOIN os_mensagens ON os.id = os_mensagens.id_os' at line 4
What I mean is how is it right?
 
@NikiC If I've passed the zval to a user function, then I probably want Z_DELREF, no?
@NikiC Custom destructor for the hash table? Right now I loop through it, freeing the pointer before calling zend_hash_destroy. Is there an easier/better way?
Switching to zend_hash_destroy produced quite a few more leaks, so clearly I'm doing something wrong.
I'm using zend_new_array(0) to create it, that's probably wrong?
 
I am trying to find an email in file content and then echo the whole email. I am using strpos the location of email Like.
strpos($fileContent, "@gmail.com")
But how Can I get the the part before @gmail.com till an space with substr?
 
cmb
@Trowski you may need to use zend_hash_init, which allows to specify a custom dtor for the elements.
 
@Trowski Generally the pairing is Z_TRY_ADDREF + zval_ptr_dtor
@Trowski zend_hash_destroy will also need a FREE_HASHTABLE (if you actually allocate the table rather than embed it)
 
2:37 PM
sad that bug with id 80000 is for php 70490 ;) bugs.php.net/bug.php?id=80000
 
@cmb @NikiC Thanks! That helps move my pointer freeing to one place. I added FREE_HASHTABLE after zend_hash_destroy. Still getting a couple memory leaks though. zend_hash.c(153) : Freeing 0x0000000103817a00 (264 bytes), zend_hash.c(2072) : Freeing 0x0000000103796480 (56 bytes)
 
@Trowski hard to say
You're not freeing or dtoring something somewhere :D
Would have to see the code
 
cmb
@Trowski try with valgrind; that should produce more helpful diagnostics
 
I might be looking in the wrong place, I might be adding a reference to the fiber result when I shouldn't.
Yep, that seems to have been it. :)
 
2:54 PM
Also, I highly recommend having an asan build available to you :)
 
@NikiC If I want to store and clear an exception thrown when using zend_call_function, does this look correct? error = EG(exception); GC_ADDREF(error); zend_clear_exception();
@LeviMorrison asan build? Not familiar with that.
 
@Trowski looks reasonable
 
Basically add -fsanitize=address to your CFLAGS and LDFLAGS at configure time. Are you building this as part of PHP or a standalone extension build or..?
(and use run-tests.php --asan when running tests)
 
I'm working on a fiber extension I'd like to look at proposing for including in PHP 8.1.
This branch in particular at the moment: github.com/amphp/ext-fiber/tree/awaitable
API is a WIP, but here it is right now: github.com/amphp/ext-fiber/tree/awaitable/stubs
 
@Trowski do you have a real work demo example?
 
3:00 PM
@beberlei github.com/amphp/green-thread/tree/awaitable The examples directory has some simple demos.
simultaneous-async.php is the most complex.
 
ah better than demo/ in ext-fiber, would it be possible to file_get_contents in the fiber callback and then have it parallel?
 
@beberlei Yeah, sorry that demo dir is out of date for that branch.
 
i really have no clue what fibers enable in terms of concurrency :)
 
@FlorianMargaine there's a couple of things that seem to be accepted in France that are just never allowed in UK roads. e.g. slip roads/onramps that are too short That junction is fine when there's no traffic. And it's fine when there's heavy traffic, so everyone is moving slowly.
 
@beberlei If this extension was in PHP, then yes, though of course the implementation of file_get_contents would need to be updated.
 
3:04 PM
But when there is moderately heavy traffic, the cars are all moving fast, and there isn't enough time to merge safely. And as the slip road is only 50 meters long, you have to choose between doing an unsafe merge, or slamming on the brakes, and having any care behind you probably ram into you.
Also, the habit in the countryside of not making roads wide enough for two cars, but everyone still passes each other at 100km/h, with half the wheels on the grass....
 
@beberlei Are you familiar at all with Amp?
 
@Trowski so from wikipedia (fibers use cooperative multitasking) i am making assumptions, with a fiber everything still runs linear. and unless something with blocking I/O has explicit code to "yield" to another fiber the API is just looking parallel, but is essentially not
 
People on French roads have at least 50% more fatal accidents per whatever you want to measure it by, than UK roads.
 
@Trowski only seen it talked about here, never used Amp yet
 
@beberlei The key is to use non-blocking IO and always yield/suspend the fiber until the IO completes.
Are you familiar with promises in any language?
 
3:10 PM
ok, so essentially everything blocking in PHP would need to be updated to support yielding in some way to support it
yeah i am
 
@beberlei Yes. Though Amp has libraries that do most anything you'd need.
 
so i wouldnt use file_get_contents, but Amp\file_get_contents (or its equivalent)
 
Yes
 
its not as cool as joes parallel, but it wouldn't require ZTS i suppose ;)
 
Right now Amp functions have to return promises though. With fibers, they could return the expected value while still being non-blocking.
@beberlei No, it doesn't.
Fibers are still single-threaded.
Joe's parallel is awesome, and compliments rather than competes.
 
3:17 PM
@beberlei my understanding is, you could run workers with parallels, and then do async communication between the processes with fibres....which would be equivalent to Go's channels.
 
cmb
@NikiC seems to be both; see gist.github.com/cmb69/f4b59837478476bea0867eedc6a9188d for details (although the perf difference is way smaller than I formerly measured; not sure why; need to investigate)
 
hi testing hello world
 
@Danack amphp/parallel does exactly this (though not yet with fibers, of course).
 
@cmb would it be preferable at all to just not add anything special for <parameter>? It seems like adding extra content is a hindrance now, and will likely be a hindrance in the future if the language and/or manual evolves...
 
cmb
@Tiffany not sure if I understand, but I think we should show variadics like they're written in PHP 5.6+
 
3:28 PM
I might be missing something, I'll research a bit more
@cmb I see, so it would only add ...$ in the situation where ... is present, specifically for variadics. I'm slow.
that's simpler than going through it all by hand, which is what I was expecting would have to be done :P
 
cmb
@Tiffany currently, PhD always preprends a $ to every parameter. With that patch, it makes $foo from foo and ...$foo from ...foo
a maybe cleaner alternative would be to add some attribute (say, variadic) to <parameter> which could be used to construct the actual param name
 
<parameter variadic>, or <parameter attr="variadic">, or something else?
 
Hello guys, is there any tool to check if 2000+ email addresses exist or not?
 
@rangerboyy need more context
 
I got a client and he has got 1000+ email addresses with him. He wants me to check if they are valid and exists or not.
 
cmb
3:38 PM
@Tiffany or maybe <parameter role="variadic">; I think that would be conforming to docblock standard
 
@Tiffany you know any way of doing that?
 
@cmb Thanks, that's interesting. Is that with a debug or a release build?
 
cmb
release build TS
 
@cmb yeah, I like that
 
@rangerboyy You can't, the best you can achieve is checking if it doesn't bounce back, but for that you need to send an email to said address, which is probably not feasible
 
3:39 PM
Please add dynamic defining for class constants ・ Class/Object related ・ #80093
 
@MateKocsis @Girgias Heh, looks like we were a bit too optimistic when it comes to getting all warnings promotions done for RC1...
 
@Gi
@Girgias oh okayyy
 
@NikiC Well, we did our best :D
 
cmb
@Tiffany there may be a conflict with <parameter role="reference"> though :(
 
@cmb As a quick idea, we could cache the result of SKIPIF sections by hash. Probably we don't have that many distinct skipifs. Not sure how much that would save though
 
cmb
3:45 PM
@NikiC that may be sensible. What I had in mind was loading exts on demand, but that would require to explicitly state the required exts in the tests.
 
@cmb And would require us to fix the --EXTENSION-- section ... or at least figure out what it's actually doing, because I have no idea ^^
 
cmb
@NikiC well, it's supposed to load required extensions if not already available; not sure if it works, though; need to check
 
@cmb this question is from complete inexperience, but could we do something like $attrs[Reader::XMLNS_DOCBOOK]["role"]["reference"] and $attrs[Reader::XMLNS_DOCBOOK]["role"]["variadic"]?
or something of that sort... or maybe have $attrs[Reader::XMLNS_DOCBOOK]["role"] = "reference"; and $attrs[Reader::XMLNS_DOCBOOK]["role"] = "variadic";?
^ is probably better
 
cmb
no, that would not work; we could have <parameter role="reference,variadic"> I suppose, but not sure whether that would have to be regarded as hack; note that variadics can be passed by-ref as well
--EXTENSIONS-- appears to be supported: github.com/php/php-src/blob/php-7.4.10/tests/run-test/…; running without openssl in php.ini works; removing openssl from that section lets the test fail
 
3:56 PM
I'll have to think on it when I'm able to devote more attention. Brain's a bit distracted right now.
 
cmb
sure, take your time :)
 
If an exception is thrown from a function called with zend_call_function, does that set EG(exception)?
Or is there something else I should be checking?
 
@Trowski yes
 
@NikiC What if I want to throw a different exception but use the one in EG(exception) as the previous?
 
@Trowski I think you just throw your exception then
it will be automatically set as previous
 
4:10 PM
@NikiC It is :) That was simpler than I thought it would be.
 
@NikiC Any objections if I merge in github.com/php/php-src/pull/5871?
 
@GabrielCaruso Sure. I'll take it. Still deciding if I want to branch or not. I'll pose that question to the list.
@SammyK Dunno if you saw the final cut, but your guitar track worked REALLY well in the Sunshine ElePHPants video. youtube.com/watch?v=lun5yichGmc
 
@Sara I did! \0/ Made me giggle. :D
Let me know if you need more elePHPant soundtracks. :)
 
I likely will :D
Someday... when travel happens again
/me ponders....
What if....
Okay, I have an idea for a video. I can shoot it solo, but I'll probably ask for some voice work. Let me work out the script and get back to you...
 
cmb
@NikiC, interesting test perf difference: gist.github.com/cmb69/657d2df6967aee14b46340bdbd0a19d2 (I shall run that again, though)
 
4:22 PM
/me giggles and runs off to find elephpants
2
 
@Sara :much_excite_doge:
 
Is the stack allocation of exception ok here? github.com/amphp/ext-fiber/blob/awaitable/src/fiber.c#L146-L176
 
@cmb awesome result :)
 
5:08 PM
@Trowski yes
 
Hello
anyone could help me with php email?
@bw
@bwoebi hello
are you skilled in php ? could you take a look at my question? Maybe you could help to solve my problem
 
@LuboMasura Please don't ping random people for help unless you know them.
 
I just asked for help, sorry
 
Sometimes the room is slow on Fridays- just post your question and someone may answer it when they have a moment.
No worries.
 
1
Q: PHP - checkbox value display in E-mail responder

Lubo MasuraI have checked all the questions first. But non of them helped to solve my problem. I have PHP E-mail responder connected to HTML contact form. I need to display selected checkbox value inside the email responder which is sent to customer. PHP code <?php if(isset($_POST) && ($_POST['send'] == 1)...

 
5:20 PM
fyi I'm slow every day, not just fridays
 
here is my problem
 
See guidelines here: room-11.github.io
@DaveRandom Me too, but mentally. =P
 
@StatikStasis I don't think they'll help me be quicker but sure I'll check them out
 
/me goes out drinking \o/
 
5:21 PM
:-D
 
@DaveRandom Be careful - lotta weirdos out there.
 
one more now
inhabit
 
@StatikStasis thank you for posting the guidelines, I have read them.
hope someone reply to my question :) thx
@DaveRandom enjoy your dinks :-D
drinks
 
@LuboMasura tbh at this time on a friday it's not all that likely, but please note that it's just because it's friday night and everyone is busy doing other stuff :-)
@LuboMasura I love a good dink
/me actually leaves
ttfn
 
5:25 PM
yes, I know
 
When trying to use valgrind, I get Fatal error: Error installing signal handler for 31 in Unknown on line 0 Could not startup. Is there a env var or something else I need to set to stop that?
 
@Trowski Toggle zend-signals
(I do not know by heart whether it needs to be off or on, but it's what you do not have compiled right now)
 
Do I need to recompile or is there a flag I can set to turn it off for a run?
 
You need to recompile, configure flag
it's toggling a preprocessor define, so you need to clean
 
Ok, thanks.
 
5:51 PM
@LuboMasura Glad it worked- accept answer and thanks.
 
:) thank you you have it
@StatikStasis
 
@StatikStasis so, you have started answering questions, good for you.
 
@mega6382 yeah- no. That was a one off because I was procrastinating doing my own work.
I'll do another in another 3 years or so.
=P
 
lol, still its a lot of fun, you should give it a try sometimes
 
If I can find time. =)
To busy in here goofing off with you guys @mega6382 =D
 
6:06 PM
yeah. that definitely slows you down :P
 
6:35 PM
I've a somewhat goal of gaining most of my rep from edits...
only 72 rep so far though
 
you can't go over 2000 with edits, iirc
after you reach 2k you stop getting edit rep, because you don't need approval anymore
 
7:27 PM
Is there a way to forward an exception to the set exception error handler if there is one?
 
Rethrow it?
 
Digging a bit, looks like EG(user_exception_handler) is what I'm looking for. Though it appears to be a zval, not sure how to call from a zval… I've always had zend_fcall_info.
 
@Trowski x/y detected.....maybe. Why are you trying to do that?
 
In the fiber extension I'm working on, a fiber has a set of callbacks when it finishes. That callback shouldn't throw. If it does, I was going to forward the exception to the user exception handler or fatal error.
 
@Trowski I think normally, you just look at if one of those callbacks has thrown an exception, and stop processing the other callbacks, and resume control to the engine....which then would do the appropriate exception stuff for you.
!!lxr array_map
 
7:37 PM
Total number of search results: 3
• [ /php-src/ext/standard/basic_functions_arginfo.h::2334 ] ZEND_FUNCTION(<b>array_map</b>);
• [ /php-src/ext/standard/basic_functions_arginfo.h::2957 ] ZEND_FE(<b>array_map</b>, arginfo_array_map)
• [ /php-src/ext/standard/array.c::6009 ] PHP_FUNCTION(<b>array_map</b>)
 
@Trowski I think you maybe should just resume the main fiber and rethrow it there?
which would typically be within an event loop where you can catch it and have centralized error handling
set_exception_handler() is more like call before register shutdown, if all else has failed
at least that way round a global try { Loop::run(...); } catch (Throwable $e) {} will just cleanly fall through
 
What if there's additional callbacks and the first callback throws?
 
@Trowski resumed when the fiber is resumed afterwards
 
@bwoebi The fiber completed, so it won't be resumed again.
I'm talking about callbacks registered on Fiber::onResolve()
 
@Trowski Let's just not have callbacks on Fiber.
 
7:46 PM
I know… I'm basically suggesting to consider the fiber code like $result = runUserCode(); while ($cb = $nextcallback()) { try { $cb(); } catch (Throwable $t) { Fiber::throw($t); } }
and the fiber code running is only really complete until all callbacks have been called
 
@bwoebi We just decided to drop Fiber implementing Awaitable, so there's no collection of callbacks to invoke, eliminating the problem completely.
 
@bwoebi The fiber has completed though, I can only throw into the previous fiber.
@kelunik Uh… no, we didn't.
 
@Trowski You should wrote "Yes, that will still happen."? :o
 
@kelunik I thought you meant if one threw.
 
@Trowski I guess we probably need a callback on the Fiber object
Fiber::onError($cb)
 
7:51 PM
No. I don't see value in Fiber implementing Awaitable. At least not enough to justify the issues.
 
If I remove the callbacks on Fiber, then I still have the same problem.
 
@Trowski Could you elaborate?
 
The exception from a fiber throwing then has to go to the Awaitable::onResolve() callback that resumed the fiber, so then we have an unhandled exception there.
 
@Trowski Which is automatically thrown into the loop in Amp, so that's fine.
 
Which also happens if Fiber implements awaitable, but then we don't have to tell implementers of Awaitable to expect their onResolve callbacks to throw.
 
7:54 PM
@Trowski And with the implementation in async, there are never uncaught exceptions inside a fiber.
 
@kelunik Only because we did it that way. Other using fibers may throw from them.
The local update I have of async doesn't catch the exception anymore because it doesn't have to.
 
@Trowski It still needs to, because it needs to fail the promise returned from async
 
@kelunik It fails it in an onResolve callback, but only because I needed to return a Promise, not an Awaitable.
 
@Trowski They'll have to expect callbacks to throw anyway, because users might register their own.
 
That's true, rather I should say that an onResolve callback throwing is unexpected, rather than expected.
@bwoebi What happens when that callback throws :-P
 
8:01 PM
It's exceptions all the way down :P
 
Sure. But I think it always bubbles up to the scheduler that way and it's a lot better than solving multiple maybe throwing callbacks and then solving what to do with that exception.
 
The other problem with a fiber not implementing awaitable is that the fiber return value has no where to go.
 
@Trowski Threads in Java are void too, don't see a problem there.
 
Seems very odd API-wise that the only way to get a value from a fiber then is to implement your own deferred.
I can't start a fiber and then later await that fiber unless fiber is an awaitable.
 
@Trowski We can add a deferred implementation.
 
8:05 PM
@kelunik Which will need callbacks on it's awaitable :-P
 
@Trowski Fibers are expected to be a low level API to be wrapped by frameworks.
@Trowski damn... :P
@Trowski I think it's fine, you need your own scheduler, too.
The only purpose of Awaitable in core is basically saving a closure :P
 
Right, I could just drop the awaitable idea and go back to the API where Fiber::suspend took a callback.
Then frameworks can resume fibers however they see fit, rather than enforcing a promise-like object.
 
@Trowski Rather the current master of green-thread?
So Fiber::getCurrent() + Fiber::resume() and Fiber::suspend(), all without parameters.
 
That was fine too I guess. I liked that the callback to suspend didn't require you to call Fiber::getCurrent() to get the reference to the fiber object.
Plus it made suspend return a value, which IMO is a bit more intuitive.
 
@Trowski then you just handle it like an exit() emitted in the main fiber and resume the shutdown sequence
 
8:17 PM
Fiber::suspend(function (Fiber $fiber) use ($promise): void {
    $promise->onResolve(function (?\Throwable $e, $v) use ($fiber): void {
        if ($e) { $fiber->throw($e); return; }
        $fiber->resume($v);
    });
});
 
@Trowski But is switches fibers two times instead of zero for already resolved promises.
 
@Trowski Oh please don't set is up to have 15 competing fiber wrappers in user space that don't work with each other. Please.
 
@kelunik Hmm?
 
Er, @kelunik.
 
@kelunik Oh, now I understand. No, it doesn't.
If resume or throw is called in the callback, then the fiber doesn't actually suspend.
Which was true in the awaitable branch too.
@Crell That is a reason to have Awaitable in core, one promise to rule them all /cc @kelunik
 
8:19 PM
@Trowski what's suspend(callback) supposed to do?
I don't get what exactly the cb does
 
@Crell different wrappers will happen without the scheduler in core, but we've designed the API in a way so that multiple projects can interoperate and don't break each other. However, if they're not using the same scheduler, different schedulers will still block each other.
 
@Trowski No it isn't. One promise is basically not relevant with fibers, because promises are no longer viral.
 
@bwoebi You set up the code to resume or throw within the callback. It avoided requiring references or another object (though at the cost of a closure… so it's a bit of a toss).
@kelunik Yeah, good point. The event loop is the only real interop hangup.
 
@Trowski how exactly is that superior to just $fiber = Fiber::getCurrent(); $promise->onResolve(function($e, $v) use ($fiber) { ... }); Fiber::suspend();
ah okay
 
8:22 PM
@Trowski Maybe we should propose that to core at the same time?
 
@Trowski but… you are anyway acquiring the reference, just within the closure
 
I don't know the details, I am just begging you to not create a situation where FIG will have to re-standardize anything, which some projects will ignore on principle. :-)
 
@Crell It'd have to standardize the event loop, which already failed.
 
Right, so let's please not create the same problem at a different level. :-)
 
8:27 PM
@Trowski I don't think we should have the suspend($cb), this also has a strong assumption that the fiber gets to decide itself when it is going to be resumed … which we can still have, but only explicitly, and not mandated by the API
 
@bwoebi The same problem exists with Fiber::getCurrent().
The only way to get a reference to the fiber is within the fiber.
 
@Trowski oh, run() is void
I thought it'd return a fiber
 
It originally did, but we removed start() and simplified resume and suspend to all be void methods.
 
hmm… let me consider it a few min more
 
If you use a fiber like we did generators in amp, then another library couldn't use a fiber without having interop issues.
Was fine with generators since they're self contained, but fibers are an issue since another lib could call suspend expecting their promise implementation.
 
8:33 PM
@Trowski what about Fiber::suspend(function (callable $resume, callable $throw) {}) then and not having a Fiber object at all?
 
@bwoebi That was the eventual plan with that branch, yes.
I got distracted with trying awaitables though.
There probably still needs to be some function to tell if you're in a fiber or root.
 
@Trowski what for?
 
The API can be just Fiber::run(), Fiber::inFiber(), and Fiber::suspend(function (callable $resume, callable $throw) {})
 
@Trowski it'll just throw FiberError, you can catch that if you want a specific error
 
@bwoebi Would be nice to not generate an exception to have top-level await in amp /cc @kelunik
 
8:37 PM
Ah
 
Still need the Fiber class for suspend anyway.
 
@Trowski but you get that info from your event loop whether it runs or not
that's not tied to fiber
nor should it be … technically your event loop could be not started despite you currently running a fiber
 
That was the subject of a long debate @kelunik and I had.
 
@bwoebi not sure what the advantage is over the fiber object
 
I advocated for an API that required wrapping the app in a call like Loop::run() so everything was in a fiber.
 
8:41 PM
@bwoebi it should be started if running in a fiber, otherwise it does not interop with others using fibers
 
@kelunik it's more explicit / highlighting simplicity … feels more natural to me
@kelunik why is that an impediment to interop?
 
@bwoebi consider guzzle using fibers. In some middleware you now call an amp lib. Amp's await should then run the event loop, but it still blocks.
@trowski just noticed this breaks if you have amp - > guzzle - > amp, because amp doesn't run the event loop then and it'll hang.
 
@kelunik I do not see the issue: await calls the event loop, the event loop waits for its events, processes them … at some time the promise of await gets resolved and it continues
 
So I guess we need to bind the scheduler to Awaitable to allow interop
 
@kelunik Because curl_multi blocks you mean?
 
8:53 PM
nesting event loops is a terrible idea anyway
 
@Trowski yes. So the inner amp promise will never resolve
 
@kelunik Yeah… interop is just impossible without a shared loop.
 
@bwoebi sure, they'll block, but it shouldn't be worse than blocking IO
@Trowski it's possible to make it as bad as blocking IO, and that should be the goal if we don't ship with an event loop in core at the same time
 
If we could put an event loop in core then I like the awaitable-style implementation.
 
If we have an event loop in core, I'd use the method less style
And just have async await keywords
So you don't need a closure passed to async, but can directly put it in front of a call
 
00:00 - 21:0021:00 - 00:00

« first day (3618 days earlier)      last day (1327 days later) »