So for today's class, we are still now working further up the stack in the database system. And now we're going to talk about how we do query execution and scheduling. So there's all this sort of background information we have to get to before we can understand why the hyper guys did what they did or why they chose that particular type of architecture. So I want to start off talking about different process models for in our database system and we'll talk about how to do query parallelization, what different types of query parallelization you can have. We'll also talk about data placement, non-uniform memory access models and other things like that. Then we'll finally get talked about scheduling and then we'll finish up with a quick overview of a outline of rules you should follow when you're in the streets and when you're doing databases. And we'll be following a 1997 list of sort of edicts called the 10 crack commandments. We'll go through that and we're just going to see how that relates to databases in your life again. When you leave CMU, these are some of these life skills you need to have to survive. Okay, so pretty much for this entire semester or the entire semester, we're talking about a certain kind of database that's called a multi-user database system. And this differs from an embedded database system, something like SQLite or RocksDB or LevelDB. Because in those systems, you assume that there's only one user accessing the database at a time. That user may want to run multiple transactions but you're really only trying to interact with sort of one outside entity. So now in a multi-user architecture, in order to make sure we use the same terminology in our discussion for this lecture, I want to go through what at a high level, what I mean when I say multi-user database application stack. So the term I'm going to use is that we have a client and the client interacts with the database server. So the client is actually not actually a client like an end user on their iPhone or doing something. This is like your application server running PHP, Node.js, Tomcat or whatever it is. And it's making requests either in SQL or PL SQL over JDBC or ODBC or some other wire protocol to invoke queries on the actual database system itself. And then we differentiate the client between the end users because the end users are sort of one hop removed. And these are the things that are going to be making invocations to the application server or the client, which then makes requests to the database server. So typically these end user applications will be written in something like using like a REST API or SOAP API, some kind of XML JSON thing, and you could be sending the request over HTTP. So another way to think about it is this is the front-end application, right? This is the thing that sort of makes a high-level request about what they want the application to do. And then we have the back-end application that takes this request and then converts them or executes the appropriate SQL statements against our database server to do whatever it is the operation that we want to do. So when I say client server as we go along, I really mean this setup. I don't mean this part over here. Some database systems like CouchDB can let you do JSON requests or REST requests directly to the database system, but usually this is how people always implement. There's always an application layer that is talking directly to the database server. Usually you don't let them do that. Okay, so to go further, I want to talk about the terminology we want to use when we talk about query execution and query scheduling in a database system. So we're going to say a query is comprised of a query plan. Like you take a SQL statement and you generate a relational algebra query plan. And that query plan is going to be comprised of operators. And these could be relational operators like the scan, the join, insert, update, delete, things like that, but also sort of these physical operators that allow us to have control flow in our query plan. And we'll see what it looks like in a second. And the key difference is that, the key thing that they understand is that when we have a query plan with a bunch of operators, at a logical level there'll be sort of one scan operator for the one table we want to scan. But at run time, the physical plan could have multiple instances of those operators that correspond to the same functionality being executed in the logical operator but being done in parallel on different segments of the data. So we'll say a single operator can have multiple operator instances when we actually run the query. And then we're going to organize a sequence of operator instances into what are called tasks. And this could be a series of operations that we're going to want to do to compute some portion of the query. And so all our scheduling for the most part is going to be at sort of the task level. That's the encapsulation we want to care about. And the idea is that if there are operator instances that sort of feed into each other one after another, we can combine them together into a single task and get sort of a nicer pipeline of better cache locality because we know that the output of one operator can go directly and be used immediately by the next operator instance. Okay. So now, if we want to support a multi-user application, we want to support multiple transactions, multiple queries running at the same time, we need to talk about what the database system's process model is going to be. The process model is going to define the high-level architecture of how it's going to allow for concurrent operations in the system. And then within this process model, we're going to have this notion of a worker. And I'll use the term worker thread throughout the lecture. It doesn't necessarily have to be a thread, right? It could be a single process itself. But the idea is that this worker is this high-level construct that is responsible for taking the tasks that the query planner will generate in our physical plan and actually executing them and generating some results. And those results can either be fed into another task or they can be fed back to the client itself on the application server. So I'm going to go through the three different process models we can have in our database system. As far as I know, all the database systems are out there. We have to implement one of these three approaches. So the first model is called a process per worker. And the idea is that every single worker is going to execute as its own separate operating system process. So not a thread, but an actual full-fledged process. And so what will happen is when the application sends a request, it will first go to this dispatcher and the dispatcher will say, all right, let me fork off a process that's going to handle this client connection. So it finds a worker, assigns the connection to that process, and now this worker will communicate directly with the application on the client. So when additional requests come in, it doesn't go through the dispatcher, it goes directly to this process. And then the worker knows how to interact with whatever the database is. It could be on disk, it could be on memory, it doesn't matter. So the way we're going to do scheduling in this process model is that we're going to completely rely on the operating system.  We can set priorities, set the nice flag or IO nice for our worker threads, but we don't really have a lot of fine-grained control on how we set priorities in our system. We just let the OS do whatever it wants to do. In order to make this work also when we have multiple processes, is that for shared data structures like a lock table in memory database itself, we have to use shared memory and maintain locks and latches and do all the protections we would normally do in a single process environment, in a multiprocess architecture, because we want to be able to access, we want all our threads, we're using a buffer pool, we want all the processes to be able to share that data and not have complete copies of everything redundantly. So this is the approach that was most used in the systems that came out of the 1890s. In the 1980s and 1990s, because back then, threading support was not what it is now. Now everyone has Linux and there's P-threads and things are great and for the most part, although there's different distributions of Linux, everything's also GNU, everything's all POSIX, so your code is somewhat portable, pretty portable. Back in the 1980s, 1990s, there was all these different variants of Unix, right? There was Solaris, there was HPox264, Minix or whatever, all these other Unix or BSDs, all these other variants of Unix that didn't have the same threading support or the same threading packages. So you could reliably, you could assume that whatever operating system you were running on could support fork and do a multiprocess architecture, but if you had to do threading, then chances are if you wrote it from one operating system, it probably wouldn't work on another one, so you sort of limit your portability. So again, this is why things like DB2, Postgres and Oracle, all these older systems are using this architecture here. Another approach is to use, again, multiprocesses, but instead of sort of forking off one process per client connection, what you can do is have a pool of worker processes so that when a request comes in, the dispatcher just picks some free process in a pool, lets it handle that one task it wants to execute, and that task could be the entire query plan or could be a portion of it, it communicates to the database itself and then sends the result back to the client. And then when the next request comes in, even though it may be for the same connection, it may choose a different process.  You have this pool of resources or pool of processes you can reuse as you need. So the only database system that actually I know that does something like this is IBM DB2, and we'll see in a second, DB2 actually supports all three process models. That's because the system has to be designed to work on not only your sort of Linux and Solaris and your standard Unix variants, but also like crazy mainframe stuff that has architecture that contains a lot of legacy components from the 1960s and 1970s. So they basically let you as the DBA specify which one of these models you want to use based on what kind of hardware you're running on. So the last approach, which is the more modern variant of these three, is to do a single thread per worker. So now we don't have multiprocesses. We have a single process that has a pool of workers. And when any request comes in, we just pick whatever we want in a pool and let it execute. And we can still do, per connection, we can have a thread. We could have multiple threads run for different tasks of the same query. It's really left us to decide how we want to spread things out. So the disadvantage of this is that it requires more work on behalf of the database system developer. So people like us that actually work inside the database system, we basically have to reimplement a lot of the stuff, a lot of the scheduling architecture that the operating system will normally do for us if we're using the process model. But that's better because we can have now more fine-grained control on exactly how we want to organize and schedule tasks in our threads. And so for this, you may or may not have to use a dispatcher thread. So a dispatcher thread would be like a coordinator. It says the request comes in and assign it to a free thread. As the paper you guys read in Hyper, they don't actually use a separate thread. They let all the workers do cooperative scheduling. But in other systems, there could be a thread that organizes things out. So of course, DB2 does this because DB2 does everything. The newer versions of Oracle, I think as of Oracle 12, which came out, what, two years ago, does this kind of threading now. SQL service does this. MySQL does this. And pretty much as far as I know, every single database system that's been come out in the last six, seven, eight years is all going to do multi-threading.  Okay, so as I said, the multi-threading architecture has a distinct advantage over the other guys. One key aspect of this is that when you have a context switch from one thread to the next, it's much more lightweight than a context switch in a process model. Because switching from one thread to the next in the same address base or in the same process, you don't have to switch security contacts. You don't have to swap out program counters or things like that. It's not as big, you have to swap out program counters, but you don't have to swap out as much as you would if you're swapping out threads versus swapping out processes. We don't have to deal with shared memory anymore, which is kind of nice. And in general, this allows us to be more flexible in our architecture. In my opinion, this is a better way to go. I'll note that just because, though, we're doing a one thread per worker, it doesn't mean we're going to be able to do intro query parallelism that we'll talk about in a second. So in the case of MySQL, for example, MySQL is a multi-threaded database system, but when you execute a single query, it's one thread that will execute that entire query. You can't split it off into multiple threads and combine the results as we can in the hyperpaper. And in the case of Postgres, they could do multi-threading within a single process, even though they're using the process model, but they don't. Supposedly, in Postgres 9.6 or 9.5, they're going to have multi-threaded queries, but it's still going to be forking off a single process, and then within that process, you can have multiple threads. They're not going to switch to the threading process model. As I said, I don't know of any database system. You'd be crazy to build something with a process model now when P-threads is so widely available. So the only systems that I know that you could say that they're newer ones that are not doing threading are ones that are based on Postgres. So CitrusDB, the VitezaDB guys, they're predicated on using Postgres as architecture, but they didn't rewrite it in the same way we did in Peloton to make it multi-threaded. Okay. So given that we have now a process model, now we want to think about how we're actually scheduled these tasks for the execute queries. So for each query plan that comes in, usually what happens is you have a... you could assign the connection to a thread and then that thread will do the parsing, the planning, and the optimizations for the query. Or you could have a central thread that do it. It doesn't really matter. But now we have a query plan and now we have to decide where do we want to execute it, when do we want to execute it, and how are we going to execute it. So these are some four general questions that we have to deal with. So we have to figure out how many tasks we should split up our query plan into and how many cores we can use to execute those tasks. It doesn't necessarily have to be a one-to-one matching. If you have ten cores, it doesn't mean you have to use ten tasks. You could use less, you could use more. Then we also have to decide where should we execute these tasks. And this will make a big difference when we talk about the NUMA architecture because the access speed of data, the latency of accessing data at one CPU socket versus another is not always the same. So you want to make sure that if you know data is at this one location, you want to run your query or tasks on the cores that are closer to it. This is the same thing we see in a distributed database system. If you have your data across a bunch of nodes, you want to execute the query on where the data is actually located. You don't want to pull the data to the query. And then the last thing we've got to deal with is where do we actually store the output. So all of this is kind of stuff. You complete a gloss over in the intro course. You say, hey, here's a query plan. Here's your processor. Just plow through it. But now when we actually implement these things, we actually have to care about this. And it's not easy. And in general, I would say that the main for the preset you should keep in mind going forward for the rest of your life is we never want to let the operating system do this. The database system is always going to know better and it can always make better decisions. It's more work for us to implement this logic in the database system architecture itself, because that's okay because we get paid a lot of money to do it, right? And it's sort of like the same thing. And I said, never use M-map. Never let the operating system manage your memory. You want to never let the OS manage your scheduling. All right, so there's two types of parallelism we're going to want to achieve in order to get better performance in our system. So the first is sort of the obvious one that we've talked about before when we talked about concurrency control. We want to have what's called interquery parallelism. The idea here is that we want to improve the overall performance of the database system by allowing multiple queries to execute simultaneously. So we have multiple application threads invoking transaction requests and we get this query request at the same time. We want to be able to have our database system execute those things at the same time, right? And rather than having to wait one after another. And so this is why we use that concurrency control stuff we talked about before is because we're going to allow these queries to execute simultaneously and not mess up each other and still maintain the illusion that they have complete control of the system. They're running in isolation. So I would say that, you know, there's not much more we can talk about today in scheduling for concurrency control because we've already sort of handled that before, right? All the same ideas that we'll talk about, you know, fit just along, you know, just as everything we'll talk about here. I will note that I don't, in my opinion, there's not a significant software engineering difference in the amount of work you're going to have to do to implement a concurrency control scheme in the different process models. So again, Postgres is doing NVCC. It uses shared memory to make that work. I don't think there's anything much more work or less work you'd have to do if you switch to a multi-threaded architecture, right? I think there's no difference in terms of interquery parallelism, but I think there is a difference for introquery parallelism, which is the second time, type of parallelism we want to have. So for this, the idea is that we'll have a single query from one transaction ignoring other queries running at the same time. We're just dealing with this one query. And we want to be able to improve the performance of the system by allowing us to run the tasks that correspond to that query plan for that query to run in parallel, right? Instead of saying, like in MySQL, for a single query plan, we'll have one thread executed from beginning to end. Now, since we have all these multi-core systems, we have all these extra threads we can use, we want to break up our query plan tasks and allow queries to compute those tasks at the same time. So there's two approaches to doing introquery parallelism. So it's sort of the same way you can have introquery parallelism within that we can have another hierarchy to have the different kind of parallelism we can have in the operators themselves. So we can have introoperator parallelism and interoperator parallelism. So introoperator parallelism, the idea is that we're going to decompose the different operator instances that perform the same function to sort of replicate them multiple times and have them operate on different segments of the data, right? So if you have a scan operator that wants to scan an entire table, we can split that scan operator into pieces and have the different instances operate on just those pieces. And that can be all blasted out in parallel. And the other type of parallelism is to do within the query plan itself, we want to have the different operators at different levels in the plan execute at the same time. So they're doing different functionalities but they're both operating the same time and then we can feed data from one operator to the next and have that second operator compute whatever it is that needs to compute on the output of the previous guy but then the previous guy can still keep on running. So we'll show examples of both of these in a second in the next slide. Alright, so this is introoperator parallelism. Here's our query plan. We're doing a join between A and B on some foreign key and then we have the two predicates to do some kind of comparison to filter out for both of the tables. And then here's sort of a logical plan query plan for this, right?  So say we start with this scan on A. Say A has, you know, a million tuples and we can divide it up into three different chunks of data. And so in our physical plan we'll have separate operator instances that each operate on a portion of the total data for A. So we'll break it up into three chunks or three partitions and then we have an operator instance for those three chunks. And then we can assign them to cores at the same time and they can execute them in parallel. And then now we can sort of expand it even further. We would see that, well the scan on A immediately sends its output into a filter operator. So what we want to do is in our task we want to assign not only the scan on A on some portion of partition of the data but then also apply the filter operator. So this is essentially here is our task that we can then schedule out on these different cores. And then because we know what we're going to do, a hash join, then we want to go ahead and build the hash table that we're going to need to do the probing and do the join later on. And the way that we're going to be able to combine these results is through what's called an exchange operator. So there was a query optimization protocol or method in the 1990s, late 1980s for this system called Volcano. And they basically propose a way to do parallel execution of query plans through these exchange operators. So what's going to happen here is because this task here is doing a scan on A1 and this one is doing a scan on A2, they're all building their own little local view of the table. And then we need some way to be able to combine them together to produce a single answer to then push it up into other parts of the query plan. So this exchange operator is a way to sort of coalesce the results from these separate tasks and then combine them into a single piece of data that can then be used by other parts of the query plan without having to know that it was broken up to three separate tasks. So as we go along, the upper portions of the query plan don't know that we executed this in parallel and it doesn't care, right? So normally what happens if you execute this using like the iterator model, when you get to the exchange operator as you go down the query plan, you would call fork or spawn to fire off these three separate tasks in separate processes or threads. And then it knows that it has to wait until all the output from those three processes or three threads finish before you notify the guy above you to say that I have the data that you were looking for. And now we'll do the same thing on B. Say B is a smaller table. It doesn't have as much data as A. So we'll just split it up into two chunks and then we have two tasks that will do the scan, the filter, and build our hash table. And again, we have that exchange operator that tells us that we need to combine these results. So now we get to the join operator and the join knows that it's going to take the input from the exchange operators and then we can farm out the actual probing, the join operation itself by probing the different hash tables into separate tasks as well. So now we have sort of five tasks on five CPUs here that we can fire off in parallel. Then we have to wait until the exchange operators finish up because now we have our two hash tables that we can computer join. And then once that's done, we can then schedule four different tasks that do join on some portion of the hash tables we built. And then there's that exchange that tells us that we coalesce them and produce the final answer. So this is called horizontal parallelism because within a sort of single hierarchy or level in the query plan tree, we can have all the operator instances running in parallel. So this is very common. This is used in most database systems that support interquery parallelism that they'll do this kind of exchange thing here. And you see this a lot too also in distributed databases is because the idea would be instead of running on separate cores, these are running on separate machines, you get the data over the network to some location, you coalesce them, and then you feed them off to the next operator. Okay, so now in inter-operator parallelism, the basic idea is that we want to have sort of a... You can think of each of these operators in our query plan as running in a separate thread as a separate task, and they're pulling the guy below it to get the next piece of data. Again, this is from the volcano model, or you think of this as doing get next, get next on the guy below to get the next data.  Let's see an example here. So let's say we deal with this join. This join is basically going to do a forward loop on the outer table, forward loop on the inner table, and compute some join, and then I'll call emit to tell it that I have a new output and push it up to the guy above you. So now in our filter operator, this thing here is this spinning on some input queue waiting for tuples to come from this guy below. So you can think of this as sort of a blocking queue where you pull it and say, wake me up when you actually have something. This guy computes a join between two tuples, produces some output, emits it to the next operator. This guy gets woken up in his thread, and then he spins, does whatever it is that he wants to do, and then pushes it up further up the tree. So this guy can just be spinning nonstop, trying to compute this join, and this guy can do whatever it wants, and once he has something to compute, he wakes up and does it. So these two different tasks, these different loops are running in separate threads. They don't matter because now we need to potentially assign this guy to a core, and this guy to a core, and chances are this guy is going to be waiting for a long time for this guy to actually produce something. So this is kind of difficult to do, and they don't do this in Hyper because they want to have a single worker per core, and you wouldn't be able to do this because this core would essentially be idle just waiting for output. So I don't know how many database systems actually do this approach. So I'm still being very hand-wavy about everything we've talked about so far. There's more questions we have to deal with about figuring out what's the right number of workers to use in our query plan, how do you want to split things up in tasks, do you want to use the same number of tasks as we have hardware resources? Does it depend on the size of the data? Does it depend on what the actual operator is doing? So there's all these other questions we still have to deal with before we even decide how we actually generate a physical query plan. So I'm not going to give you, there's no sort of one right answer to say this is exactly how you're going to do this. I can only say here's the different design choices you have to consider when you actually would implement something like this. And you have to look at your application, what kind of database applications you're trying to support, what the other parts of your architecture are like, and when you make decisions for this kind of stuff. So there's two things we have to now consider as well in our schedule. The first is how are we going to assign workers to our hardware resources or workers to our CPU cores. So one approach is to use a single worker thread per core. This is sort of the same thing we saw in h-store where there was a single thread of execution engine per CPU core and that's assigned to a partition. And the way that they made this work efficiently is that they would set the affinity of the thread that was running at that core such that it would only run at that one core.  So you can do this by setting this call called scheduler set affinity and basically you provide the operating system a bit mask that says I want my thread that it's making this call to only run on these sets of cores or just this one core. And you do this for all the other threads you have in your database system to tell them to run on this core and not all these other ones. So what happens is the operating system only schedules to run there so it sort of wakes up and the idea is that as it spins and wakes up it's always going to run at the same core and therefore it's going to have better cache locality because all the data that it accessed the last time it ran still may be in its CPU caches because nobody else was running on that same core. Another approach is to have multiple workers per core and basically the idea is that there's either for a single core or a socket or a subset of the socket and the idea is that by having multiple threads be able to run on our cores we're going to get better resource utilization because we don't have to worry about if one thread blocks then that blocks all execution of that core. There might be another thread that can come along and start doing useful work. This is sort of the same idea we saw in a disk based system because it's about stalling and going out to disk. In our case we may stall for other reasons like the network or just because you know, cache miss or something like that and the OS schedule will be able to put something else in its place and still use the hardware. So there's a bunch of different approaches. In this case here you still use the set affinity because if you're pooling workers per core you want to have them sort of assigned to a subset of the cores. You don't want anything they want to run. The other architecture decision we have to make is how we assign tasks. There's two approaches to do this. So at a high level they're somewhat the same but there's different things you can think about for each of them. So the first approach is to use a push model where there'll be some central thread that looks at all the workers that are around looks at the tasks that are available and assigns those tasks to those workers and then when the worker gets the task it wakes up, starts running it and then when it's done it notifies the dispatcher that hey I'm done and then it's told what the next thing it should do. The pool based model is that the workers are going to always be looking in some kind of queue for the next thing to do and it's going to grab that out execute it on its own and then when it finishes it goes back and gets the next task it doesn't actually tell anybody I'm done it just goes and does it. The hyper scheme and then in this HANA scheme we'll talk about at the end they're using a pool based model I think a lot of the older systems are using a push based model because they do static scheduling. Okay so going forward, regardless of what worker allocation or task time of policy we're going to use it's going to be very important for us to make sure that we only operate on local data. I've talked about this earlier where I said that we want to make sure that when a worker gets a task and that task is going to tell us some data we want that data to be close by to it right and this could be again we want it to be on the memory that's local to it or memory that's close by and again in a distributed system obviously it would mean that you want the data to be on the machine that you're on but it's the same idea. So this means that when it comes time to actually schedule and execute a task on behalf of a query we want to make sure that we're aware of the underlying hardware layout is for our memory model right and there's two basic there's a couple but I'll talk about two of them there's two basic memory models we can have the first is called uniform memory access or UMA and this is the approach that was used in symmetric multi-processing systems up until about 10 years ago when we switched to the NUMA model right and so the basic idea is that say you have four CPU sockets and each of these CPU sockets will have its local cache right L1, L2, L3 and then there'll be a series of memory dims up above that are connected together over a bus so when a process running on say this socket here wants to access memory location X right it would send the request up to the bus and then it would get routed over to the location that had it the reason why we say this is uniform memory access is because the cost or the latency of accessing item X at this dim here is going to be the same for all our sockets or all our processes running these different sockets right you're always going to have to go through the bus right and obviously there's the cache coherence protocol with this this controller here that keeps everything on sync but we can ignore ignore all that right it's basically again there's this bus reading anything or writing anything is always the same for all our processes so then around 10 years ago they actually started implementing what's called the non-uniform memory access so the idea of this has been around for a while and there was some sort of boutique shops that had systems you could buy that had this kind of layout but now this is essentially what Intel pushes forward when you buy high-end Xeons multi socket machines you're going to get this architecture here so now we see that the bus is completely gone and instead we have this interconnect in between all the different processors and we also see that we don't have a shared memory bank or shared locations of DIMs for all our memory instead we're going to have for each socket they're going to have a local memory bank or local memory DIM that it can use and so what happens is say that there's a processor running the socket here and it wants to access memory that's here that's really fast because it's really close to it sort of direct access to it but if this process wants to access memory that's over here that's managed by this DIM then you have to send a message over the interconnect go through this process and then get to the thing that you're actually looking for right now we see why it's called non-uniform memory access because the cost of accessing memory here is really fast the cost of accessing memory here is slower so even though it looks from a processor standpoint from a process standpoint you look like you have this giant chunk of memory right that's all contiguous but in reality they split up across all this different hardware right so if you're not careful about how you organize your database in memory and where you decide how to assign tasks to these different cores when you want to have interquery parallelism you may end up having queries running here that always have to access data over there now we're talking like nanoseconds of access time here but the difference is quite significant and as we'll see in some experiments it makes a big difference if you're always able to access things local here so this idea of organizing the database in our storage and in memory is not new to yes sorry no keep going keep going right so this comment is that it doesn't necessarily even need to be new mom if you have something like this if you say had to there's data that this guy had in his cache all the tasks that have to access some piece of data are always ending up here and then for whatever reason I have a task that gets landed here that will modify data that this guy has in his cache I have to pay a cache coherence penalty because anytime I update that location it's going to have to go and validate the cache here so it's sort of extra traffic to make all this work so it doesn't necessarily have to be we don't have to be careful in a numeric architecture we have to be careful in this architecture as well but I think in my opinion the effects are more pronounced in the numeric architecture than the okay so I'm going to get that so like if you have to do cache invalidation for here in order to avoid cache validation you want to try to keep data that's always used together located at a single CPU socket so any task that has used that data always gets executed here but it's the same idea for both of them okay so this idea of organizing the database in storage is not new and it's not specific to in-memory databases so this is an idea called data placement where we're going to split the database up and then we're going to organize it in such a way and keep track of where the data is actually being placed and then we can use this information to make decisions on how we schedule our tasks and so in the same way in a distributed database where the database system would keep track of this node has this shard, this node has that shard we could do the same thing in memory for here so we could say the database has been split up this CPU socket and its local memory has that portion of the data and this CPU socket and its local memory has that portion of the data and they can make decisions about how we want to organize our scheduling operations and so there's a command in Linux called move pages that essentially allows you to take some address as in memory and move it to one of these nodes or one of these CPU sockets so essentially what happens is if you call move pages and give it an address range without telling it to move it it'll come back and say this memory location is located at this socket here that you can go back and invoke it again and say alright we'll now move it to this other CPU socket so you can have fine-grained control of where you actually move data around in your database system but this assumes that we're doing it after the data has been created right but what happens when we call malloc in our database system we want to allocate a new chunk of memory where does the data actually go what will actually happen in our system so assume we call malloc and assume that the allocator which runs in user space it's not a call into the kernel the user space doesn't have a free page or a free block of memory they can give out through our calling process so what would happen in malloc here yes go sure yes that's it so when you call malloc nothing actually happens it doesn't go in the kernel actually it does go in the kernel but it doesn't actually allocate the real memory so what happens is it'll make a kernel call and tell the operating system to extend the processes data segment the memory that's being used for it but this is all just in virtual memory and it's not backed by anything in physical memory it's only until your process either does a load or store on that memory location you've allocated does it actually get a page fault and then go to the memory control and actually allocate physical memory so now the question is if I call malloc and I allocated a chunk of space where is that memory going to be stored like what's socket so say I malloc it but I don't touch it then another thread in my same process running on another socket he touches it does it land on the socket that malloc did or does it land on the socket that touched it then I'm going to take a guess yes by default yes but you can also do interleaving as well so basically what happens is when we can enforce the operatives will enforce for us that tell us where this memory is going to show up so I think the default is called first touch basically whatever thread touches it wherever that is that's where the local memory will be physically allocated but there's also a command in called numeric control that you can specify the policies that the operative system will use so one of the policies could say just interleave the data all throughout my different sockets so that way I avoid the worst case scenario right so I bring this up because we want to be careful now about how we set things up and load the database and other buffers we need to process queries because we want to make sure that our tasks are operating on data that's local and they're writing to data structures that are local as well we're not going over the interconnect and updating and doing caching validations to other sockets so data placement is a big deal in databases so in this graph here I'm showing this is from a micro benchmark that was done by people at EPFL in memory version of short MT and it's a simple workload where we're going to use four worker threads that are just going to execute the TPCC payment transaction and what I'm showing at the bottom is for these four groups these are different thread layouts or the thread worker thread assignments to the different cores relative to where the data is so all the data is going to be stored on the first CPU socket here, the one on this top corner and then for the different groups where the red marker is it tells us where the worker thread has been pinned to by setting its affinity so in the case of spread all four worker threads are running on different sockets under group they're all running on the same socket where the data is under mix we have two of this first socket and the OS is letting the OS do whatever it wants to do which is always a bad idea and so what you see here is the grouping grouping policy by making sure that the data is executed the worker threads are executed on the socket that has the data close to it gets you the best throughput here so it's just showing you're motivating why you never want the OS to do anything and why we want to be careful about where we assign sockets and where we store the data this is why we keep track of the placement policy or keep track of where the actual pages are stored in memory in our catalog and then we can use that to assign tasks to CPU sockets at run time to make sure they're only accessing the local data so in this example the performance difference doesn't seem very pronounced worst case scenario we're doing about 7,800 transactions a second but now and then up here we're doing about 11,000 for this workload the amount of data access per transaction is quite small maybe 10 or 12 queries each of them is only accessing one tuple so it's not a lot of data being moved around but you can imagine if you're doing an OLAP query that's scanning large table segments, large chunks of data then the performance difference becomes more severe so again never let the OS do your job so the other thing we want to be clarified too is that the partitioning policy of a database system or database is different than the placement policy so the partitioning scheme defines how we're going to physically divide up our database and divide up our tables and we can do this using like range partitioning, hash partitioning we can do a round robin approach where we have say four partitions we each go one by one and assign tuples to them or we can also do partial and full replications we can have say on a single socket we can replicate the same table across all the sockets and this is different than the placement policy because the placement policy tells the data system where to actually push the partitions after you partitioned it so this is telling us now if I split my hash partitioning on my tables based on the primary key now I've got a bunch of buckets the placement policy tells me where I put those buckets so you do this and then you do this and you need to keep track of both of them okay so where are we at so far we have a process model that tells us whether we multi-threaded or multi-process we have our allocation model or worker allocation model this tells us how many worker threads we want for the hardware resources that we have then we have our task assignment model this tells us whether we want to do a push or a pull then we have our data placement policy that tells us how we're going to organize the layouts of chunks of partitions of the database in memory and of course we always have a solid appreciation for the CMU database group so now we can talk about how we create a set of tasks from a logical query plan so this is now the physical task of the CPU cores and we will execute them and run them in parallel so to do this for OLTP queries is really easy because we probably don't want to use intro query parallelism why? what's a standard OLTP query? insert is one, yeah select start from table where ID equals primary key equals some value you're doing an index probe to go find one thing you can't really parallelize the index probe you can't parallelize the insert thing and just doing it so there's not much we can do for dividing up a query plan to multiple tasks for this it's for the OLTP queries that we really care about right? the OLTP stuff is where the currency control allows us to get interquery parallelism and then the stuff we're talking about today is allow us to get intro query parallelism for the OLTP queries so the sort of standard approach that a lot of systems use is what's called static scheduling basically the database system decides when to generate the query plan of how it's going to divide things up into tasks and the easiest way to do this is just to say I have 20 cores I'll have 20 tasks and then just shove it out and then let the scheduler execute them in based on some order the call it's called static because we're doing this before we generate any query plans and we don't adjust anything based on how the actual query plan executes or based on what's actually running the database at the same time and in practice this actually works pretty well because it's easy to implement and there's not much extra metadata you need to keep track of while the query runs so this is what you see in a lot of like MySQL and Postgres I'll do stuff like this but then then we get into what the hyper guys are opposing to do and they're doing a dynamic scheduling of tasks where the database system can adjust how many tasks and how much hardware resources it's going to assign to the query plan while it's actually running and it can adjust that moving that up and down based on what the performance is of the query plan and based on what else is running in the database at the same time so in their approach they're going to have a one worker thread per core they're going to use pool based task assignment and they're going to use round robin data placement for these morsels and the morsels are essentially just partitions right for every reason they didn't want to call them partitions and they didn't want to call them chunks or blocks and things like that so they call it morsels but it's the same thing and we're not going to really talk about this in this class we'll talk more about it on Wednesday but their approach is to allow them to do all the sort of standard operators you want to do like hash join, sort merge join sorting and things like that all in parallel very easily and while being aware of the layout and the placement of data in a numeral architecture so at the high level what you're going to have is in hypers you're not going to have a dispatcher thread because they're all going to do what I'll call a cooperative decentralized scheduling so there'll be these queues of all these tasks that some query planner generates and then the threads can go look in the queue and say alright this task wants to access data that I know is local to me so I want to execute that task and then the idea is that once you're done you put the result in some location that's close to you and then you go back in the queue and find the next thing to do and they use a lock free hash table to make sure that you don't have thread tripping over each other because obviously you don't want two threads trying to execute the same task at the same time alright so let's look at a high level how things look out or how things look so here's our data table and we want to first split this up into morsels so I think they choose for each morsel is going to be 100,000 tuples and this looks a lot like the row groups we talked about in SQL server right row groups, partitions, shards, it's all the same thing and then for each of these morsels they're going to assign them to one of the CPU cores or CPU sockets and then when they load it in they'll store it in the memory that's close to the core so now we want to execute things say we have this query plan here we generate all the tasks for it and they call these things pipelines and the basic idea is that the pipeline is going to be the operator instances that can be run one after another using data directly from the guy below it without having to get data from anybody else so in this case here the filter operator instance can use data directly from the operator instance that generated that does the scan on A it doesn't have to combine anything with anybody else so you wouldn't combine them into a single task called a pipeline so now we have all say in our example here we have three cores and the first thing we see that within the data for each core this local data we're going to have all the morsels that correspond to that have been assigned to it but then we're going to also have this buffer for local data this is where we're going to store the output of all the operators instead of having a global hash table that can be accessed by anybody else it's all going to have these thread local stores that they can use and know that nobody else is going to try to write this at the same time so therefore you don't have to use any lashing or locking to protect this it's the same thing we saw on h-store where every execution engine had its own exclusive access to the data and it didn't have to use any locking or lashing so now we want to start executing this query plan we have our queues and the queues are going to be for each task in the queue it's going to be annotated in some way that says this task wants to execute on data at this morsel and so each of these different threads will look in the queue and they would say we want to do a first scan on A and each of them will find the data that's going to access the data that has local in this morsel storage and so now when it does the scan it pulls data out of its morsels, its morsel storage and runs on it and then when it generates the hash table it will store it in its local data storage so now let's say in this case here these first two CPUs for whatever reason the scan on their morsels runs faster than the third guy so these guys finish and now they can go back in the task queue and try to find the next things to do and again they would say alright well I have some tasks on B here and I know that I have morsels for B1 so I want to grab this, I have the morsels for B2 and grab that so now they can execute on that and then while this other guy is still running computing on the scan on A3 this could be because we miscalculated the amount of work we could have to do it could be that for whatever reason there was a the OS stalled our thread it doesn't matter, we don't care for whatever reason this guy is running behind so now let's say the first core here he finishes up early and it would notice that the core 3 so now we can go up and say well there's this task to scan B3 and I know that data is stored over here but I'll go ahead and steal it because I can't start executing the hash join part because we haven't finished the scan operators in the query plan so in this case here we'd have to pull the data from this guy's morsel storage over the CPU interconnect and then bring it into our memory here and then we can compute the scan operator in the filter there and build the hash table but the key is that when it writes out the hash table as it builds it it writes it to its local data output and there's some catalog or some additional metadata that's tracking in our system to say if you need the hash table for this for this morsel I have it here right and this all finishes up and then it can do the hash join just as it normally would by combining the different the different hash buckets that are built by all these guys and producing the final output so the key thing to understand about why they have to do that work stealing thing or the task stealing thing is that because they only have a single core per worker if you could if each worker thread or each core could only operate on the data on the morsels that it had local these stragglers would slow everything slow everything down yes the core that finished up early could look in the queue and try to execute the next query to try to execute the hash for the next query but ideally you kind of want to have the lowest latency as possible so it's we're willing to pay the penalty of caching validations and moving data over the interconnect by stealing the work from from somebody else we'll see in a few few slides when you actually scale up to really large socket systems like 32 sockets they actually found that the work stealing thing doesn't actually play out that well but in the smaller systems that they're using for the next query, this actually makes sense and then they also use a lock free hash table to maintain the global queues we're not going to talk about that so much here we'll talk about more of that on Wednesday when we talk about doing hash joints right so since the time in the beginning talking about different types of hash tables so another alternative way to do dynamic scheduling is a recent paper in VLDB 2015 from the SAP HANA guys is how they do scheduling in this prototype or this one-off version of HANA the actual real commercial version that you get when you give SAP money doesn't actually do what we're talking about here but this could be something they would add in later on so this type of new and where scheduling is going to do pull by scheduling just like hyper but the difference is that they're going to have multiple worker threads that are allowed to operate in groups on the same harbor cores, the same CPU cores so each CPU socket can have multiple groups so it doesn't necessarily mean to have one socket per group or one group per socket and then when each group we're going to have two different queues that correspond to whether there are tasks that can be stolen or not stolen so a soft priority queue would say that here's something that I want to execute this group but if someone comes along and steals it, I'm okay with that and then there will be a hard priority queue that says no other thread group can steal this task and only can run at this socket and different from what hyper does is that we're going to have a separate watchdog thread running in the background that checks all these groups and see whether they're fully utilized and if notice that some of these threads are idle it can go steal tasks from the soft queue of another thread group so there's much more management we have to do in this than hyper because hyper says every guy's just always looking for the next job it just doesn't regardless of where the data is if there's nothing that can run for its local data in this case here it's a bit more nuanced and there's a bit more sophistication required to do the watchdog thread I'm going to talk too much about what they're doing on the inside but I'll just say that the way that they're going to have multiple threads working in a single group together is that they categorize them based on what they're actually doing so you could have a group of threads that are actively executing a task and you mark them as working and then you could have threads that are blocked for some latch to free up before it's allowed to do something then you can have a free and parked threads and these are sort of like a bullpen for the thread group that allow the watchdog thread to say well I see that you're not fully utilized or you have idle cores so pull something out of the free queue or pull something out of the park queue allow them to go steal work and start doing you know get better utilization by doing work when they would otherwise be idle so I mean I'll be real handwriting about all this but I'll just say that this paper is that it's better to have groups of threads and be able to move around what CPUs they're actually running on rather than having the sort of single thread pin per core and they found that when you scale up to a large number of sockets the work stealing approach that Hyper uses doesn't actually play out and I think that our reason is just because at that level there's so much movement around that you saturate the interconnect with all these cash and allegations and the other thing is I thought was kind of cool in the hyper case those worker threads can only execute queries they can't do anything else so you have to assign additional threads to do logging, additional threads to do networking stuff in the the HANA model because these there's multiple threads per group you could have some of the threads in the group do networking some of the threads do other background processes and overall the utilization become more uniform then having sort of one of these CPU cores that are pegged at 100% all the time processing queries and then other threads you allocate if we're doing background stuff are only used some of the time okay so to sort of finish up quickly a database system is a beautiful piece of software it's doing everything it's doing networking, it's doing logging doing recovery, doing transactions doing query processing and the key thing is in order to treat your database system right you have to make sure that you implement the scheduling protocols to be fully aware of what the underlying hardware looks like because if you don't if you don't realize you're running on a NUMA system or even the NUMA system if you don't track up where your data actually is and you just let it access whatever it wants then you're a software performance penalty in the case of the hyper paper and the HANA paper the difference is quite significant when you run OLAP queries and the main thing again is never let the OS do the stuff the database system can do the database system always knows exactly what's going on and always knows more about what it's trying to do than the operating system ever could to the operating system your database process looks like anything else yes it may have a different access pattern but it doesn't distinguish the database process between a YouTube client or a BitTorrent client the database system actually knows what it wants to do it knows what it's going to do how it's going to execute queries and therefore it can always make better decisions on how it organizes everything this is because we have a declarative query plan we use SQL we know exactly what all the operators are going to do we know where our data is so we can always make better decisions any questions about scheduling fantastic execution so there's another street lesson so in 1997 1997 there was a a noted laureate Christopher Wallace who came up with a list of rules about what you should do or how you should maintain yourself when you're hustling on the street right and in particular he was talking about how to deal crack alright because in the early 1990s crack was really big and he was in Brooklyn and he was dealing crack on the streets there he spent a little time in prison I think when he was like 17 but he came out and basically wrote down and codified a bunch of rules that how you should do all this so even though it's 20 years later and even though that we may not be hustling the same way that Christopher did a lot of these rules that he talked about are still applicable to us in the context of database systems so I'm going to go through each of them one by one so the first thing is that we want to never let make sure we never let anybody know how much money we're holding on ourselves unless people get kind of weird and so we want to avoid that entirely so in the context of databases you don't want people to know like how much money your data system is making how much money your salary is at the company you want to keep all that information private never think is that he says never let people know your next move so if you're going to start you can move your trap from one street to the next you don't advertise that ahead of time in the same ways in the context of databases if you're at one company you think about moving to another or you think about putting out a new feature in your competitors you don't let people know this until it's actually done you never want to trust anybody so in the case of hustling on the street with your trap you don't want people to know where your stash house is you don't want people to know again where you're storing your money where you're staying in the case of databases it's a little bit less a little less vicious so it's okay to tell people where you're going but in general you should be very mindful about what people's ulterior motives are keep everyone at an arms length never sample your own supply in the context of dealing obviously don't dabble in your own product in the case of databases actually maybe I disagree with that this is actually apropos because obviously when you build a database you always want to try to eat your own dog food so if you have a database system that you're building you want to use that for as many internal products as you can so maybe put a line through this one you don't want to follow this never sling where you live basically means if you're dealing don't deal out of your house doesn't matter how much they want from you don't don't give them anything just asking for trouble never lend anybody credit if you think someone who is using is going to pay you back later that's probably not going to happen in the same thing in a database system if you give people free stuff and you expect them to pay you back later with gifts or other things like that it's probably not going to happen so you won't avoid that never mix your family with your business affairs so that means don't try not to get to have your family involved in your trap or have people involved in your database company your database product that's related to not trusting anybody even though you're family because at some point you may have to make a hard decision and your family members may end up getting hurt it's just better to avoid that entirely another thing is that you don't want to keep a large amount of product on yourself and this includes your car your personal body, your house because in general this is just general good advice to have just don't leave anything on yourself yes he says that instead of us holding weight the cats who squeeze your guns can hold jumps too yes so I'm wondering what he meant by this also, what is a jump? okay, so let's go question Dana so Dana asked he says that the cats who squeeze your guns can hold jumps too, so a jump is a jumbo crack rock usually like $20 maybe a little bit more now depending on what the street is and the idea is that there's all these if you're dealing with crack, there's all these laws that say how much product you need to have on yourself before you go from just holding it to distribution so if you have a trap set up and you have a lot of product you personally don't want to be holding all this because if you get caught by the police then they might bust you on a federal charge for distribution so all your sort of minions that are hanging around in a trap that are sort of watching things, taking money, things like that you won't let them hold all the product because if the police come, they'll take the fall and they're under age, they probably wouldn't be arrested in the same way that you would so a jump just means a jumbo crack rock good question it goes without saying never talk to the police it never ends well so avoid that entirely and again in databases the same thing never talk to the police and then finally, never take an assignment job if you don't have the clientele so if someone wants you to sell their product if you don't think you can push it in a reasonable amount of time you don't want to do that because they're going to come back and say where's my money same way in a database job if someone says I have this big customer I need you to come use your database system or build some extra feature for it if you don't think you can do this and complete it in a good amount of time it's probably best not to take the job because people just end up getting upset okay so again all of these things, these are all rules that I follow in my life and I strongly encourage you to do the same because it got me to where I am today okay so next class we're going to talk about parallel hash joins so since sometime in the beginning talk about different types of hash tables lock free hash tables, cuckoo hash tables, things like that and then as a reminder for project number two, next Monday Joy will announce that we'll do a checkpoint the basic idea is a casual thing that you just meet with him, discuss your code if there's any questions you have about how to implement things he can sort of help out and then just make sure that everyone's sort of making progress and moving along okay in the back, yes what happened to Chris? Christopher Wallace in 1997 actually his, the memorial is coming up I think it's next month, it's like March he was shot on March 9th 1997, so it was almost a month for a day we could have a moment of silent for it in the class, but since it's the spring break we can't do that so any other questions? alright see you guys on Wednesday


Welcome to the two-wheel revolution here on ThinkTechHawaii.com. I'm your host, I'm Peter Rossin. This is a program where we talk about micro-mobility, essentially rolling, scooting, walking as a way to get around and avoid the automobile, if possible. So today we have our guest, Anthony Chang, who's been here before talking about some traffic issues before as well. Anthony is an avid bicyclist that actually makes a small business of it, I believe. And he recently wrote a piece for the Hollywood Star advertiser about that darn Alawai bridge, the pedestrian cyclist bridge that's gotten a lot of discussion lately. So Anthony, welcome to the program. Hello for having me, Peter, again. And thank you for everyone who is tuning in and whether you're listening to me for the first time or you've listened to me before, I also appreciate your time. Thank you. Well said, I appreciate the time too. I have my two regular listeners out there, but I'm not sure who else is out there. But let's press forward. You just wrote a piece, so it's published in the Star advertiser, about the bridge. And I imagine you know the first sentence by heart by now. So what was the first, what was the lead? What was the first thing you said? Arguments. Well, I'm probably summarizing. Arguments against the Alawai bridge are anti-democratic, anti-deport and not grounded in democracy or reality. I think that's exactly right. And you know, when I worked for the newspaper for a long time and one of the frustrating things about writing for the newspaper is you never get to write your own headline. So the headline of the story, at least the one on the online version, was pedestrian bridge would be an asset. And so let's take that for a moment, rather than, you know, talk about what's anti-democratic or irrational when we talk about planning. Let's talk about, what do you see are the positives? What, why is this such a good thing? And before we jump into that, I wanna say, I've been an enthusiast and a supporter of this version of this bridge for many years. And so it's not that I'm opposed to it but I'm, you know, interested in all the controversy that's surrounded. So let's start with the positives. What's the good thing? What are the good things about this bridge is where it gets built? It will create a safer and more convenient crossing for people who walk and bicycle. The current crossings, as I mentioned in my op-ed, the sidewalks often are very narrow and sometimes are difficult for people, especially if you have like a wheelchair or just need more space to cross, definitely not more than enough room for one person to walk across. So there's that bit. This is both Kapa Kulu side and Macaulay street for people wondering how to get from Moeho Yuli to Waikiki. And the bike lanes on the Macaulay side disappear at random points, getting into Waikiki. They are non-existent on Kapa Kulu. The Alawai Bridge addresses this pedestrian bicycling only, therefore 100% safe. And because it's such a short crossing, should be accessible for most people who have, you know, even if they have energy issues. Okay, so you would say safety, convenience are the main things? Yes, and I, as I touched upon it in the opinion editorial, makes it more equitable. As I mentioned, there is data that shows that 17, nearly 17% of households on a walk who are carless, nearly 70%, 70% of those people are, would be considered low income by federal standards. So not all of us, unfortunately, can afford the automobile to go across. And even for those who can, they just might wanna walk in and bike across, but they don't feel safe to do so because yes, of all the problems I just addressed previously. Okay, so just to review, there are raising me three ways to get across the Alawai right now. You can come down Kapa Kulu, which is skirts the Alawai. And although there's not a bike lane on Kapa Kulu proper, there is a bike lane along the golf course. There's the Kala Kala extension that goes, or the Alawai extension that runs up to Kala Kala Avenue and then goes right. And there's, I guess that's a bridge, all right, before the convention center. And then there's the McCulley Bridge. Is that it? And that those are, well, aren't those enough? Though there are shared use paths up going up Kala Kala past the Alawai, but there are patches, I wanna say of Kapa Kulu Avenue, definitely no shared use path, definitely narrow crosswalks. Again, really inconvenient and you're not going to see a lot of people, you're definitely not gonna see a lot of cyclists on the road.  Not just like walk and push your bike. And same thing on the McCulley side, I've seen a lot of cyclists. That was actually my early days too. As someone who spends a lot of time on the road doing deliveries, I do feel comfortable doing it, but I understand that I am not, probably like 98, 99% of people. During my early days, when I was bicycling back when I was just only using B-Key, B-Key, shout out to B-Key. I only, I often just got on the sidewalk and walked my bike across just to get into Waikiki, which unfortunately is not very, you know, it's telling how unsafe I felt and definitely not convenient if you have to walk your bike across. Yeah. I guess I've done this route myself, and I used to more frequently do the bike routes that goes basically along the Alawai on the Malca side and then down Alawai on the Makai side and just cross at the McCulley bridge and the McCulley bridge is awful. McCulley is awful. I mean, McCulley is a street that's four lanes wide, I guess, and seems to always have six lanes of traffic on it. So I sympathize with that idea, although some people raise the question of why it's needed, but I think you make the case that it's not a huge distance down. If you're on the Alawai and the University Avenue, the end there, it's not a huge way to go to McCulley or a huge way to go to Kapaulu, but it's an inconvenience that it does, I'm sure, discourage the people from taking the bike there. So... I could get into it too. The other thing I thought about too is if you do walk or bike, there's a long ways between Kapaulu and McCulley, especially by foot, never mind by bicycle. Sorry also to the Alawai Canal, that is a terrible bike lane, no offense to anyone who ever designed it because it's next to like 200 cars, never mind the traffic that is definitely gonna fly by you at 35 miles per hour, but cyclists are often concerned that a door will open up on them suddenly, and if you're biking, blasting really fast, that it could lead to... If you hit the door straight on, it'll lead to an injury, but the door could also knock you into traffic, which is gonna cause a lot of other injuries. And just having a more central route to get into university, McCulley would be, again, safer and more convenient for the reasons that I guess. It's not as long of a route, and there are already a lot of people who actually bicycle and walk actually on the other side, the Malka side of the Alawai Canal, just kind of like adds to that traffic, but there really is a good amount, at least all the times I've ever biked and walked by. And speaking of the Alawai, I mean, either you're in that bike lane going with traffic, waiting for a door to open in front of you, or you're on the sidewalk, which is problematic for, because it's not really a sidewalk from excuse, and it's also not straight. You have to curve around every palm tree and so forth. So it's not, depending on which way you're going, you're either coming up behind pedestrians or you're coming down in front of them. But there is a plan to approve that, I think, is there not, there's got to be, we don't know when, but there's a plan to approve, move the parked cars on the Alawai and create a bike lane on the other side. Isn't that coming sometime? I don't want to escalate the timetable as I am not a planner for Department of Transportation Services or Complete Streets. They do have that in the works. They're supposedly supposed to be something like a two-way bike lane, at least for parts of it, or some of it, and they're going to get rid of, I believe the estimate is about 20% of the parking to create enough space for that. And I also want to mention, yeah, folks do not, it is illegal to bicycle on sidewalks, which is the sidewalk next to Alawai Canal. So I usually don't, and there is, there's a lot of people who do walk and jog and do other things through. So I take my chances with the bike lane. It sometimes actually gets even congested on that bike lane. Sometimes I'll just take the road. I'll take the right lane, and I'll just spot myself there taking the lane, so to speak. So I will get to, bike lane despite how bad it is, it is used. Yeah. When we'll get to the struggle over losing 20 parking spaces some other time, I'm sure there'll be a protest about that. But going back to what you said, you said something like 17% of the people on Alawai who do not have automobiles, is that right? Yeah, there's a study from Brookings Institute. I, if I had a way, I would put a link up on it. But the State of Hawaii also got a book through the US Census also, they track carless population. They track zero car households. And they can also tell you how many other number four or two based on people who responded. So all the data is out there. Yeah. That's not what Brookings pulled it from actually, they probably, the census. I doubt they did a study around the water. So I would also guess just on experience that many of the households in the Aboelele, Macaulay area, which is pretty congested, are those households without cars. And also many of the people, the residents of Waikiki who we often forget about, but I think if I remember 35, 40,000 people live full time in Waikiki where parking is difficult. Then if you move on up University Avenue, you've got the university population. Many of whom don't have a vehicle either by choice or by consequence. So my guess would be that the people on both sides of this bridge are among the communities or those communities are among those that have the most people without our mobiles. You think that makes sense? It's hard for me at university side, I could believe the average amount of cars per household on Oahu is two. I have seen data that you get when you get more to our town, it shrinks down to one. Therefore, by a statistical probability, statistical averages, yes, there are probably more zero by your friends, more zero households when you get toward town. Because it's also just going to be, the sun there is probably a few households that have two or a bit of three cars that you get the idea of. From there to averages, but the average is going to be, it's either gonna probably, the amount of people who own one car or less definitely gets higher when you get to more town or less, zero. Well, you're cooking a fish and I go by the seat of my pants, anyway, so let's look a little bit at some of the opposition. There is always opposition to projects like this, like rail, like anything. I worked for Hawaiian Electric for 20 years and if you wanted to put up a poll you had that, you of course, you had to have a community meeting as you should. And of course, there were people turned out and said, oh, that will block my view and so forth. When you look as a planner yourself, but if you look at the complaints or the opposition or the arguments, are there any there that are at all convincing to you? Are there any there that you say, well, you know, maybe they have a point?  My first word of the first sentence is arguments. So I got some comments that Anthony, you shouldn't name call people. I have not. And if you were, if I knew you opposed the bridge, rest assured, I'm still very friendly, approachable. I've had people who debate with me and I'm usually pretty nice with them, but I am going to, arguments, I'm sorry, but don't have feelings, don't have rights. You're entitled to your argument, but I still will treat you as a human being with respect and kindness that you deserve. That's good. But let's go ahead. Well, we can argue about that for a long time about it, but let's talk about the bridge. So are any of the arguments or any of the comments that you heard at the meeting or that you got, I didn't like it, I didn't pick the comments you got on the piece were good and nobody signed their name. So I tend to just let those go, but is there any of the opposition that you think, well, you know, maybe they have a point or I wonder how we can, if there's a way to deal with that. Anything at all? Okay. The self about it bringing crime is not based on evidence as I kind of addressed on my editorial. There are complaints about its design, which I'll be fair, I actually don't have strong opinions about it. They want to get rid of the sale thing and stick columns into the water. There is an argument that it will impact paddlers, however, there are columns on the McCulley Bridge and the paddlers seem to be navigating it through. So there is some criticism about the design even though the principle is good. So there's that bit, that's a legitimate thing. But I as a planner, I only think about the public good. So I don't think about athletics. Will it benefit this community as a net? Yes. And if I may, Peter, there is one argument that is based on evidence that has not been touched upon that people have not brought up. If you want me to share it. Share it, let's start. So projects like this tend to lead towards gentrification. If you are worried that it is going to make your rent more expensive and price you out of Mo'ili'ili or Waikiki, that complaint would be legitimate because there are studies and evidence, unfortunately, that like support this stuff. The cost of living on Waikiki is really high. I should stop smiling, but I'm just smiling because it's just an argument that hasn't brought it up. But the project like this do, there were people who are worried about their property values dropping with the increase in time. It will actually probably be the worst, your property values will likely increase and that might make your rent more cheap, more expensive, excuse me. Assuming you don't have a lockdown with a mortgage or something like that, your monthly payments. And so there is that. But that's a longer term effect as order to place, but this is historically even true. The most complete streets, they tend to be gentrification projects. Many major transportation works tend to be gentrifiers, notorious gentrifiers. So I haven't heard that one actually, so. Yeah, there are, there is a complete streets plan for University Avenue to also increase the bike lanes and so if it is gentrification, or that it's coming bridge or not, but the bridge is part of that plan. I guess for me, the aesthetics do matter. And I look at the pictures of those, of that sale, if that's what it is. And it doesn't warm my heart, what could I say? It doesn't, I do take aesthetics into account that it seems like too much. I work for Hawaii Electric, as I've said, and I work with a lot of engineers. And engineers tend to over engineer. In my experience, they want the gold-plated solution rather than something that is inadequate. So it does bother me a bit that this thing has turned into much bigger physically than it was that I envisioned it in my mind. I envisioned something like the Macaulay Bridge, but it got a little better than the Macaulay Bridge has turned out to be. Is there anything that can be done about that, do you think, as a planner? Is it too late to modify that design or do you think it's a done deal? By the way, there was also, I think I mentioned a bicycling and pedestrian bridge in Chinatown, actually, I can almost like, if there wasn't, if the Chinese cultural closet wasn't my way, I'd be able to see that bridge. And that design is actually, if you saw us see it, it is much simpler. A lot of this is, I think where there's a political will, there is a political way. A lot of this is politics-driven. Sorry, this bridge, infrastructure projects, in my opinion, should not be political. No, I don't think it's too late to change design with enough political groundswell, it can change. However, because 60% of the design is already complete, if we change the design at this point, people are already complaining about the cost of the bridge. If we change the design, the cost will go up and not like in a small kind way.  Like, it went through architects or engineer scrutiny. In all likelihood, we will lose much of the money that has already gone into the design of the project and it will be expensive to redesign. But yes, it is possible. It can be done with enough. If you message your mayor, your city council, whoever enough, if there's enough, even civil servants, which I am, but I don't work on the project, thankfully, I would love to work on the project, but I don't work on this project so no conflict of interest. But us, we as civil servants, we care about public opinion. We care about public pushback. We listen and read about it. And as extravagant as some projects, people feel like have been, they might've been more without the pushback and we listen to, but we listen to the people we serve. That's it. I am not pretty. I saw like I work, you know, I was a civil servant on this project. I haven't read. I've watched a couple of community meetings. I've voiced my support for the project. I am a stakeholder as a small business person, as a delivery person who spends probably at least 60% of his weekend shift, bicycling up and down, Waikiki and O'Uli Uli. So though I'm not a resident, I am a stakeholder. I came in and I shared my piece and never have I actually ever touched upon the design of the project. I just want this to happen. I want a better bicycling and walking, crossing, especially considering our current situation. Yeah, that's fair and I think and I respect you for, first of all, for clearing it up if anybody thought that you were in some kind of great conflict of interest or that you worked on the project and also because you put your opinion out there and you signed your name to it, which to me is an act of bravery. Whether I'd agree with you in this case, I do or I disagree with you. If you're going to express an opinion in a public swarm like the newspaper, put your name on it. And if any of those comments that followed your article or any others, if they want to be treated with respect, they need to put their names on it as well. So I give you kudos for doing that and for frankly not holding back.  And I responded to those comments on my name. You can actually see at the check, like if you're lying, I didn't hide behind a safe name or pseudonym or anything like that. You could maybe wonder if it was really me and is there someone in the person need to be me? But no, that was me. That's Anthony Chang. There is Anthony Chang, the comments are and Anthony Chang, the author are one and the same for this article. Yeah, as I say, that is worthy of respect. And I do agree that the bridge already built. I guess I have my some reservations. I guess the bridge would also, it's going to be about 20 feet wide if I get the information correctly. And I wonder about, you've seen the possibility or in danger of kind of a conflict on the bridge between pedestrians, some of whom will be pushing strollers and so forth between those folks that have people on traditional bicycles peddling and then the electric bike folks, I think of one year one. Do you think that's going to be a problem? Is there any way to deal with, if you do, is there any way to deal with that problem? One of the things the city could do better is make it evident what is the speed limit for a bicycle for a shared use path, which is this is the legal and legal clone offer. While I was wondering what a shared use path is, that is a path that is legal, but it often looks like a sidewalk, but some shared use path examples, and Yeezy wants to pick up the state capital, technically not a sidewalk, shared use path, the path that goes through Almanlou Halle, the diamond head side, where the zoo goes up to Kapakulu, up to Alawai, those are all legally shared use paths, and they could just put shared use path, speed limits, nine miles per hour, less than 10 miles per hour, and there, but I would argue it's relative. If a pedestrian, most people were walking, if they had to choose, it would be horrible to get hit by a bicyclist if you were walking, but you'll probably survive, you'll be upset, you might get an injury, but you'll live, especially if you get relative to getting hit by a car, which is something that is more possible, especially on the Wakali side, Kapakulu side too, at various points, where I've had some people actually just kind of like, they've had to hop, they wanted to be polite, and get all the person's way, they kind of hopped into the street, which is not, but yeah, can there be a conflict? Yes, but it doesn't have to be a serious, the automobile versus pedestrian, a cycling conflict, and hopefully with a bit more education or vacation, you'll change people's behaviors. Yeah, well, that's a hopeful attitude, and I agree with it. I think as people get used to walking and scooting and rolling through these mixed-use areas, a multiple-use area is that people will get used to it. They certainly have gotten used to it in Europe, it didn't happen overnight, but you see shittings like Copenhagen, and Oslo, and others, it's not called where somehow, and there are accidents of course, from time to time and everywhere in Amsterdam, but by and large, people have gotten used to it, it just doesn't happen overnight, unfortunately. And at a local level, during what is like work rush hour, you get a lot of people walking and bicycling on the Honolulu Halle and state capital grounds, as far as I know there haven't, I mean, yeah, they haven't, thank God forbid, any deaths, but definitely no permanent injuries, nothing that cripples, see, but I know. Well, there's a lot of people, I know this because it's about the time I go home. There are a lot of people walking and bicycling on that shared-use path during rush hour as well, and same thing, I'm sure people got used to it. Maybe there is a complaint, I probably not enough to check to warrant a change, you know, I haven't seen, I think on the state capital at one point, they were even discussing like a dedicated like bike path, that never happens, and there we are, you know, I guess it wasn't even warrant enough for, again, if there was enough political will for it, my opinion would have happened and it hasn't, probably just because there aren't enough conflicts for it to happen. Well, let's hope that's true. Anthony, thank you so much for running out of time. I really appreciate your coming on and talking about this. I think we've had a great exchange, not just what's great about the bridge, which I think we both agree on, but trying to figure out if there's some way to make it better and to make it more palatable, even to the people who are opposed to it. But I really appreciate your commentary. I'm sure you spoke at the meeting and your commentary and the Star Advertiser and your commitment to cycling is, to me, very, very honorable and very much to be praised. So I want to thank you for coming on the program again and I'm going to go now to our microavailability moment, which is how I end most of our shows.  And so before you maybe go to your local bike shops, which are some of which are terrific and will help you out, spend some time on this site and learn a little bit more about electric bikes. You learn about how you should behave. This is the kind of education that we're just talking about. It's not just pedestrians, it's cyclists who need to be and drivers, everybody needs to be educated. So I really encourage you to take advantage of this and the last picture here, I will show this for the very last time. It's me learning to ride a bike at about 14 years old. I was the last kid on my block to learn to ride a bike and it took a long time, but I finally found my balance and I encourage you to learn to ride a bike and learn to get back on a bike if that's, you know, if you've been on one before because it's fun, especially an electric bike, it's good for the environment, it's good for your health. So with that, I'm gonna thank Anthony once again, appreciate it. Thank you to my two regular viewers for watching and we'll be back with the two wheel revolution in a couple of weeks. Aloha. Aloha Mahalo.


Hello and welcome to the session. In this session, we will discuss the following question and the question says solve graphically the equations x plus 2y is equal to 4, 3x plus 2y is equal to 6. Let's start the solution now. We are given the two equations x plus 2y is equal to 4 and 3x plus 2y is equal to 6 and we have to solve them graphically. For this step one is draw the graphs of the two equations on the same coordinate plane. Now to draw the graph of the first equation that is x plus 2y is equal to 4. We will first make the table of values for the equation x plus 2y is equal to 4. To make the table of values, we now substitute values of y and obtain values of x. Now the given equation is x plus 2y is equal to 4. This implies x is equal to 4 minus 2y. So we have expressed the variable x in terms of the variable y. Now we substitute different values of y and obtain values of x. So for y is equal to 0, we get x is equal to 4 minus 2 into 0 which implies x is equal to 4. Now for y is equal to 1, we get x is equal to 4 minus 2 into 1 which implies x is equal to 4 minus 2 which is equal to 2 and for y is equal to 2, we get x is equal to 4 minus 2 into 2 which implies x is equal to 0. We will now put the values of x and y that we have just obtained in this table of values. For y is equal to 0, we got x is equal to 4. So we write these values here. Also for y is equal to 1, we have x is equal to 2 and for y is equal to 2, x is equal to 0 that is y is 2 and x is 0. So we have obtained three ordered pairs in this way. Now we will plot the points ordered pair for 0, ordered pair 2 1 and ordered pair 0 2. So this is the coordinate plane and we have made two axes on this coordinate plane. The horizontal axis is the x axis and the vertical axis is y axis. We will now plot these three points on the coordinate plane. We will plot the point ordered pair for 0. Now in the ordered pair for 0, the x coordinate is 4 and y coordinate is 0. So this point for on x axis is the ordered pair for 0 since it has x coordinate equal to 4 and y coordinate equal to 0. Now we should plot the second point that is ordered pair 2 1. The ordered pair 2 1 has x coordinate equal to 2 and y coordinate equal to 1. So first we reach the point 2 on x axis and then remove upwards along the y axis. Can we reach the point 1? So this point is the point ordered pair 2 1. The third point is ordered pair 0 2. Ordered pair 0 2 has x coordinate equal to 0 and y coordinate equal to 2. So this point 2 on y axis is the point ordered pair 0 2 since its x coordinate is 0 and y coordinate is 2. In this way we have plotted the three points. Next we will join these points. So now we will join these three points. So this is the line formed by joining the three points and this line is graphed by the equation x plus 2y is equal to 4. We will now make the table of values for the equation 3x plus 2y is equal to 6. Now the given equation is 3x plus 2y is equal to 6. This implies 2y is equal to 6 minus 3x. This implies y is equal to 6 minus 3x divided by 2. We will now substitute the three values of x and get values for y. So for x is equal to 0 y is equal to 6 minus 3 into 0 upon 2 which is equal to 3. Now for x is equal to 1 we get y is equal to 6 minus 3 into 1 upon 2 which is equal to 1.5 and for x is equal to 2 y is equal to 6 minus 3 into 2 upon 2 which is equal to 0. So for different values of x we have obtained corresponding values of y. So we now put the values of x and y that we have just obtained in this table of values. We obtain for x is equal to 0 y is equal to 3 so we write down this in this table for x is equal to 0 y is 3. For x is equal to 1 y is equal to 1.5 and for x is equal to 2 y is equal to 0. So in this way we have made a table of values. Thus we have obtained three ordered pairs. Now we will plot the points ordered pair 0 3, ordered pair 1 1.5 and ordered pair 2 0. Thus we will plot the three points that we obtained from the second equation in the same coordinate plane. The first point that we will plot is the ordered pair 0 3. Now in the ordered pair 0 3 x coordinate is 0 and y coordinate is 3. So we first reach the point 0 on x axis which is the origin and move upwards along the y axis till we reach the point 3. So this point is the point ordered pair 0 3. The next point is ordered pair 1 1.5. Now in the ordered pair 1 1.5 x coordinate is 1 and y coordinate is 1.5. So we first reach the point 1 on x axis and move upwards along y axis till we reach the point 1.5. So this point is the point ordered pair 1 1.5. The third point is ordered pair 2 0. Now this point 2 on x axis is the point ordered pair 2 0 since it has x coordinate as 2 and y coordinate as 0. So this is the point ordered pair 2 0. Now we will join these points. So we have to join these three points that we obtained from the second equation. So this is the straight line that we obtained by joining these three points and this line is the graph for the equation 3x plus 2y is equal to 6. Now step 2 is see the coordinates of the point of intersection. The two lines we can see that the two lines intersect at the point 1 1.5. So at this point x is equal to 1 and y is equal to 1.5 since this point lies on both the lines therefore ordered pair 1 1.5 is the solution to the given equations. So we can say that since the two lines intersect at the point ordered pair 1 1.5 therefore x is equal to 1 and y is equal to 1.5 is the answer to the given question. With this we end our session. Hope you enjoyed the sessions.