 So, I'm Zhonghua and I'm currently studying at the National University of Singapore and I come from China, so my English might not be very good. Sorry and please forgive me if I did not express myself very well and so the basic idea of this talk is, this is my first time coming to any kind of meetup and standing on the stage giving a talk, I may be a little nervous and this talk is about the new features and performance improvements introduced in Goat1.8 and I will try to be a little inclusive but I will not be too specific about certain things. So if you are interested in something, please just stop me and I will see if I can talk more about that. So actually the change log is very long, so I categorize them into four sections, the language, the runtime and standard library and torching and so the first part is about the language. There is only one change made in Goat1.8, it's the conversion rules and it's quite un-euro because we don't have any change in Golang since 1.5 and this change is quite minor so previously when you do conversion from one type to another, these two types have to be strictly the same. Even the difference on the structure text can prevent you from doing that conversion but it's quite unnecessary and so I am happy to see this decision is gone. And there is another proposal about the alias deterioration which is very popular but also very controversial and they actually adopt this change at the moment but soon enough they take it up because there is some grammatical ambiguity for some corner case and the issues are too late to be found out so they cannot catch up with the release of 1.8. The proposal will change the language spec to a different alternative syntax to avoid the issues so it will be from this form to this form. Also we will see if we can happen in 1.9 and the next part is about runtime so basically this part is about those performance improvements and for me it's quite impressive because the GC POS, the most concerning one is notice go down to under 1 millisecond and the compiler is generally 15% faster and differ and see go all faster. So if we are sorry I didn't expect the diagrams to dark maybe it's hard to recognize. So in this chart after a short period of warm up we can see the GC POS of 1.8 is go down to 1, it's stabilized at 1 millisecond, under 1 millisecond but the Goat 1.7 is still fluctuated between 2 and 4. About 2 to 4 millisecond is good enough because in 1.6 it's 40, in 1.5 it's 300, it's significant and the reason that such huge improvement can happen is because the state rescanning is eliminated and they replace it with a new thing called hybrid write barrier which combines a deletion barrier and an insertion barrier but I don't know what these two names mean but anyway it's really fast and something even more exciting is and there is an improved implementation of this write barrier has been merged in the depth range. It will reduce the GC POS to under 100 nanosecond. So standing from 1.8 they make it 10 times faster again so it's unbelievable but there is some side effect because the write barrier did compromise the throughput so yeah this is the trade off we need to take it but we still can, there is a built option which you can re-enable the state rescanning and disable the write barrier so it's still up to you. And what I think is the most important, the write barrier is not just optimizing the runtime but it will tremendously reduce the overall complicity of garbage connection so it will make the further optimization happen and in 1.8 we will have SSA support for the up-platform so SSA stands for the step single assignment it's a very popular technique used by the modern compiler and previously we don't have the SSA because the goal compiler is derived from an old C compiler which is born before the SSA has been invented and in 1.7 we have SSA introduced into the AMD and Intel platforms and now we have it on R. So still we are not just caring about the optimization this time the compiler team can be more focused on a single compiler backend so yeah we have a very promising future I think and personally I like to take one minute to brief a little about SSA because it's just based on a very simple idea so SSA means every variable will just be assigned once so we have in a simplest case we have this code that is not SSA where the compiler will translate into transform it into SSA form by adding a version number that is to identify each generation of this variable and in this case we can see the first line actually is decode because why will be overridden in the second line but so it's hard to recognize that for the compiler and so if it is in SSA form the compiler will just check the ref count of y1 which definitely is zero so it means this is a decode but not it will never be used so so the the ultimate purpose of SSA is to make it more make the code more machine readable not human readable and based on that we have some advanced benefits listed here and yeah that's all about SSA and this is some case that's how the compiler are improved in terms of this compile speed so for the juju for the Kubernetes controller manager and go git we see the time the time compare time is a 15 it's it's about 15% faster but if comparing to 1.4 it's still be fine it's because in 1.5 the compiler team turn to use the translate the old C code C coded compiler to go code compiler and to make go can bootstrap itself and this is also for the further optimization so it the the the compile time for a lot in a short term but in the long term it's I guess it will pay off and catch up and faster defer I don't know I think I have nothing to talk about about defer and and see go but just beware they are really faster and the next part is about the standard library and for me it's really a feature feature for a lot change so the first one I like to introduce is about HP graceful shutdown and actually it's a shame because we there is a four year old ticket about having graceful shutdown but they just I don't know why but they just keep denying it but anyway we have it but previously you still can have a graceful shutdown if you use third-party library and the I guess meet if there is a reason to have it have graceful shutdown so late it might be the the maybe they want to have contacts in prior to the graceful shutdown I this what I this is my guess so in this example we should always see that we can subscribe a keyboard signal and waiting for waiting for the channel and if it came we will shut down the we will graceful shutdown gracefully shut down the web server and and there is a timeout version so I think it's they are going to fit most of situations and next is HTTP 2 server push I think HTTP 2 is something really really important I but I wonder how many of us have no HTTP 2 or use it in your production environment how many whoa whoa to I also want to take one minute to brief a little about HTTP 2 so in a word HTTP 2 is a binary and multiplexed protocol so binary means it will save more bandwidth it's not text-based and multiplexed is because they reduce the the granularity of transmission into a new word called a new terminology called a frame so I will introduce more about that with this code example so so within one socket connection we can have multiple stream in transmission in parallel and without blocking otherwise that's really helpful and so in this code example we have we have three streams the first one is the indexed html file and it have a have references to the CSS file and the image file and so usually what we are how we call the the the the server parties just I call the the handler and the highlight part is this is actually what we need to do for HTTP 2 server push so we will there is a new edit interface called html.pusher and it has one function in push so we will try to convert the the response writer to the pusher and if it is converted it means the HTTP 2 server push is enabled and then we will call the push function for these two streams and the the HTTP 2 server will send two frames there are the they are push promise frames to the clients so the clients will not try to create a new connection to request these two files this is to proactively promise i will send these two files and then we we said the headers and the the content for indexed html file and the the server will send them in two frames so the header becomes a frame in html 2 and the content become another frame and and and here we have a we have a specified handler for the for all files under the static directory so this is the right handler for these two streams and the the server will the server will pick up the the the right handler and do all the rest of things so you don't need to worry about how to encode the html 2 stream the server will do all the rest so the extra part in html 2 is just that long and that's straightforward last but not least don't forget to turn down a tls because html 2 is based on tls and the next thing is about tls yeah yes it's it's a little mouthful but anyway this the this suite is uh the the charm of this suite is uh because it can be uh very uh it can be uh computed on various cpu's uh it's very fast for the mobile device so google start to use this uh cypher suite arranging it and uh then we will have it in go it's uh it's yeah and uh we we and there's some uh we will have a more um we have the the the function stack um easier to use because the the the the runtime will automatically select select a cypher suite for you if you haven't given one uh based on the hardware and the the configuration callback functions are also very flexible this time so yeah you may if you are really if you really want to work on html 2 you may check it out and the next part is about sql additions and uh i will not try to be so in depth like uh our first talker but uh there there there's something new to mention in in 1.8 about sql so firstly we will have contacts so we will have cancellation and next we will have uh uh i have on a short list the the spec the uh we will have an interface so the the database can respond the the type of the type and its name and we will have multiple result sets support so by calling this section you can move on to the next result set and uh i i guess most of language have this in their standard library i think and uh and pain pain can any server uh actually in 1.7 if you first time calling the if it is first time calling pain function it will reach out to to the database server but if it is second time it will not because it will pick up from the pick up existing connection from the pool and uh and the decline is too lazy to check the connectivity again so it will just simply reply uh true but actually it might be false so this is more like a bug fix and we will have named the parameters so it will be easier to manipulate the the sql and we will have a transaction isolation support so yeah it may be useful sometimes and next we will have uh the inline slice sorting so i i guess most of us will think the coding uh sorting function is quite painful for a piped slice because we have to uh we have to define an order type and we have to implement each and every functions uh learn swap less especially for the first two they are this they are really redundant and unnecessary but in 1.8 we will have a simple we will have a helper function called salt dot slice we just pass it the items you want to sort and uh and the inline function can have a closure to to a close reference to to the items so that's much easier but there is a performance cost because the the reflect is involved and generally the the the the the old salt function is about one one-third faster than the new slice function but uh whether you go with speed or convenience it's up to you it's uh it's very good to have a have more choice and next it's about context we have context introduced previously and but but it's about you know in a form of a long import pass and uh and this time we we can't have it uh in a short pass and uh and also uh there is a uh command tool provided to help you fix the the pass so basically you round this command on your code base uh see there is a diff flag here we'll try to show the the currencies of the long pass and the second line without the diff flag well but overwrite I thought context got in in 1.7 only 1.7 maybe it's we regrettably have it for hdb yes yes yes yes yeah and the next part is about toolchain and the first thing about toolchain is the we have a new build mode called plug-in so we can build a very shared library like a binary and so still I give a simplest example code so here we define a variable called v we define a variable a function called f that says to print out the value of v and we period uh in the the the plug-in mode and we will have a we will have a so file and we load it up and retrieve the the variable and the function and assign to the to the variable and we call the function it will uh it it will print out the the value we assign in a different project does already sorry does this work in windows with what windows plug-in dot drl uh actually it only works for uh only works for unix it's not even working for for mech oh sorry I should I should uh and uh have a note about that sorry yeah yeah and the next thing is about the default go pass so uh if uh if we uh if we haven't defined a go pass in our uh environment variables the the go pass will default to the home directory slash go so I think this is quite uh sensible it's to adhere to the the principle of least astonishment I really I think okay okay so we will have a new uh command tool called go bug don't laugh it's it's it's useful don't laugh because this is like most uh this is the easiest way to find a new bug and when you run go bug on your operating system it will open it will open the browser uh open the the bug report uh web page and uh we generate template and uh with all the system details prefilled like the the the flags and the operating system the the the variables something like that and next we will have a we have a we will have a go that and go that is going to be uh smarter uh I want how many of us previously used go that okay good good really good okay so go back is to examine the source code statically but sometimes you can find some errors that that cannot be captured by the compiler so I show you an example here so anyone can tell uh what is wrong in this code anyone yeah yes yes that's correct yes that's correct oh yes yeah yeah it's it's yes so make sure have differ after the the the the near check of the error so otherwise if if if if the error is not near and the resource if we try to close the resource it will gone crash so previously the the go wet is not smarter enough to find this error but this time it can so I I strongly recommend of us to have a go wet included in your uh CI scripts okay so that's almost all about uh go on uh 1.8 and uh I I really appreciate you uh stay to the last minute of this talk and uh actually I want to take maybe extra 10 seconds to advertise myself I uh I come from China and I this is my first year in Singapore and uh actually I I got some available time so if you uh happen to uh look for uh freelancer or our interstudent or anything I can help please contact me uh at this email address and uh sorry is it hard okay so I have uploaded this uh slides to the to the slide share so just you can find it by by uh search what's new oh sorry okay okay I will okay definitely so so thank you very much I actually have a question ah please sorry sorry I'm sorry I have a I have a story to tell I I recently read a blog post about uh a machine learning platform they're trying to do the optimization for their for their system because they have hundreds of millions of record and the the the GCPo seems to be the bottleneck and they they try many ways to to take the program or to to adjust the the variables and they barely make it uh three times faster in terms of the GCPo it's it's uh it's good enough but when they but when they try to build uh their system with go 1.8 beta immediately it's 10 times faster uh sorry uh previously they are using go 1.6 so I I'm not trying to sugarcoat 1.8 but but I I I really like to suggest if you want if you have a plan for optimization maybe the first step is to upgrade the the version okay okay that's all sorry destroy the server okay so thank you