« first day (1942 days earlier)      last day (3006 days later) » 

7:00 PM
@bwoebi just dump what gets collected in gc?
 
ugh … just my own stupidity operating on an old checkout :-/
 
@bwoebi so you're completely cycle free now?
 
no
not yet
@NikiC when that line lxr.php.net/xref/PHP_MASTER/Zend/zend_gc.c#1094 never gets hit means that I'm cycle free, right?
 
@bwoebi I'd say so
 
then I'm cycle free in websockets code
 
7:15 PM
@user2800382 not sure if it's a problem but it's all about having different absolute/relative paths ie. xcom.com/files/file.png (html) - /var/www/xcom.com/files/file.png from server and when you upload a file and have it on the file server you first have the latter one.
 
7:36 PM
Interesting comprehensive map of every country in the world that uses the MMDDYYYY format https://t.co/vgB9FYLGxe
 
@LeviMorrison allowing non constant expressions didn't seem confusing to me. It's probably the future scope section that looks a bit scary.
 
@Wes you asked about the hash() method earlier. It's in the Hashable interface: github.com/php-ds/ds/blob/master/php/include/Hashable.php
 
Wes
@rtheunissen do maps and sets implement it, right?
 
They honour it, but other objects implement it.
So if you want your class to be used as a key, you could implement hashable and control that behaviour.
Otherwise object keys fall back to spl_object_hash
 
Wes
i see
 
7:48 PM
Which is basically obj1 === obj2 I think.
 
Wes
for scalars what kind of hash gets generated?
 
Exactly the same as what the PHP array uses.
@JoeWatkins you had me worried saying you noticed something.. but that's awesome. :D
 
@rtheunissen You don't do numeric string conversion tho, right?
 
Correct, so "1" and int(1) are not the same key.
 
k
 
Wes
7:52 PM
how about floats' hash?
 
@rtheunissen And it's also fine to use doubles, null and bool?
 
Yeah should be fine.
 
@rtheunissen I mean, you preserve the values?
 
@NikiC I somehow have a deferred with tens of thousands of when()'s … oh well.
 
Wes
7:54 PM
contains(...$values) not a fan of this though
 
@Wes elaborate please
 
Wes
i dislike variadics
should be contains(Collection $values)
 
What if I just want to say contains('a') ?
 
Wes
yeah i meant containsAll
 
containsAll
contains being variadic is nice because you can use contains(...$array)
containsAll would work on an array as well, or other iterable.
 
Wes
7:58 PM
what if $array is actually a ds\Collection ? would the unpacking work in that case?
 
Yes it would.
 
Wes
@rtheunissen oh.. but it would use a regular array temporarily, no?
 
@NikiC ^ how does unpacking work for non-arrays?
 
Wes
another thing i'd change is Map::containsKey(...$keys): bool {} into
$map->keySet(): Set->contains($key)
$map->keySet(): Set->containsAll(Collection $keys)
 
8:01 PM
@rtheunissen similar to iterator_to_array
 
@rtheunissen It supports Traversable. Note though that it must not have string keys
 
Wes
and similar methods too
 
@rtheunissen Btw, I'm also not a fan of contains. If you support multiple values it should be either containsAll or containsAny, otherwise it's just ambiguous
 
@Wes I like that but only if the ->keys() is a view on the map, otherwise you create a Set in linear time.. then a contains? That defeats the constant time lookup.
@NikiC I'll have to think on that for a while.
 
Wes
@rtheunissen yes, that object implementing Set would be a "private class" delegating to the Map it comes from, not a copy
 
8:05 PM
@Wes exactly. :)
There are some cool things we can do..
 
Wes
i have contains($content), containsEachOf($contents, $respectCardinality), containsNoneOf($contents, $respectCardinality) and containsSomeOf($contents, $respectCardinality)
 
While that is very clear for the reader.. I'd consider it confusing for the developer.
I feel like I'd have to look up the docs to figure out which contains I should be using.
Or at least have to think about it.
 
Wes
i don't actually know where i'm going, so far i'm just throwing things at it and trying to give them some kind of logic
 
Wes
but yeah i will remove some stuff eventually
 
8:09 PM
@Wes I'm trying to come at it from the user's side.
contains($value), contains(...$values) I quite like that.
containsAll($values) is a good idea though.
I expect to a lot to change before a 1.0
 
Wes
* This should be equivalent to a count of zero, but is not required.
* Implementations should define what empty means in their own context.
that sounds like a lsp violation welcome party :P
(isEmpty)
i'm being very direct throwing out my (limited) experience... sorry if i don't sound nice :D i actually like it and i always appreciate any effort made to get a nice data structures lib in php
 
I appreciate the criticism. :) What do you mean by lsp violation welcome party?
 
Wes
8:26 PM
well, the definition of empty should be well defined in the interface, just count() == 0
like, if i substitute Vector with Deque i must be sure that method behaves consistently
 
any Laaravel pros here?
0
Q: handleProviderCallback not firing in Laravel Socialite

NikanorI have spent a day trying to get Socialite working with Facebook. I have logged user in with the method: public function redirectToProvider() { return Socialize::with('facebook')->redirect(); } But my ip not getting any info in handleProviderCallback method: public function handle...

can someone help me with this
 
Wes
subjective: i dislike names like pop, poll, push, unshift, shift. i know they are pretty standard by now but it's super hard for newbies to memorize them. i'd go with append, prepend, pickFirst, pickLast, and similar stuff... first grade english, basically :P
 
@Wes I like prepend and append too, but what's the first grade equivalent for shift?
removeFirst is the only one that works.
I think it's important to align an API with what people will expect.
 
@Wes I always disliked unshift. But push and pop are just... well, depends how much assembly you've been exposed to :p
 
8:34 PM
array_push, array_shift, array_unshift etc.. are functions we have been using for a very long time. I wouldn't call it shift and unshift, but because that's what we're used to and have been using, it's easier to pick up.
Deque was an interface with addFirst, removeFirst, addLast, removeLast
 
@Gordon thought I recognised that name, guy also did a PHP SDL extension. On my list of 100 projects I intend to filter down to 10, I have a more complete/up-to-date SDL wrapper
 
Wes
eventually you get used to everything... but would be better if methods had simpler names from the beginning
 
I know.. and it's difficult not to innovate too much
Should be an easy transition for the common PHP dev.
 
@Leigh funny, I just googled for a php-sdl extension but couldn't find one
 
@Gordon Not sure how you missed it... github.com/phpsdl/extension
 
8:42 PM
@Nikanor I though their official name was Laralovers
@Leigh didnt check his other projects
 
I mean, all the keywords are right there in the URL :p
should have got google results
I think an SDL 2.x ext would make a good project
 
Wes
@rtheunissen also i'm not a fan of implementations of raw abstract structures. for instance i'd have Stack having the Sequence functionality as well, even if it doesn't have random access and things. if you don't expose such functionality the risk is that when the users need such functionalities, they will access the data in a poor way, like converting Stack into a Sequence or array, iterating over it or whatever, in a non-optimized way. the more you offer the less the users can do nasty things
 
9:01 PM
@Wes Bad bad bad idea
 
Wes
why?
 
That's pretty much all that is wrong with SPL
@Wes Don't couple your structures to specific implementations
 
@Wes you acomplish that with aggregate structures that build on top
 
@Wes I'd say a stack that behaves only like a stack encourages users to use the data structure correctly
 
Wes
@NikiC when did i say that? i'm saying each implementation should offer the functionality of more generic abstract structures in their own optimized way. say i have a sortedset that is implemented with a tree. why should i convert it to an array first, to get the element at offset 3, for instance? thing that could be achieved easily traversing the tree without copying the data?
@Leigh but when you need an exception to the rule you'll be forced to do nasty things, like copying the data, iterating... while the implementation could offer its own proper way to achieve the result
 
9:14 PM
@Wes What is offset 3 in a tree?
oh, in a sortedset.
 
Wes
@ircmaxell yes. not saying it should be done with "extend"
$sortedSet->asSequence() /* no copy is made */ ->get(3)
 
@Wes cool
 
9:28 PM
@Wes $set->sort()->get(3)
I really like the idea of structure views, so that something like $map->keys() doesn't actually create a Set if it doesn't have to.
 
@Wes ah, okay :) I misunderstood what you had in mind there
 
Wes
@rtheunissen you mean view as being immutable, or reflecting the map's data?
$map->set('foo', 10);
$map->keySet()->remove('foo');
the Set returned by keySet() is actually a super interface of Set, because
$map->keySet()->add('foo');
$map->get('foo') // what will this return? null?
c# and java throw "not supported exception" iirc, but i'm not sure if i like it
 
hi all!
whats the best php forum (free+commercial) out there these days?
 
@Wes reflecting the map's data.
@Wes $map->remove will always be the key. Makes no sense to remove by value.
 
Wes
depends...
 
9:40 PM
$map->keySet()->add('foo')... egh.. why wouldn't anyone?
Depends how?
 
Wes
well, it's not impossible...
 
Try to think of actual use cases vs 'because we can'
If you really want to remove by value you can filter
 
Wes
does filter create a copy?
 
When have you ever seen a php associative array where entries are removed by value.
Yes it does
 
Wes
not against copies - just different stuff
 
9:43 PM
Because array_filter does
 
@rtheunissen I'd assume that these have rather limited applicability?
Are they really worthwhile?
 
I'm not convinced, no.
 
I feel trolled by PHP. …
I var_dump() the shit out of PHP, but there's nothing justifying 280 MB used
nothing in gc buffer
 
They're cool but.. not sure when they'd be practical
 
@bwoebi "used"?
 
9:48 PM
@NikiC AG(mm_heap)->size shows 280 MB
 
and what is size?
allocated or used?
 
used
 
ok
 
there's real_size for allocated
 
@bwoebi I think you know what you have to do
Implement a memory profiler for PHP!
 
9:49 PM
@NikiC no, I don't.
lol
 
:P
 
It'd be enough to have a memory profiler for C
 
@bwoebi Tried massif?
 
Wes
@rtheunissen just one thing before i leave. i haven't tested the ext yet (i'm on windows and i'm not great with compiling :D) an example of what hash() returns in set and map? does equals just compare the hash code?
 
I never was able to get much out of memory profilers
 
9:51 PM
@NikiC never heard of, let me try…
 
@bwoebi part of valgrind
 
@NikiC yeah, found it
oh
I think I have found something, let me verify…
 
@Wes I could give you a Windows dll to play with? hash is implemented by an object that is being added to the set. The return value of hash just determine where the key goes in the hash table, so you could return 0 for everything but you'd destroy the table's performance.
When you call $set->contains($key), the table uses the key's hash as a starting point to find the key-value pair in the table. For each pair in the collision chain (where multiple keys used the same hash), equals is used to determine if we've actually found the key we're looking for.
It's practically identical to Java's hashCode() and equals()
 
@bwoebi I haven't used it 'recently' but vtune was always the go to thing: software.intel.com/en-us/intel-vtune-amplifier-xe
 
Wes
@rtheunissen an example implementation of equals() ?
 
10:02 PM
Let's use a User model as an example. hash() might return user->id, equals() would be $user->id === $obj->id
The argument passed to Hashable is guaranteed to be an instance of the same class
So the ->id would be safe.
Maybe not the best example..
 
Wes
no polymorphism?
 
@rtheunissen What if it's two different classes with a common hashable ancestor?
 
not sure if that makes sense...
 
I'd be happy to re-evaluate this.
 
10:04 PM
@rtheunissen Does java also restrict to same class?
seems pretty weird to me
 
Wes
nope @NikiC
 
I don't think so
 
Wes
equals(object any)
 
Would you have to use instanceof then?
 
though just now I can't come up with a great example...
 
Wes
10:05 PM
java is not great with equality though
 
Could just drop the same class test.
Or not be so strict about it.
Same class or child of.
I like the safety of knowing you can use $user->id because you know it's a user.
 
@rtheunissen best to come up with some examples where different behaviors are useful
 
Can't agree more.
 
I mean, the all-the-way behavior of arbitrary values can technically also be useful (think GMP and int), it's just not very likely...
 
Wes
equals() returns a boolean, so if type doesn't match you'd expect it to just return false
 
10:11 PM
If we drop the same-class check, I can see if (is_a($obj, self::class) && $this->id == $obj->id) everywhere..
 
Wes
for the same reason contains(object element) and containsAll(Collection<?> elements) are untyped
 
Generics would change a lot.
 
@rtheunissen ugh is_a
why do you use is_a?!
 
I know..
 
why not instanceof?
 
10:12 PM
I put myself in the shoes of someone implementing equals :p
 
Wes
i did it completely different @rtheunissen, my hash() function returns a GUID and equals is just $objectA->hash() === $this->hash()
 
Hah @Wes that's interesting
hash shouldn't be used to determine equality (or identity)
 
Wes
depends how you see them...
 
"Globally unique identifier" seems like it would be safe :D
 
It would work but made me smile
$objectA->uid === $this->uid would be better
@NikiC if ($obj instanceof self && $this->id == $obj->id) better?
 
10:19 PM
@rtheunissen yes :)
I know, I focus on the important things only :P
 
I guess the instanceof isn't so bad.. noted down that the OBJ_CE check should be re-evaluated.
I'd prefer an internal instanceof, but that would fail for something like GMP
 
@bwoebi did you track down your memory wastage?
 
@NikiC not yet
 
Wes
going to bed \o gn @all
 
Night @Wes thanks for the feedback
 
10:33 PM
hi @rth
hi @rtheunissen, can you tell me what's wrong with this bench : pastebin.fr/45758 ? Because it shows really different values than your bench
 
@JesusTheHun what were the results? I see some issues though.
 
Wes
think about it @rtheunissen it's basically the same thing, except you can cache it. for example:
equals($other){
return $other instanceof self::CLASS
&& $other->foo1 == $this->foo1
&& $other->foo2 == $this->foo2
&& $other->foo3 == $this->foo3
&& $other->foo4 == $this->foo4;
}
repeat that comparison every time you call equals() as opposed to:
equals($other){
    return $this->getHash() === $other->getHash();
}
getHash(){
    return $this->cachedHash = $this->cachedHash ?? $this->privateGenerateHash();
 
the result is Vector sucks x)
 
Construction time shouldn't be taken into account, so take the initial time before constructing the object or array.
 
construction is done once, its not in the loop
 
10:36 PM
Doesn't matter.
Also, use []= on the vector.
Function call overhead each time..
 
Wes
gn
 
cya
 
object_store is getting bigger and bigger … okay. … why !?
 
@rtheunissen the difference is like 15x slower, doesnt have a vm here
 
@JesusTheHun here what I see:
Array push duration : 1.0513081550598
Array Iteration duration : 0.13568115234375
Vector push duration : 0.59523510932922
Vector Iteration duration : 0.23838591575623
Array push duration : 0.69423317909241
Array Iteration duration : 0.13802409172058
Vector push duration : 0.54653215408325
Vector Iteration duration : 0.23976016044617
Results vary a lot.. so you should wrap multiple trials around it and take an average.
 
10:41 PM
your bench shows that it takes the same time for an array and for a vector ; Sequence::push figure, is that correct ?
 
Yeah almost identically the same.
 
You also say very fast iteration, throught the bench i've been able to run, it almost always take twice the time of an array iteration, can you relate that ? You've made no bench on that
- these are truly interested questions, not here to blame, I actually really love the extension you've done
 
I'll take a quick look. One sec
Looks like array iteration is faster :)
Theoretically vector should win though..
 
@rtheunissen btw just to check, you're not running those tests with opcache enabled are you?
 
Opcache is disabled on CLI I think
 
10:54 PM
@rtheunissen probably because slow path of object dimension dispatch?
 
why opcache should be disabled on CLI ?
 
6
Q: Zend OPCache - opcache.enable_cli 1 or 0? What does it do?

JackIn the documentation it says "mostly used for debugging" which would lead me think "never enable it unless you've a problem and need to do some debugging," however reading mostly everything that I could find about it says to enable it "opcache.enable_cli 1" but why? I could not find any informati...

 
That answer is bollocks.
 
@NikiC I really feel like I need a way to do a full-program dump of everything in global, static and local contexts.
 
@bwoebi so... a core dump?
 
10:57 PM
… in PHP.
 
@rtheunissen you can have opcache in the cli with file-based cache in php7
 
@rtheunissen oh, never thought about it. It totally make sense
@Danack actually, I don't really like bench that show numbers that aren't really life numbers.
 
I somewhere have hundreds of thousands of objects with refcount=1, which are not garbage collected and I have absolutely no idea what is referencing them
 
wait, if no opcache in CLI, then no interned strings, meaning a 500-length array with the same string actually store 500 times the same string in CLI ?
I don't know if interned string has been done in PHP7, that was something internal was talking about few month ago
 
I'm not sure if string interning depends on the opcache
@JesusTheHun looks like "very fast iteration" was based on theory.
 
11:06 PM
lol
 
I suspect that array foreach receives special attention :P
 
i'd love to leave there :p
 
Because in theory, a vector should iterate faster (if not equally fast)
 
"numeric" array has been optimize in PHP7
but still ...
 
@bwoebi where should I look for array's foreach?
 
11:09 PM
@rtheunissen ZEND_FE_FETCH/RESET in vm
 
Thanks
 
@rtheunissen also don't forget packed hashes
 
Not forgetting :) Which is why push is equivalent to vector
 
@bwoebi yeah packed hashes ! that what I meant by "numeric array" x)
 
I suspect that iteration is slow because it has to be done via zend_object_iterator
 
11:10 PM
yes
 
can't find ZEND_FE_FETCH in lxr :/
 
@bwoebi my lxr skills aren't exceptional.. can't find ZEND_FE_FETCH
 
well, I guess im no better than you lol
 
@rtheunissen ZEND_FE_FETCH_R and ZEND_FE_FETCH_RW, sorry
 
I don't understand what ZEND_OPLINE_NUM_TO_OFFSET does
 
11:17 PM
@JesusTheHun converts an absolute offset from op_array start to a relative offset towards a specific opline
 
do you mind to explain me what op_array and opline is ? I don't know anything about how opcache works internally (if it has something to do with opcache...)
 
no, not related
 
@rtheunissen yep
 
@JesusTheHun a Ds\Vector passes as IS_OBJECT
So foreach is optimised for IS_ARRAY, which it doesn't qualify as.
 
11:21 PM
yes it is
 
but if you find ways to make iteration more efficient without impacting array iteration much, feel free ;-)
 
@rtheunissen It is difficult to beat array iteration. It has to do with PHP arrays being special cased I think.
 
so... is a permanent domain change redirect as simple as setting response status code to 301 and location header to the new url?
also mornings
 
$array[0] is cheaper than $ArrayAccess[0].
The interpreter has direct stuff for the former but has to dispatch for the latter.
(Anyone feel free to clarify the holes or inaccuracies)
 
11:26 PM
it goes to read_dimension ?
in a packed array it just look in the bucket
at the numeric value you gave him, right ?
 
@JesusTheHun Depends also if it's internal or userland.
 
echo $arr[0];
userland :)
well no, it's for iteration throught foreach so internal
 
@bwoebi @LeviMorrison could an object handler for iteration work? I find it cumbersome having to use zend_object_iterator internally.
 
ZEND_FE_FETCH_R of for " foreach read" , right ?
is for*
 
for each do read fetch, yes
 
@rtheunissen don't know right now
 
^ That feels.. unnecessary
 
why unnecessary?
how would you do it?
 
@rtheunissen I haven't had time to look at your C sources; is something like Vector::map using the iteration API or short-cutting that and using only internal functions?
 
I don't know, just seems like a lot of boilerplate for iteration.
@LeviMorrison shortcutting.
 
11:36 PM
Good (I think).
 
Maybe something like $seq->each(function(){}) would be faster than foreach :S
 
doubt it.
 
Same, just thinking out loud really.
@JesusTheHun that filter benchmark is a good example of faster internal iteration.
 
what's the problem with $seq->each(function(){}) ? The lambda ?
 
@JesusTheHun the call itself
 
11:42 PM
what do you mean ?
 
the call to the callable
 
ok, what about it ?
 
is slow
 
what's the difference between using array_filter / Vector::filter and array_map / Vector::each ?
I mean @rtheunissen latest bench shows us that Vector::filter nails array_filter, both using lambda I guess, correct ?
(btw I love your bench scripts & structure @rtheunissen)
 
Neither using lambda.
array_filter($array) and $vector->filter() so just uses bool check
Closest I could think for iteration.
 
11:47 PM
@rtheunissen More likely the difference is in insertion time there
array_filter does not optimize construction of the return value
 
@NikiC good call, didn't think of that.
 
internally, considering an object iterator of a given type (let's say IS_BADASS_OBJECT) can't we give a pointer to the start of the storage, the length, and implement specific loop for this type of object that goes over ?
 
^ Shows that $vector->each(function($value){}) is worse than foreach @JesusTheHun
 
@NikiC Any way how to figure out container of an object?
I'm close to giving up :-(
I have no idea from where these objects could be referenced and a var_dump() of the reactor didn't show any usages
 
if its a known type, you can make a php function that echo the struct item by item, as xdebug does
 
11:54 PM
@bwoebi you mean find what references it?
 
@NikiC yes
 
maybe just scan allocated memory in gdb
 
I think there should be an internal iterator option where you provide a zval* and length, I think that's what you're saying @JesusTheHun ?
 
@rtheunissen That feels too specific to me
 
yep
 
11:56 PM
@NikiC scan for pointer address? hm
 
@bwoebi yah
 
but it has to know what kind of object it is to go look for it
 
write a gdb helper that loops over the allocated chunks and searches memory
@rtheunissen it wouldn't even support a map structure. that's too specific for me
 
@NikiC if you consider it for this extension only, but think of all classes that could benefit from it
 
Fair enough.. the key has to be considered also.
 
11:59 PM
im ok to optimize object that use no map ; it has been done for arrays with packed array
 

« first day (1942 days earlier)      last day (3006 days later) »