 All right, thank you both All right, so hi there welcome to fun with CQ light and was he live see My name is Jesus Gonzalez and I work at was a labs at being where office of the CTO with some other folks over there Let's talk about CQ light. So I assume everyone here really knows about CQ light So I'm gonna highlight just one single aspect It's the most used DV engine worldwide you can find it into your smartphone you can find it into your tablet You also can find it into your browser Or even in some IOT devices appliances and even in your car so That's a notion about how important really is CQ light So we thought that to bring more application into the web assembly ecosystem It would be great to have CQ light bill for was he? All right, so how would you compile CQ light? so if you look at the traditional tool chain You will make use of a C standard library that will allow your source code to You know, I mean some sis call to a POSIX OS And if you want to build it as a web assembly for the browser, you can make use of a toolchain like mscripten And by the way, this is what we use back in July last year to showcase how WordPress Could be run entirely in your browser powered by CQ light and You can also believe for you know as web assembly for the server using a toolchain like was he SDK? it will make use of was he lipsy which is an implementation that will map some of the POSIX syscalls into was equals and for the missing features he will try to Excuse me to emulate them Now if we focus on the letter use case From the developer point of view the workflow is pretty much the same than in the traditional toolchain So if you remember the duck test, you know, like if it looks like a duck swims like a duck And quacks like a duck it will probably probably be a duck, right? It turns out that for was he lives a It looks like POSIX compiles like POSIX, but is definitely not POSIX part of the reason is because of the emulated functions and They assist to work around some of the missing pieces in was he and what assembly? They are API compatible, so you don't need to change the source code and You must Activate them explicitly which by the way, I believe it's a smart decision So let me share now What was our experience with one of those emulated functions while trying to port CQ light into was he? so first of all The implementation of was he live see I mean the end map implementation was he live see Doesn't really pretend to fulfill the POSIX specification One of the limitation is that it won't write back into the file system once I mean once you are done with you You know with you map file into map file into the into the memory But also and more importantly it won't return you aligning memory so this particular limitation, you know gave us a strong headache while porting CQ light because The side effect was that CQ light wasn't able to read some of the databases while it worked with others So that was at the same time, you know hard and fun to do back So let me share a couple of takeaways from our lessons learned while porting CQ light into was he that I do believe It will be useful for other cc plus plus code bases So first of all you really really really want to understand the differences between the two the different tool chains And as an example, you know process identity processes identifiers. They don't have any sense on web assembly So was he live see do you know just returns? Fixed value there and I believe that will work in you know 99.99 percent of the cases But it could be the it could happen that it won't work in others Also remember that was he is not POSIX They have a common core like, you know opening file closing files there are missing pieces as I mentioned before and Fortunately, we are keep standing was he we knew set of features like was in and was a cloud, etc The second main takeaway is that if compiled it doesn't necessarily mean that it will work So here is kind of a few step that I will suggest to follow The first one is you go on directly on the back What is the outcome from was he and was he will see because it probably I mean there are good chains that is not what your software is expecting So if it still doesn't I mean if you find the root cause there You should try To disable that feature that is missing in was he and was he see and that's what we did with Escalade because it was relying on a full and map implementation that wasn't there fortunately for us Disabling and map in circulate was easy because I mean escalate was designed to not use it At the cost of using a less performant Generally method, but it would work And finally if you cannot disable you should really try to patch it That was something that we found not in circulate but in PHP in the P. I mean in the interpreter and As you can imagine you cannot disable the interpreter because it's part of the of the core function So we had to work around and patch it with a different way to get a line of memory With that that's all I have for today. I hope you find it useful Thank you. Thank you for your attention. So you're on Thank you very much for the presentation Jesus. I think we have time for one question before the next one Hey, great presentation. I was wondering if there are any system call functions that you found that you could not patch Sorry, I couldn't hear because of the background noise. Oh, sure I was wondering if there were any functions that you found when you were doing this that you could not patch. Oh Yeah Well, I do believe that Well, let's use a map as an asset the sample so in politics and map is kind of a Swiss knife so depending on the use of that function there is no way to patch it like So for example in the in the sense of the memory if you really want allocated memory that will imply that in the Webassembly module linear memory you will waste a lot of memory Because of the minimum base size that in web assembly 64 kilobytes and in the linear memory, you know in The x86 is just four kilobytes. So the way was he live see is Using that function It needs to provide a header into the linear memory Before the memory that you are mapping actually So I don't see a way an easy way to patch that unless you don't you don't care Wasting a lot of memory in web assembly. I think that's one of the simple I have others that we can catch our fly and tell you. Yeah Thank you for the presentation Jesus, please give a round of applause