Is postMessage slow? - HTTP 203

  Рет қаралды 22,239

Chrome for Developers

Chrome for Developers

Күн бұрын

Пікірлер: 44
@LewisCowles
@LewisCowles 3 жыл бұрын
Feel like the world needs a show with just Surma as well. They are so pleasant and energetic. Like the happiest worker on the deathstar. Totally removed from planet and rebel killing, working on tooling.
@forceboxed
@forceboxed 5 жыл бұрын
I loved this episode! You guys have great chemistry and I always find your videos kinda inspiring.
@hypersonic12
@hypersonic12 5 жыл бұрын
Great video! Thanks for providing the view into the development process for Proxx. A while ago I was trying to figure out how to send potentially megabytes of data using postMessage in a performant way for my day job....the end result was that we should come up with a better architecture that doesn't store that much data in the main thread. :)
@dassurma
@dassurma 5 жыл бұрын
For really big payloads ArrayBuffers + a serialization format like CBOR, BSON or FlatBuffers can be helpful. But in general I’d agree with you and advise to reduce the data required to be sent at once :D
@SimonBuchanNz
@SimonBuchanNz 5 жыл бұрын
Or SharedArrayBuffers, and start that nightmare 😭
@samuel.00
@samuel.00 5 жыл бұрын
"Today on Blackshirt and Greyhood"
@jakearchibald
@jakearchibald 5 жыл бұрын
I promise there's a radical wardrobe change in the next episode¹ ¹ This is a lie
@rongsenng
@rongsenng 5 жыл бұрын
2:08 why Comlink.wrap() instead of wrap()?
@dassurma
@dassurma 5 жыл бұрын
Mostly cause I'm bad at copy/pasting 🙄
@arodic
@arodic 5 жыл бұрын
Cool research! Have you considered putting entire game state into WebGL buffer? Theoretically, this entire game could be run on the GPU using a few simple shader programs.
@forceboxed
@forceboxed 5 жыл бұрын
Whoa!
@LuLeBe
@LuLeBe 2 жыл бұрын
For a minesweeper clone, even the current method seems way overengineered. You're taking it to the next level :D
@PabloNevares
@PabloNevares 5 жыл бұрын
Since the idea of a RAIL budget isn't well-known and the captions weren't sure if it was heard correctly at 12:49, here's further reading for anyone interested: developers.google.com/web/fundamentals/performance/rail
@shifteleven
@shifteleven 5 жыл бұрын
Hey. I read that blog post and I liked it. It had me doing one of those Todo apps where Redux was in a Worker - simple and overkill, but still interesting.
@dassurma
@dassurma 5 жыл бұрын
I don’t know if you saw, but that’s legit what I did as well :D dassur.ma/things/react-redux-comlink/
@DrRobrez
@DrRobrez 5 жыл бұрын
Neat, thanks for sharing your research
@MaxArt2501
@MaxArt2501 5 жыл бұрын
Now, which one of you decided it was a good idea to switch to flag mode with a double tap in Proxx? It always gets in the way of me breaking the 2 minute limit in hard mode!
@MaxArt2501
@MaxArt2501 5 жыл бұрын
Sorry, reading this comment again it sounds way more aggressive than I thought! Actually it's just a minor annoyance, and I'm actually enjoying Proxx a lot (also I've had a minesweeper addiction in the past but that's another story). I think it's a great project with a lot of interesting techniques used under the hood. About the double tap, maybe I'll open a PR about it 👋
@swantzter
@swantzter 5 жыл бұрын
Also Yay, finally a new podcast episode!!
@nir8924
@nir8924 5 жыл бұрын
17:17 what about using shorter key names ? Won't it make the serialized payload small enough ? (I mean, yes, it's very specific to the example, but still something to consider right )
@dassurma
@dassurma 5 жыл бұрын
Yeah, that would have been one optimization, but it felt more like a band-aid fix rather than properly decoupling performance from payload size.
@nir8924
@nir8924 5 жыл бұрын
​@@dassurma yeah I think I get what you're saying. it's an optimization, not a solution. in a large app with many models it'll become a burden. thanks for the video, it was very informative! 47 FTW :)
@RichardGustin
@RichardGustin 4 жыл бұрын
What about SharedArrayBuffer? it does not carry the expensive structured clone hit, since it is available in both/any/all web/service workers and the main process....
@stepans2167
@stepans2167 3 жыл бұрын
You'd have to serialize/deserialize the object to put it there anyway
@NanobyteOnline
@NanobyteOnline 5 жыл бұрын
hahaha, i didnt notice he said 74ms instead of 47ms, im german xD
@Surefire99
@Surefire99 3 жыл бұрын
I know it's not really in the spirit of this video, but I'm curious if for Proxx you considered not saving the state of the game, but rather the initial configuration plus all the actions taken? Which you could use to recreate the current state by running all the game logic as fast as possible (sans animation). I believe you would achieve really great game play performance since every action only sends data on which cell and which action was taken. Maybe you wouldn't even need a worker at that point. The trade off would be slower resume times, but as a user I'd find that acceptable because I'd expect the game play to be smooth, but the resume to take some time because that will either happen very infrequently or never. I believe this is somewhat similar to how Google Docs manages collaborative edits.
@LuLeBe
@LuLeBe 2 жыл бұрын
I don't think they need a worker right now either. They use it because it's a demo app for modern web tech.
@LuLeBe
@LuLeBe 2 жыл бұрын
I wonder why you use workers in prox. I mean you probably did because it's a demo app and you wanted to show it, but is managing the game state on the main thread really such an issue? If it is, you could use your 10 changes per frame animation trick as well, and surely you'd be fine. Only issue is scrolling the game field anyways. Everything else doesn't happen before the state is updated: User clicks -> state update (either on worker or UI thread) -> new state renders -> User clicks again etc. The only thing that a blocked UI thread would inhibit would be scrolling while the state update is calculated.
@FireNeslo
@FireNeslo 5 жыл бұрын
I still prefer using workers for more long running code, then just spit out some result at the end. I do like the idea of being able to parallelize more though. Most of the time its more work in the ui update code than the state update code, so its mostly that code that would be nice to get out. with virtual dom you can achive that but I need a vdom with support to do serialized hooks of some sort, so i can do more complex dom effects. Vent listeners are also a bit tricky but using some sor of convetion i could probably do something declarative for transferring the event to the correct controller. Othewise vdom fits nicely with the idea just creating chunks of dom diffs and send them over.
@renancaldas7251
@renancaldas7251 5 жыл бұрын
Awesome talk! I'm currently using postMessage for communicating with Service Workers. Looking forward to use comlink in order to off-load the main thread :)
@AlexanderCerutti
@AlexanderCerutti 2 жыл бұрын
05:06 Little note as of 2022: now we have structuredClone, yay! 🎉
@victornpb
@victornpb 5 жыл бұрын
I'm curious about the queue loop on the worker thread, if instead of sending lots of data, you spam the queue with a ton of small messages.
@dassurma
@dassurma 5 жыл бұрын
What are you curious about specifically ? That definitely works as well :)
@DenisTRUFFAUT
@DenisTRUFFAUT 5 жыл бұрын
Conclusion : If you use lots of animations, especially looping ones, you'd be particularly interested to offload code in the worker. There is no excuse, except for the 10kB message limit, to not offload code in the worker.
@omri9325
@omri9325 5 жыл бұрын
Good conclusion
@perguth
@perguth 4 жыл бұрын
@driziiD
@driziiD 3 жыл бұрын
take-away: read the spec!
@ahmadhosafy
@ahmadhosafy 5 жыл бұрын
Actually Arabic numbers work the same as German ones 😅
@forceboxed
@forceboxed 5 жыл бұрын
Even Hindi numbers kinda work the same way.
@duncan-dean
@duncan-dean 5 жыл бұрын
14th! ;/
@LarsRyeJeppesen
@LarsRyeJeppesen 5 жыл бұрын
Very informative. And yes it's slow.
@dassurma
@dassurma 5 жыл бұрын
So, let me get this straight: You posted your comment to this *20 minute video* about 1 minute after we uploaded it and then say the *exact opposite* of what’s in the video?
@LarsRyeJeppesen
@LarsRyeJeppesen 5 жыл бұрын
@@dassurma Yes lol.. I gave up trying to do it because of the complexity and serialization stuff ;) ,... I'm 7 mins into the video btw so far... :) ... getting interesting /s
@GifCoDigital
@GifCoDigital 5 жыл бұрын
I want to live in a world where semicolons dont exist!!
Weak JavaScript - HTTP 203
29:22
Chrome for Developers
Рет қаралды 25 М.
Scope in JavaScript - HTTP 203
17:21
Chrome for Developers
Рет қаралды 27 М.
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 43 МЛН
Mom had to stand up for the whole family!❤️😍😁
00:39
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 24 МЛН
Kluster Duo #настольныеигры #boardgames #игры #games #настолки #настольные_игры
00:47
Cross-origin fetches - HTTP 203
23:42
Chrome for Developers
Рет қаралды 39 М.
Import maps - HTTP 203
20:16
Chrome for Developers
Рет қаралды 18 М.
Four silly browser hacks - HTTP 203
21:01
Chrome for Developers
Рет қаралды 39 М.
Service Workers - Messaging between Tabs and Service Workers
23:01
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 8 М.
Learn Web Development And ACTUALLY Get A Job | Ultimate Guide
1:33:52
James Cross
Рет қаралды 1,4 МЛН
Top 10 performance pitfalls - HTTP 203
36:31
Chrome for Developers
Рет қаралды 37 М.
Simple Code, High Performance
2:50:14
Molly Rocket
Рет қаралды 256 М.
Loop Tiling - HTTP 203
25:36
Chrome for Developers
Рет қаралды 28 М.
Web animation gotchas - HTTP 203
20:10
Chrome for Developers
Рет қаралды 23 М.
Seja Gentil com os Pequenos Animais 😿
00:20
Los Wagners
Рет қаралды 43 МЛН