Watching the 3 of you just laughing and having fun was the best part of the episode :)
@АлександрКостюченко-у4х3 жыл бұрын
You are awesome! Thank you for all your videos! I wish to meet you someday) from Russia with love))
@joonasfi6 жыл бұрын
Awesome seeing you goofing around with my favourite container hero, Jessfraz!
@MffnMn6 жыл бұрын
Hey, love your content, but I'm not sure this video demonstrates how pools are useful, since the main performance gain comes from adopting the smaller struct for the payload. I ran the benchmark with a normal allocation to for data data := &pullRequest{} at the beginning of the function and this produced a 246 allocs/op, i.e the pool is only saving one allocation for us. Could you do a follow up comment or video on some cases where pools give a significant help?
@Phscyoman6 жыл бұрын
I was about to comment the same thing.
@JustForFunc6 жыл бұрын
Sure, I actually wanted to make sure people didn't get the idea that pools are magic and you should use them everywhere (they're not) I'll add the new episode somewhere
@AlexeyZhuchkov6 жыл бұрын
I also think that in this example it's better to use var data pullRequest Since it could be allocated on stack and stack memory is much faster than heap and does not require GC at all. However, judging by allocations, even in such a simple example, the compiler decided to allocate this memory on the heap. It would be interesting to know why.
@neknarqo6 жыл бұрын
Run the benchmarks from the episode with Go 1.11beta1 and got "64918 B/op 22 allocs/op". Twenty-TWO allocations!
@JustForFunc6 жыл бұрын
Waaaaaaat, that's amazing 😮
@marinprcela27786 жыл бұрын
Maybe it would be fair to do step one (without pool) but with smaller struct as in step 5. Your parents’ house looks lovely! ❤️
@jub0bs3 жыл бұрын
Exactly!
@_thehunter_4 жыл бұрын
thank you so much, for enlightening about pool with example.. I wasted hrs to understand this
@zohebakhtar11724 жыл бұрын
hi , i have GRPC client and i am storing client objects in a map and i am reusing the connection , is a good idea to create sync.pool for this case. how can i do that
@chneau6 жыл бұрын
lovely ending :)
@johnbalvin54016 жыл бұрын
Isn't the bechmark compare wrong? At the end it takes less resourses because you are only decoding one field and not because Sync.Pool
@rodrigolopes106 жыл бұрын
Hey man, what is this "whoseport" command? I was trying to find but I didn't find anything. Thanks man.
@deeeeeds6 жыл бұрын
Add this to your ~/.bashrc file: alias whoseport="lsof -i -n -P | grep $1" The command will slightly differ if you're not on a Mac.
@jimcanoa6 жыл бұрын
A linux version fwiw whoseport() { PID=$(sudo ss -H -p -l -4 "sport = :$1"|sed "s/^.*pid=\(.*\),.*$/\1/") ps w $PID }
Really thanks man, it will be useful a lot, I didn't know that.
@wilkins74076 жыл бұрын
"Okay, let's do it once more where you actually say it" 😂
@komuwairagu39426 жыл бұрын
hi @Campoy, regarding the fact that you need to 'zero'(for lack of a better term) out the thing you get from a Pool before using it; I was looking at the documentation for sync.Pool and I don't see it mentioned. Is that a bug in the documentation, or did I misread it?
@Kirides6 жыл бұрын
Well, you take something, write into it, read a value and return it back to the pool. The data you wrote into it, is still there, so the next function that uses the pool might get a pre-filled object and if it does not validate it correctly you run into issues. Usually pools are used for things like buffers where you rent a []byte, write into it and use it like this written := w.Write(buf, []byte("Hello! .... x100")) // this could be a serializer that reuses the given array val := r.Read(buf, 0, written) return val
@komuwairagu39426 жыл бұрын
thanks,
@musale22776 жыл бұрын
It's really nice seeing a comment from a familiar name :D Hi Komu!
@easternsunking2556 жыл бұрын
does golang has the method like c using "memset" to quickly reset the object to zero?
@pjox6 жыл бұрын
I am extremely disappointed, I saw the thumbnail and I thought you were going to do the whole video with a pair of cute huge glasses on, but it was just clickbait and you broke my heart :'( . Other than that, amazing video as always. Thanks!
@JustForFunc6 жыл бұрын
Now I need to buy humongous sunglasses
@pjox6 жыл бұрын
I agree! It should still be summer when the next episode of JustForFunc comes out :D
@hoaibaonguyen4776 жыл бұрын
Hi Francesc, thanks for the video. However I'm still not clear why in the last (5th) step, no reset is correct while in the 3rd and 4th step, you must reset the data in the pool. I can't see the difference between those steps. Could you clarify more? Thank you.
@JustForFunc6 жыл бұрын
The webhook always contains the field, so resetting it is unnecessary But it wouldn't hurt to set it to 0, or even keep the *int and set it to nil (one extra allocation)
@hoaibaonguyen4776 жыл бұрын
JustForFunc: Programming in Go ah I see. Thank you for a great video.
@TheSTVentertainment6 жыл бұрын
In the doc: "Any item stored in the Pool may be removed automatically at any time without notification. If the Pool holds the only reference when this happens, the item might be deallocated. A Pool is safe for use by multiple goroutines simultaneously." Can you explain this to me? Really appreciate it.
@petersafari98826 жыл бұрын
Would using jsoninter instead of encoding/json have any effect on the metrics?
@mishasawangwan66526 жыл бұрын
interesting i wrote a webhook bot for fun awhile back .. i have a question though, in the payload you use pointer to string and pointer to int.. why are these pointers instead of value types? thanks for the video
@vdemario6 жыл бұрын
Usually that's for the json package to put nil in the field when it's not in the payload.
@13TheGUNNER6 жыл бұрын
So that you can differentiate between a integer coming as 0 vs the integer not coming at all in the payload
@JustForFunc6 жыл бұрын
That's exactly why
@mishasawangwan66526 жыл бұрын
Subhojit Dutta damn that’s crazy thanks for the info
@hualetwang31056 жыл бұрын
赞,准备让我同事用这种方式优化一下我们的一个go库 😊
@azzalos6 жыл бұрын
Would've been interesting to benchmark with RunParallel in this situation, since requests would also come in like that.
@Kinagi6 жыл бұрын
Can't wait to start using sync pool in my work! Thank you!
@easternsunking2556 жыл бұрын
the example to use sync.pool github.com/Netflix/rend/blob/master/handlers/memcached/batched/conn.go#L189
@robertoferrer5356 жыл бұрын
Buenisimo como siempre
@neelesh20234 жыл бұрын
awesome
@dimitris50326 жыл бұрын
And I thought you would be doing this in a pool also wearing the sunglasses