 Here is Lenske-Schwente, here is Sam Villain, we are open parallel and then we will talk a little bit of Intel's 3D building blocks into Facebook's hip hop, these are our names and essentially this talk will discuss what are we aiming to do as a startup, as a business, so we have a model at the same time why we are working in this area, multi-core and parallel computing and which are the huge opportunities that we soar around, that we didn't just walk up one day and say oh let's do a project with TVB into hip hop because it's 30 degrees Celsius, so it's a process that we had from some time and the most interesting part of what are we aiming a part of telling you about the project, it's to inviting you to join us building more about the specific project or other projects that we have in the pipeline, so thank you very much for coming, welcome, we have these are a couple of white papers that we are, you can download it from the website, but we have it in hard copies here too, I already distributed a few of them and you can pick them from a chair that are on the on the door, so again welcome everyone and hello to everyone who is watching on the streaming, hello mom, so Hola Esteban, that was real, that's my son, okay, so a little bit of intro about what is this multi-core, I mean in all the years that have been around in this environment, just to call it something, you find three kind of people, the ones that have absolutely no idea about what is this, but just read one or two words, then the ones that are a little bit aware and are going through it and then the ones that have been playing with this for the last 40 years or more, so we will give a little bit of context about what's the process that brought us here and then go straight to the specific presentation which is all in the white papers and hopefully we will have an open conversation with all of you about what we can do together and what we are aiming to do ourselves too, so what's the problem, the generic big problem that's happening in multi-core and why are we talking about this, well it's simple, things change, things constantly change, I mean you build something once and then you expect that that stuff will last forever, I was planning to do a little bit of quiz that if you are able to tell me where is this, I will give you something, but okay, so okay we know that certain things don't last forever, now which are the options about this sort of things, you can simply choose to okay, I don't care, I ignore, I put my head in the sand, it's an option, some people just have fun ignoring that, okay good luck, others will say okay I have this problem but if someone from the more slow, someone will help me, so I will just sit and wait for help, the standard help that I need could come, I don't know, from everywhere, so you can wait for help, not sure if good news or bad news, not sure if that help will come, so you can go and discuss in a committee or have a board meeting or round table and raise your hands how many times you have been sitting in a board meeting like this and you choose who you can feel, so probably the only one who is hating this photo is my daughter sitting there, now where is this, I will tell you later, so providing that the solution of this multi-core problem is not simple is better to aim high, as high as you can in this earth, so aim high, you know where is this, so and if you're aiming high let's think about creative things and to be honest things can in any shape from anywhere and that's one part of the message that we need to expect solutions of any kind from anyone and in this time I heard a lot of people I did this in 84, I did this in 77, look at these guys, maybe they have solutions because parallelism is out there, it's normal, it's intuitive, it's anywhere, so it's even there, this is the 101 in the Bay Area, so we come from the New Zealand, the South Island of the New Zealand we have one lane bridges which means that if someone doesn't stop then the other we have problems, so parallelism should solve a lot of problems, but parallelism has some problems too, you need to take care with it because you have problems in the same 101, so you learn it here, if you don't take care you have problems and as happened, where is this, Wanaka, so before you go for help somewhere else, before you go asking for people that you think that they have the right options or even big money which could be in this address, is anyone been there, okay, so just for you, I'm sorry not sure, whoops all these names are not dentists, our venture capital is Equalia, it's the one that's here everyone, so my message is that this multi-core and parallel problem won't solve if we do not join forces, so this is not a proprietary solution that will solve or just one community, there are different options and these options can be good for anyone, where is this, okay, so for the other class of people who already has certain awareness, I recommend a couple of papers that are freely available, if you just browse for this title from David Petterson, it's reasonable download and you don't even need to pay for it, but what I love is the synthesis of the problem and I'm glad that I can introduce myself by definition, I'm an entrepreneur, I've been on many areas in the industry, my first venture was a mathematics academy, I had a dot-com, at certain stage I even have a venture capital firm, but the point is that as an entrepreneur there's a gap in the market, there is a problem, it's not only a technical problem, there is not only a call, it's a business opportunity, so this paper gives some hints on many directions and even a more technical paper, maybe some of you already heard about these guys, these are classic hits, so this paper tells about a number of solutions that have been already there for a few decades, so this is what I call my introduction about the problem, so let me tell you a little bit about who are we, we are just a startup, but we are formally incorporated, which means that we pay taxes, and I use the word ecosystem just to talk about all the friends that surround us, which are in the industry, which are in academia, which are in the community, which are developers, which are in the investment area, so because you don't have a simple single market that you need to point to, you play with different friends, and we started some time ago, that was a company that we started around Niagara, the NETRA division, the NETRA data plane system, and we did a lot of things with Sun Microsystems, and the Otago University in Dunedin, where LCA was in 2006, becomes thanks to our, and there was the first open-spark center of excellence outside the United States, so the chancellor was very happy that you had a banner of Otago University with stamp for Carnegie Mellon, but it's not a huge merit, it's just very few people doing this. We went to Santa Clara, we moved to Gorex for a couple of times, so those were the days, and we even were invited from time to time to go to the NBA because you know, so, and there is a subtle basketball place there, the funny thing is that this guy was a director of Major Architecture Division of Sun, so the rest of history, so when a big ship imploders, the small ones, are a little bit solid or just imploded with them, so later we used that expertise with some help of New Zealand government, another project was a good opportunity to create more awareness about what are we aiming to do around Multicorps with the community in New Zealand and Australia, and in the last, in this couple of LCA's, we are organizing this mini-con, which is a very, very good way to be in touch with this community, so I wanted just to do this intro about, as I say before, we didn't wake up a week ago and decided let's do something on TBV and hip hop, but if we have time after Lens Talk, maybe we can discuss openly, so I will pass to Lens and he will give the story about what is, what are we talking about, thank you. So, we heard a lot about parallel programming and I want to take you to something entirely different for a while and then we come back, hip hop is a project that started out of Facebook because of the need that they had a couple servers, probably a couple hundred, maybe a couple of thousand, that ran PHP and tried to render Facebook.com and they had some issues with page loading times and page rendering times and all those kind of things and they are probably the largest caching farm worldwide in the moment but they really, really tried to get the page rendering time down so what they tried to do is they looked around the market a bit and saw that there are a couple of guys actually doing PHP to C++ compiling and looked into that a bit further and took a couple of those ideas and took a couple of other ideas and came up with this thing that compiles a subset of PHP down to C++ and that thing is called hip hop, very hard to Google as I heard earlier, try hip hop PHP that probably gives you more hints. So hip hop is really a PHP to C++ compiler that takes your PHP code, spits out C++ that you can then compile with GCC and run. The thing that is a bit different about hip hop is that you can't just take your PHP code one and drop it onto the hip hop engine and hope that it compiles. They've skipped a couple of core language features just to make it easier for them to come up with a compiler that is performant enough and has not this amount of side effects or things that are really, really hard to implement in C++ because the concepts are simply not there and they're stuck with PHP 5.2 and didn't really make the transition to 5.2.3 yet, but the subset that is there compiles really, really nicely, it's just important to know that it is not a drop-in replacement that you can just take it, throw in and expect that everything works. So why is hip hop interesting or why should we bother? The amount of resource consumption that you can save by compiling your code down, your normal PHP code down to C++ depends on the region you're applying it to. Obviously, there is code that compiles better down to C++ and optimizes better than others, but it's around the area of 50 to 70% resources that you can save. Facebook got rid of a lot of servers, or not rid, but could use a lot of servers for other things suddenly because they started to use hip hop more and more. What that means also is obviously less power consumption, less administrative overhead, and all those kind of things. If you're running a larger shop power consumption and things like that, there's suddenly a problem. If you run one server, yeah, probably the benefits are another aspect. So the performance aspect is one of the big aspects. Another aspect that we were more interested in is suddenly threading starts to work because hip hop can do threading, whereas PHP's threading support not really. So we tried to come up with some way of playing with hip hop and trying to get familiar with hip hop and one of the popular projects that you often pick is WordPress because it's readily available. It's widely used. So we started taking WordPress and apply a couple of patches and see if we can compile it on hip hop. And we were not the only ones, there were a couple of other ones. And in the meantime, there is a really, really well maintained patch set for WordPress. And there is even, not all of the patches, but a lot of the patches went into upstream. So WordPress more or less runs out of the box on hip hop in the meantime. So WordPress is really, really interested in getting full hip hop support for it. So they're actually constraining themselves to a subset of the functionality in PHP just to get it running on hip hop out of the box. An interesting thing is hip hop has two components, either you compile it down statically and run it as a binary, or there is a just-in-time compiler called HP HPI. And for development, especially HP HPI, it's really, really nice because you don't have to compile, see where it breaks, go back, fix your code. It's a very, very iterative way of, well the PHP way really to develop and it makes it way faster to just test out stuff. Our patch set is on GitHub as well as other patch sets that are on GitHub for WordPress. And if you're searching around, either in our repository or just on WordPress, for WordPress on GitHub, there are a couple of folks of the same core patch set that kind of went for them. We try to measure what hip hop can give us in terms of running it on a standard Apache setup and then running it on hip hop. And the standard LAMP stack that we used was just a virtual machine running in virtual box on a standard laptop with two cores in it. And we just try to push it as fast or as hard as we could. We used Zhong as the stress testing tool. Zhong is really, really cool if you want to do some sort of slash dot effect things or dig attack things where you have a load that is slowly building up and then a peak and then a load that is abbing out again so it can really flood web server very, very nicely. And not only with kind of hitting it and hoping that you get a response, but with really defining a path through the website that a user would actually take. So if you're doing stress testing on your website, Zhong is really cool. Written in Ulang, other passion of mine. So we set up a Zhong task that had about 250 users stressing the system from one user arriving at a second to every quarter of a second a new user arriving and so on. So it really built up a load very fast and then kind of maintained it and hold it for a couple of minutes. And we thought like 250 users is probably a fair amount of users. We can probably push it that far and sure enough we pushed it against our OVMs and they just swapped to death and nothing really happened anymore and we pushed it a bit too far. So our expectations of how far we can push the chest really out of the box. It was not optimized. It was out of the box lamp stack. Yeah, broke it horribly. We tested it with lower numbers but that was that was kind of the interesting number for the next experiments then. So we had actually obviously working tests as well. But yeah, the hip hop stack outperformed the lamp stack in that respect that it was still responsive. It didn't crash. It went through and we actually got results which were the graphs we are showing in the white paper as well. This is roughly how it looks like if you run a dig attack against a virtual machine that runs HPHPs or the hip hop engine, really the compiled version. But we also really only measured the page rendering so the task that we set up didn't request all the static files like CSS, images, all those kind of things. So we really only focused around testing the performance of the PHP engine itself. Slight digression. TBB, we've been talking a lot about parallel programming before and TBB is a library that aims to make parallel programming really really straightforward. We all know it isn't but at least it makes it a bit more a bit easier to deal with memory management, with locking, with programming towards more than one CPU with a couple of constructs that you can use. It's an Intel library. It's open source and it's not only running on Intel hardware so it is written in a way that you can actually define different back ends for different processing architectures. So it is written in a modular way and it supports all major architectures in the moment. I think they're still working on the ARM port but all other major architectures should be working in a moment. So our idea was to put TBB into hip-hop or extend the TBB functionality in hip-hop because it offers those wonderful constructs for parallel programming and it was already used in hip-hop for memory management and to get the threading synchronization right already. So our first kind of aim was to look which commands we could pick out of TBB to improve the performance of the parallel performance of hip-hop and ultimately of WordPress. And we picked parallel four for a quite straightforward way to map for loops in PHP onto something that runs on several threats on several CPUs in the real machine. And it turned out it's not been that hard to implement new language constructs into the hip-hop engine. It is not that hard to extend the language set that hip-hop understands and therefore the PHP language that hip-hop can compile. So that first thing, getting TBB into getting this parallel four TBB construct into hip-hop was actually pretty straightforward. And the next thing was a bit more work to get this parallel four construct into the TBB source so we hacked a couple of four loops that had no side effects that could be parallelized. And here I ran a bit into problems with the fact that we can only use PHP 5.2 so we couldn't use a couple of the PHP 5.3 features that we would have loved. But all in all it turned out to be a workable thing. Then we got patched WordPress compiled with our new language constructs and with our new four loops. And it turns out it was worth the effort. We did a lot of testing and we stressed it from different angles. But we found that we got about between 100 and 200 megabytes of less memory consumption roughly. We got the whole test suite running in in considerably less time. I think it was in the end around between the normal run was about seven minutes and our optimized one was about five or six minutes on average. So we really got a considerable speed up. We got a definitely better result in the pages served in parallel. We had on the unoptimized version about six pages served in parallel on the optimized version we went up to seven. So there was a considerable difference between the normal standard hip hop version and our hip hop version with the parallel full construct. This is how the graphs look like. The thing we kind of found out in that whole process was that TBB is really easy to use for writing parallel stuff, whatever it is. It makes it really, really easy for for CNC++ programmers to actually get stuff done on multiple CPUs in a multi-threaded environment. And it was a really, really good fit for hip hop. It was in there already for memory management so we really only had to extend it in terms of hooking our custom commands in it. And the speed up we got out of it compared to the standard PHP running on a lamp stack to hip hop and then to our optimized version of hip hop was a really, really big gap. And if you look at that for deploying a larger setup where things like power consumption, things like resource consumption in terms of having 50 servers or having 100 servers makes a real difference, I think hip hop is a really strong contender to jump in there and kind of get those resources down. And the other thing we found out is that hip hop is a very, very interesting framework that can be hacked in various ways and can really be adopted to the needs that your specific application has. So it doesn't fit everything, obviously. There is corner cases where hip hop really just scales minorly better than the standard PHP stack. But for a lot of purposes, hip hop can definitely speed things up and can be hacked in ways that it even speeds it more up for the code base you have. So I'm roughly ready for questions, roughly ready for... No, but there is, maybe you can clarify that some people believe that hip hop for it's just for size of the size of Facebook. But we are for example working on how we can whatever site, well not whatever site, but a slow PHP slide can be optimized. That's something. I mean everyone, you can run hip hop on your own server, but probably it makes more sense on larger sites, but it doesn't have to be Facebook size. It makes sense for smaller applications as well. A lot of packages like WordPress are pretty useless without their plugin architectures. How does that fit in with using WordPress and then are you still able to use WordPress plugins and that sort of thing? Or is that kind of pick and choose beforehand and then... There are actually, well obviously code that is not compiling on hip hop can't be used, but there are already quite some plugins that work with hip hop and more and more as WordPress especially pushes more and more towards compatibility towards the hip hop engine, I hope at least a lot of plugin developers pushing to that direction as well. I know that WordPress itself is really really interested in hip hop and they're definitely from the feedback we've seen, they're definitely moving into that direction. So I guess the plugin developers simply either have to catch up or go stale on this platform at least. Hi there. The parallel four extensions that you made, do you know if anyone outside of your company is using them or whether like Facebook for example are using them at all? We have published them on GitHub. I don't know if anyone's using them in production, but I know that a couple of guys have played around with them and looked into how we've done them. We obviously fed back our findings and things we did to Facebook and they looked into TBB in more detail. So I'm not sure how much of the work that we've done is really going back into hip hop, but we definitely saw some interest in the stuff we've done. Okay, so the follow-up question to that is if you're not really seeing it going back in, what is Facebook's attitude towards these sort of community contributions? Are they merging them back into hip hop themselves and then using them or this is just sort of like a bit of fragmentation that's happening all throughout the hip hop community? They take in community contributions and they I think they're really interested in growing a community around hip hop. How much of that really always goes back straight in and if it is not really touching one of their problems I'm not sure, but they are quite happy for community contributions that fix problems. You see the sorry the mailing list, you see a lot of activity on the Facebook developers about the contribution that's going back. So it's the guys who presented Facebook, sorry hip hop, less than a year ago, you just follow them and they are every week they are constantly coming and they are presenting all over the world. So it's a really active, you can see even for their commercial interest. So it's not only for the good of the community, I mean I don't know how big is Facebook in terms of service I guess that it's really big. Therefore they have a purely commercial interest also. Why not compile straight to machine language? You've got a Pazzer I assume, you've got all of the GCC back-end stuff, why the intermediate C++? It gives you a couple of advantages. If things go wrong in the compiler you still have a reasonable chance to actually read the source and can actually tweak the source if you have to and you can compile it to different architectures. So you're not, if you're really going straight to assembly, you're restricted to the architecture you're designing for and if you change that architecture you're throw away your Pazzer. Okay thanks, yeah GCC does have that system for making languages inside it. Of course the project was started by Facebook so it's kind of their architectural decision to sort of take the simpler path of well they can understand changing PHP to C++ and that sort of that means that they don't sort of have to get involved in the compiler internals that have much time it would save them and how much faster it would be. Yeah that's just the way they started the project so we'll work with that. Just a question, is there any Facebook developer here? Once you've hacked your WordPress PHP code to use Parallel 4 can you execute it back on LAMP and what effect does that have? Not in a moment. We've been looking into feeding back a couple of those language constructs into standard PHP but we're still working on that one and I'm not sure when we'll get there. The problem with that is that core PHP threading is not really where it could be. I know Sam would probably know more about it but the problem is really that threading core PHP including all the libraries that hang off it is really a mission and it is relatively thread safe ish but not quite there that you can just take tbb hook it into it and and and run it. So fundamentally if you want to start using hip-hop you're not writing PHP anymore? No if you run on a standard hip-hop machine engine everything is fine. If you run on our hacked engine you have additional syntactic sugar to express different things and if you want to make a portable patch set out of it you basically have some fdev equivalent that says if I run on hip-hop I have I can run a full loop like this otherwise I have to run a full loop like this. We have plenty more time folks we're 10 minutes ahead of schedule. Blogging doesn't seem like an inherently parallel problem so how could you get much of a speed up from parallelizing WordPress? Logging. So before these extensions you weren't able to serve more than one request at a time was it is that the bottom line? How do you mean? You have obviously more requests more than one request at a time if you have a busy web server you have thousands of requests. Yeah exactly. And the logging how the logging works then in parallel or you can? Blogging. So it's log. Ah blogging. Ah sorry. I'm still struggling a bit the the thing you have is something that runs in parallel you push you use one thread for the thing that you're executing and another thread is working in parallel on I don't know loading your modules to render your page and then there's another thread that loads another module for your page or another plugin for your page. So one of the one of the four loops that we optimized early on was loading all the plugins that render your site and this can absolutely be done in parallel because there are no side effects you only have to load all the code and then you end up with the code memory. So that alone sped up the page rendering considerably because it's normally a sequential thing where you go through and through and through and through. So you're still rendering one page it's just happening in parallel. Any comments on the prospect for Niagara under the new ownership? The only comment that I can mention it's what I see on the back page of business week that advertising of Oracle about how good they are against IBM but no we just had a nice relation at the time which opened a lot of doors you know I mean you organize a mini conference for Paul McKinney or these guys just because you are creating a nice brother who out there so that was the original part but that won't happen that's why I put the board meeting and won't happen when you have stones. So things are happening in a very isolated place I mean isolated. This is a change that in one way time it's on our side it's one we won't leave this room and say suddenly oh wow I need to change my religion I need to forget all what I knew it's a process so and yeah. So deployment wise how different is deploying a hip-hop instance of WordPress to just doing it on normal PHP? Like obviously things like Apache rewrites and whatnot aren't going to work just the same. Yeah does it work again? Yeah probably that's easy. The deployment process is obviously different hip-hop is has built-in web server thing that serves the binary basically so you don't have to it's a bit like I think it is a fast CGI protocol actually. No it's straight HTTP sorry it's just what we've done is we hooked it directly behind nginx and just ran it behind nginx as we would any other non-php thing. That's more my world and with that the running of the website is really restricted to run on that engine and all the statics for example were in our example served directly by nginx and not by hip-hop. There is some support for pushing static stuff but it is I wouldn't see any benefit in doing it. The other thing that you have to think about in terms of deployment is obviously that you're actually deploying a binary now you're not just deploying source codes. You can deploy source code if you run HP HPI the trust-in-time compiler which is still a speedup. We still got a speedup out of just running HP HPI but if you're compiling you actually have to think about if you're compiling in a big scale you have to think about build farms you have to think about how do you actually deploy the binaries to the different boxes if you have different architectures you have to compile for different architectures things like that so that becomes slightly more complex if you go into a larger scale but on a smaller scale to tinker around play with HP HPI just throw your sources at it and if that becomes stable compile it and push your compiles to the amount of nodes you have. How long are you talking in terms of compile times like you were saying it takes a while and you need a build farm how long does it take to compile WordPress for example? The compiling, compiling hip-hop itself takes forever. You don't want to recompile it often it really takes forever but compiling the website depends on how big it is. I don't know if I have any numbers on how long it really took to compile but it was in the amount of minutes it wasn't like days. So it is not huge it is just if you have 20 servers out there you don't want to compile it on each server you really want to compile it on one server and then push it out to the 20 as a binary. With Parallel 4 did you do much in the way of adding synchronization to other stuff so can Parallel 4 jobs say atomically echo stuff and it's not going to interfere with each other or are you just not echoing in Parallel 4 jobs? We are in the moment not echoing in Parallel 4 jobs. But you can it is simply threats that run in Parallel. We didn't have any outputs of those things it was really all things that were side effect free that didn't really have any output that only returned stuff that wasn't necessary for the next cycle of the of the for loop and this is how we could run that in Parallel. No other questions? When you translated it to C++ did you see that process introduce any bugs? We haven't found any so it seems relatively stable but also we've only really used hip hop and a couple of small test things that we made up so we haven't compiled a huge amount of PHP sources and just looked how well it performs but the hip hop guys are pretty onto it to make it bug free. Facebook's pretty big too. Yes that code base alone probably pushed it pretty far already. Well thank you very much that's been very informative I very much apologize for my complete ignorance of the topic and we've enjoyed the talk so thank you. Thanks.