<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Thoughts of an allocated mind.</title>
    <description>An open repository of freely available research, notes and thoughts on computer science, engineering, programming and everything related.</description>
    <link>https://ankurcha.github.io/malloc64/malloc64/</link>
    <atom:link href="https://ankurcha.github.io/malloc64/malloc64/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Where Clause Options</title>
        <description>&lt;h1 id=&quot;thoughts-on-where-clauses-for-analytics-api&quot;&gt;Thoughts on &lt;code&gt;where&lt;/code&gt; Clauses for analytics API&lt;/h1&gt;

&lt;p&gt;The current API where clause is limited in terms of functionality and the set of operations it can support. This document represents a survey of the possible alternatives.&lt;/p&gt;

&lt;p&gt;The requirements of any alternative is that it supports (either partially or fully) the following list of features:
* An extensible array of operators, namely:
	* &lt;code&gt;==&lt;/code&gt;, &lt;code&gt;!=&lt;/code&gt; Equality and inequality (both point query and ‘in’ query) operator
	* &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;gt;=&lt;/code&gt; Range query opeators
	* &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;, &lt;code&gt;||&lt;/code&gt; and &lt;code&gt;!&lt;/code&gt; Logical operators
	* &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;)&lt;/code&gt; grouping operators&lt;/p&gt;

&lt;p&gt;The alternatives below are evaluated on three axes:
* Ease of use
	* A new user should find it easy to read the documentation/examples and not find something in the API very difficult to use. This covers the syntax as well as the readability of the syntax. This requirement also ties into how much effort is needed to on-board a new user in terms of reading the documentation, examples and being able to get started. The effort needed to get from zero to understanding a sizable chuck of the functionality so that the developer may feel productive.
* Extensibility
	* This requirement is more forward facing and intends to capture how easy is it to extend the functionality provided by an option. The developer who creates a new piece of functionality should be able to add that feature without disturbing the ease of use argument.&lt;/p&gt;

&lt;h2 id=&quot;option-1&quot;&gt;Option 1&lt;/h2&gt;
&lt;p&gt;This option suggests that the URI query string be used like a regular string and we construct queries based on a set of developer defined operators. This means that we could potentially specify a query string that is very readable but not necessarily similar to the key-value syntax of most URI query strings.&lt;/p&gt;

&lt;h3 id=&quot;extensibility&quot;&gt;Extensibility&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;The developer is expected to maintain a proper parser to ensure that a user request and all the components are parsed into a well defined parse tree. This option may exactly contain the operators as defined above in infix notation.&lt;/li&gt;
  &lt;li&gt;There are a lot of options to create a parser, such as antlr or even using regular regex combined with custom logic to interpret the final set of values.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;ease-of-use&quot;&gt;Ease of use&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;In terms of readability the user would find that the query string closely resembles any logical infix expression. This ensures that the syntax is mostly intuitive and after understanding the function of each of the operators they would be able to understand their intended purpose.&lt;/li&gt;
  &lt;li&gt;There may be some confusion about escaping the operators and arguments.&lt;/li&gt;
  &lt;li&gt;A lot of the http clients out there only support key-value syntax and the user may need to switch or figure out workarounds for this syntax.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;example&quot;&gt;Example:&lt;/h3&gt;

&lt;p&gt;In this example we use &lt;code&gt;;&lt;/code&gt;, &lt;code&gt;,&lt;/code&gt; to denote logical &lt;code&gt;and&lt;/code&gt; and &lt;code&gt;or&lt;/code&gt; operations.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://api.brightcove.com/v1/accounts/1234567890/report?from=2014-01-04&amp;amp;to=now&amp;amp;offset=200&amp;amp;limit=100&amp;amp;dimensions=video&amp;amp;where=(video_duration%3E=300;video==1,2,3,4;video_view%3C=100),(video_view%3E=9000)&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(video_duration&amp;gt;=300;video==1,2,3,4;video_view&amp;lt;=100),(video_view&amp;gt;=9000)    
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The where clause if fairly easy to understand (once decoded) the user knows what the different operators mean but it would still require some getting used to.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The current Google analytics reporting API v3 is represented in the same way.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;option-2&quot;&gt;Option 2&lt;/h2&gt;
&lt;p&gt;This option proposes the use of a grammar that represents a &lt;a href=&quot;http://en.wikipedia.org/wiki/Conjunctive_query&quot;&gt;conjunctive query&lt;/a&gt; with negation. 
&lt;a href=&quot;https://parse.com/docs/rest#queries-basic&quot;&gt;Parse.com&lt;/a&gt; does this form of api. As an example consider:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bash
curl -X GET \
  -H &quot;X-Parse-Application-Id: ${APPLICATION_ID}&quot; \
  -H &quot;X-Parse-REST-API-Key: ${REST_API_KEY}&quot; \
  -G \
  --data-urlencode &#39;where={&quot;score&quot;:{&quot;$gte&quot;:1000,&quot;$lte&quot;:3000}}&#39; \
  https://api.parse.com/1/classes/GameScore
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As is evident, here the syntax of the where parameter is a json document that will be url encoded which increases the readability but also makes the user think in a prefix (conjunctive query like) syntax for the expressions.&lt;/p&gt;

&lt;p&gt;Another way to represent may use a more familiar syntax by not using json and replacing it with “regular looking” function calls. Eg:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;and(gte(video_duration, 200), or(eq(video, 1), eq(video, 2), eq(video, 3), eq(video_name, foo%2Cbar))&lt;/code&gt;&lt;/p&gt;

&lt;h3 id=&quot;extensibility-1&quot;&gt;Extensibility&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;The developer of an this format would need to implement a parser that can pase the expression and then convert it to a corresponding database query.&lt;/li&gt;
  &lt;li&gt;Adding new operators would be simple as registering a new &lt;code&gt;function&lt;/code&gt; name and the corresponding logic needed to generate the database query.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;ease-of-use-1&quot;&gt;Ease of use&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;As long as the content of the where parameter is properly url encoded, any regualar http client would easily handle the request.&lt;/li&gt;
  &lt;li&gt;The user of the API, after learning about the set of functions available would need to think in prefix notation terms and not the regular infix terms. This means that some novice users may find the onboarding process more involved than simply writing a usual logical expression.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 11 Aug 2014 00:00:00 +0000</pubDate>
        <link>https://ankurcha.github.io/malloc64/malloc64/2014/08/11/where-clause-options/</link>
        <guid isPermaLink="true">https://ankurcha.github.io/malloc64/malloc64/2014/08/11/where-clause-options/</guid>
      </item>
    
      <item>
        <title>Paper: Anti-caching: A new approach to database management system architecture</title>
        <description>&lt;p&gt;Traditionally, databases have involved heavily encoded disk storage format + buffer pool for caching hot segments of data. Executing query
first checks the buffer pool and if data is not present there an eviction occurs for the disk block needed and query resumes. This involves
substantial overhead in maintaining the buffer pool. In some cases almost 1/3rd of the CPU (if all data exists in the buffer pool).&lt;/p&gt;

&lt;h2 id=&quot;alt-main-memory-databases&quot;&gt;&lt;strong&gt;ALT&lt;/strong&gt; Main memory databases&lt;/h2&gt;

&lt;p&gt;Main memory databases store all data in memory and do not have a buffer pool. =&amp;gt; drastic improvement in performance but it also needs all
of the data to fit in memory otherwist the OS will pagefault when we try to access data that is not in physical memory (virtual memory paging) i.e.
page faults. This causes all txns to be stalled.&lt;/p&gt;

&lt;h2 id=&quot;alt-distributed-cache&quot;&gt;&lt;strong&gt;ALT&lt;/strong&gt; Distributed Cache&lt;/h2&gt;

&lt;p&gt;This is a widely adopted stratefy wherein we use a main memory distributed cache (eg: memcached) in front of a regular disk backed DBMS. But,&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Objects are double buffered (DB buffer pool + distributed cache)&lt;/li&gt;
  &lt;li&gt;Requires apps to embed logic to update/maintain/invalidate cache.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;intro-anti-caching&quot;&gt;&lt;strong&gt;Intro&lt;/strong&gt; Anti-caching&lt;/h2&gt;

&lt;p&gt;DBMS runs with the data in memory and when memory is exhausted, it evicts the coldest tuples from memory to disk with minimal encoding. =&amp;gt; ‘hottest’
data resides in memory and ‘colder’ data is on disk. &lt;em&gt;Data is either on disk or in memory but never in both places&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Data starts off in memory and cold data is evicted to disk.&lt;/li&gt;
  &lt;li&gt;Allows for fine-grained control (at tuple level) for evictions.&lt;/li&gt;
  &lt;li&gt;Non-blocking fetches: When a txn needs a block that is not in memory, it is aborted, the tuples are fetched to memory (and evictions may happen to accommodat this) and the txn is restarted when the blocks are available. Meanwhile, all other txns continue.&lt;/li&gt;
  &lt;li&gt;We can batch disk block reads so that multiple disk blocks can be read together - increases performance/throughput.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Anticaching architecture out performs traditional disk-based and hybrid architecture for popular OLTP workloads.&lt;/p&gt;

&lt;h2 id=&quot;assumptions&quot;&gt;Assumptions&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Restricts the scope of queries to fit in main memory.&lt;/li&gt;
  &lt;li&gt;All indexes fit in main memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;h-store-system-overview&quot;&gt;H-STORE system overview&lt;/h2&gt;

&lt;p&gt;Traditional DBMS - if buffer pool is full, the dbms chooses a block to evict and make space for the incoming dbms one (from disk) - needs concurrency control mechanisms to allow other txns to continue while the stalled one is waiting.&lt;/p&gt;

&lt;p&gt;Recently, RAM is cheap enough to store all or most of the dataset in memory for most OLTP workloads. - This is the scenario H-Store attempts to target&lt;/p&gt;

&lt;p&gt;Components of H-Store
1. H-Store node - single computer that manages multiple partitions.
2. Partition - a disjoint subset of the data. Each partition is assigned a single threaded execution engine that executes txns and queries.
3. Hstore can execute adhoc queries but it is primarily targeted to work with stored procedures. -&amp;gt; a txn is an invocation of a stored procedure&lt;/p&gt;

&lt;p&gt;Stored procedure has &lt;em&gt;control code&lt;/em&gt; that invokes predifined parameterized sql code.&lt;/p&gt;

&lt;h3 id=&quot;workload--&quot;&gt;Workload -&amp;gt;&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Single partition transactions&lt;/strong&gt;
1. Most txns are local to a single node.
2. Examined in the user-space hstore client, params are substituted to form a runnable query, so the txn can be sent to the correct node where it is executed completely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-partitio transactions&lt;/strong&gt;
Consists of multiple phases in which more than one partition is touched.&lt;/p&gt;

&lt;p&gt;Each transaction is given a unique txn identifier based on the time it arrived into the system. If a txn with a higher transaction id has been already executed, incoming transaction is rejected.&lt;/p&gt;

&lt;p&gt;Multipartiton transactions use an extension of this protocol where each local executor cannot run other transactions until the multipartition transaction is completed.&lt;/p&gt;

&lt;p&gt;Each DBMS node continuously writes async snapshots of the database to the disk at fixed intervals. Between these intervals, it writes out a record, to a &lt;em&gt;command log&lt;/em&gt;, of each txn that completes successfully.&lt;/p&gt;

&lt;h2 id=&quot;anticaching-system-model&quot;&gt;Anticaching system model&lt;/h2&gt;

&lt;p&gt;The disk is used as a place to spill cold tuples when size of the database exceeds the size of main memory. &lt;strong&gt;A tuple is never copied&lt;/strong&gt;. It either lives in memory or on disk based on anti-cache.&lt;/p&gt;

&lt;p&gt;The DBMS evicts cold data to the anti-cache to make space for new data – constructs fixed sized blocks for LRU tuples to be sent to the anti-cache (disk).&lt;/p&gt;

&lt;p&gt;When a txn needs an evicted block, it switches to pre-pass mode to learn about all the blocks that the txn needs. The txn is then aborted (rollback changes if needed) and holds it while tuples are fetched into memory in the background. Once the data has been merged back to the memory resident data, txn is restarted. Other txns keep executing while data is being fetched from disk.&lt;/p&gt;

&lt;h3 id=&quot;storage-architecture&quot;&gt;Storage Architecture&lt;/h3&gt;

&lt;p&gt;Storage manager (in each partition) contains:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Disk resident hash table that stores evicted blocks of tuples called the &lt;strong&gt;Block Table&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;In-memory &lt;strong&gt;Evicted table&lt;/strong&gt; that maps evicted tuples to block ids.&lt;/li&gt;
  &lt;li&gt;In-memory &lt;strong&gt;LRU chain&lt;/strong&gt; of tuples for each table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These structures are all single threaded so no concurrency control mechanisms are needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Currently, we require that all the primary key and the secondary indexes fit in memory&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Block Table&lt;/strong&gt;: A hash table that maintains the blocks of tuples that have been evicted from the DBMS’s main memory storage. Each block is the same fixed-size and is assigned a unique 4-byte key.
A block header contains the identifier for the single table that its tuples were evicted from and timestamp for the block creation time. Body containst eh serialized evicted tuples from a single table. Each evicted tuple is prefixed with its size and is serialized in a format that closely resembles the in-memory format. The key portion of the Block Table stays in memory but the values are stored on disk without OS or filesystem caching.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evicted Table&lt;/strong&gt;: Keeps track of the tuples that have been evicted out to disk. Each evicted tuple is assigned a 4-byte identifies that corresponds to its offset in the block it resides in. The dbms updates any indexes containing evicted tuples to reference the Evicted Table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LRU Chain&lt;/strong&gt;: Allows the DBMS to quickly determine at runtime th least recently used tuples to combine into a new block to evict. LRU chain is a doubly linked list where each tuple points to the next and previous most recently used tuple for its table. The dbms embeds pointers directly in the tuples’ headers.  The pointer for each tuple is a 4-byte offset of that record in its table’s memory at the partition (instead of an 8-byte memory location). The DBMS selects a fraction of the txn to monitor at runtime. Because hot tuples are by definition accessed more frequently and thus more likely to be updated in the LRU chain. The rate at which transactions are sampled can be tuned by a parameter - 0 &amp;lt; \alpha &amp;lt; 1. Some tables can be specifically marked as evictable during schema creation. Any table not marked as evictable will not be maintained in the LRU chain and will remain entirely in memory.&lt;/p&gt;

&lt;h3 id=&quot;block-retrieval&quot;&gt;Block Retrieval&lt;/h3&gt;

&lt;p&gt;The system first issues a non-blocking read to retrieve the blocks from disk. This allows other transaction to continue while block is being read off the disk. Any transaction that attempts to read an evicted tuple in these blocks is aborted while it is still on disk. Once the requested blocks are retrieved, the aborted transaction(s) is rescheduled. Before it starts, the DBMS performs a “stop-and-copy” operation whereby all transactions are blocked at that partition while the unevicted tuples are merged from the staging buffer into the regular table storage. Then removes all of th entries for these tuples in the evicted table and then updates the table’s indexes to point to the real tuples. We may merge either the whole block (Block-Merging) or just the tuples needed (Tuple-Merging).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Block Merging&lt;/strong&gt;: Merge all the tuples from the retrieved block into memory, may add tuples that won’t ever be needed by transactions. This can either lead to continuous un-eviction/re-eviction cycles (and be detrimental) or can cause tuples that may eventually be needed anyway ( and avoid more stop-load-merge operations).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tuple-Merging&lt;/strong&gt;: Only merge the tuples that are necessary for the transaction. Once the desired tuples are merged, the fetched block is discarded. THis can lead to a lot of wasted effort if only a small number of tuples are merged and subsequent transactions cause the same set of blocks to be loaded and reloaded. This can lead to holes in the Evicted blocks which should be &lt;em&gt;compacted lazily&lt;/em&gt; using some lazy block compaction algorithm during the merge process.&lt;/p&gt;

&lt;h3 id=&quot;distributed-transactions&quot;&gt;Distributed Transactions&lt;/h3&gt;

&lt;p&gt;H-Store will switch a distributed txn into the “pre-pass” mode just as a single partition txn when it attempts to access evicted tuples at any one of its partition. The txn is aborted and not requeued until it receives a notification that all of the blocks that it needs have been retrieved from the nodes in the cluster.&lt;/p&gt;

&lt;h3 id=&quot;snapshots--recovery&quot;&gt;Snapshots &amp;amp; Recovery&lt;/h3&gt;

&lt;p&gt;In main-memory DBMS, we use snapshots and command logging [22, 29] are used. The DBMS serializes all the contents of the regular tables and index data, as well as the contents of the Evicted Table, and writes it to disk. At the same time, the DBMS also makes a copy of the Block Table on disk as it existed when the snapshot began. No evictions are allowed to occur while the snapshotting is in progress.
To recover from a crash, the DBMS loads the last snapshot from disk, then replays the txns from the command log that were created after this snapshot was taken.&lt;/p&gt;

&lt;p&gt;To keep the size of snapshots small, the DBMS takes &lt;strong&gt;delta snapshots&lt;/strong&gt;. These delta-snapshots may be collapsed at regular intervals to avoid keeping a large number of deltas.&lt;/p&gt;

&lt;h2 id=&quot;results--evaluation&quot;&gt;Results / Evaluation&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;For highly-skewed workloads ( workloads with skews of 1.5 and 2.5 ) the anti-caching architecture outperforms MySQL by a factor of 9x for readonly, 18x for read-heavy and 10x on write-heavy workloads for datasets 8x memory.&lt;/li&gt;
  &lt;li&gt;For hybrid MySQL + memcached architecture, by a factor of 2x for read-only, 4x for read-heavy and 9x for write-heavy workloads for 8x memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The lower performance for workloads in hybrid-MySQL architecture is due to the overhead of synchronizing values in Memcached and in MySQL in event of a write. For lower skew, there is a high cost of cache miss in this hybrid architecture.&lt;/p&gt;
</description>
        <pubDate>Sun, 01 Jun 2014 00:00:00 +0000</pubDate>
        <link>https://ankurcha.github.io/malloc64/malloc64/paper/databases/vldb/2014/06/01/paper-anti-caching/</link>
        <guid isPermaLink="true">https://ankurcha.github.io/malloc64/malloc64/paper/databases/vldb/2014/06/01/paper-anti-caching/</guid>
      </item>
    
      <item>
        <title>No one needs to know that ...</title>
        <description>&lt;p&gt;So, recently (more like yesterday), I was chatting with a person who I don’t really know. So without thinking a lot about it, I said hi. Now, I am not a very verbose person and my abilities of actually catching social queues is, well, let’s just say are not very polished. In any case, this person went on to point out how I have been quite inconsistent with my blog and haven’t posted anything in quite some time. This got me thinking and as this person is into the marketing side of things, so they do possibly have a different outlook on things and it might be very interesting to talk to them on the same topics I think about, I asked about their blog and something that they have written.&lt;/p&gt;

&lt;p&gt;Now, Back to the original topic.
I assume, at this point, that I need to be a little more regular. So, I asked what archie’s blog looks like and the thing to which I got pointed to (and I will refrain from putting a link here!) is well, let’s just say, is nothing but a brain fart/vomit.&lt;/p&gt;

&lt;p&gt;The blog was just a continuous stream of cat pictures and spotify music posts. Now, I might not be a big editor or some scholar in creative writing, but even I can tell that this blog is of no consequence to anyone/anything.&lt;/p&gt;

&lt;p&gt;This brought me to a very important observation about our generation’s obsession with divulging every single detail of our lives. Most of the things that we do are NOT gems of our civilization and quite frankly is not something that you or for that matter anyone needs to share/know about. 
No one, I think, is bothered with how you got yourself out of the bed in the morning or how bad your nail painting abilities are or how cute your cat looks sleeping for the 500th time.&lt;/p&gt;

&lt;p&gt;Sharing is one thing that we have somehow compeletely got out of whack. The idea behind this might be pretty simple, so, for a minute, rewind back to the stone age where the caveman lived pretty much exposed and survived primarily because the herd stuck together.&lt;/p&gt;

&lt;p&gt;As a caveman, I shared my bison meat with others and others shared the fruits they forraged with me. In a similar way, the cavemen shared their knowledge, where to hunt, where to get food, places to stay away from and predators. Now, if I was to waste everyone’s time with grunts about how I threw a stone on a duck and an egg came out, it might be funny at first and maybe even a good pick-up grunt at a cave-party (yea! I said it!). But sooner or later, someone will club me in the face.&lt;/p&gt;

&lt;p&gt;Now, let me be clear, by no means, I am a hermit. I just think that there needs to be some form of personal accountability about what we share. Social media has made the world a closely knit and smaller place. People living across the street are almost the same as the ones living half way across the globe. This would be unthinkable even 10 years ago. The world economies have evolved around this concept and continues to do so. Newer areas of research have emerged, this has allowed us to tap into newer avenues of collaboration. We have seen revolutions being reported, a new era of journalism rise to power and more accountability arise from this. Heck, I myself owe my bread and butter to this very concept.&lt;/p&gt;

&lt;p&gt;But it makes me sad, yes actually sad, when I hear that people are now wasting (yes I do mean waste in the cores sense of the word) their time in front of a screen, oogling at senseless posts on facebook and twitter about how much one of your acquaintances just loves hershey’s kisses. A relief, once in a while, is fine. It lets us connect with other people on a personal level (which, is just foo-bar to my brain). It informs us and connects us to the human race. But, that’s where we get carried away.&lt;/p&gt;

&lt;p&gt;People overshare and then regret it. We hear about cyber stalkers or companies who find out the stupid things that people shared on their &lt;strong&gt;public&lt;/strong&gt; facebook pages without thinking. Followed by people getting mad at service providers for sharing information, to actually do their job (and dare I point out, you agreed to the T&amp;amp;C). It just makes my jaw drop at the stupidity of people.&lt;/p&gt;

&lt;p&gt;How dumb do you need to be? If you don’t want something online, don’t put it there! period. It’s as simple as that. I have learnt this simple fact over the last two and a half decades of my existance. The human brian is a really good optimization engine. You give it any scenario, it will work it out and share and collaborate with others and process information to give you the best possible way of doing the task. Failing to do something is just it’s way of working out the problem.&lt;/p&gt;

&lt;p&gt;If you apply this same strategy to stalkers and employers they are just optimizing, in a way, to know their target (obsessively) or reducing risk of the new employee being a business risk.&lt;/p&gt;

&lt;p&gt;To end this, rather poorly structured post, I would just like to say that I don’t intend to come off as a person who is overly paranoid. But we live in a time where everything has more impact than you thought. Technologies are advancing much faster than we can take stock of. It is very possible to cross reference anything with anything else if one has the time and patience. One migth be bold enough to propose that the surgeon general may mandate a warning to sent with every new internet bill saying “Sharing and surfing on the internet may pose a serious health risk.” Though that might be a little over the top ;)&lt;/p&gt;

&lt;p&gt;PS: Archie* here you go! I updated my blog and now you have a piece of my mind on something for you to ruminate upon.&lt;/p&gt;
</description>
        <pubDate>Fri, 29 Nov 2013 00:00:00 +0000</pubDate>
        <link>https://ankurcha.github.io/malloc64/malloc64/reflection/thoughts/2013/11/29/no-one-needs-to-know-that/</link>
        <guid isPermaLink="true">https://ankurcha.github.io/malloc64/malloc64/reflection/thoughts/2013/11/29/no-one-needs-to-know-that/</guid>
      </item>
    
      <item>
        <title>Spark Summit 2013 notes</title>
        <description>&lt;h1 id=&quot;keynote-by-matei-zaharia&quot;&gt;Keynote by Matei Zaharia&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Spark is now one of the largest big data products out there surpassing hadoop in the number of active contributors in the last 6 months.&lt;/li&gt;
  &lt;li&gt;Has more contributors than Storm, Giraph, Dril and Tez combined.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;spark-081-will-have&quot;&gt;Spark 0.8.1 will have&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;MLlib - machine learning algorithms out of the box.&lt;/li&gt;
  &lt;li&gt;YARN 2.2 resource manager support&lt;/li&gt;
  &lt;li&gt;codahale metrics based metrics reporting and a new monitoring UI&lt;/li&gt;
  &lt;li&gt;Spark stream comes out of alpha and will be stabilized&lt;/li&gt;
  &lt;li&gt;Shark imporovements&lt;/li&gt;
  &lt;li&gt;EC2 support&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;other-contributions&quot;&gt;Other contributions&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;YARN support - Yahoo&lt;/li&gt;
  &lt;li&gt;Columnar compression of data - Yahoo&lt;/li&gt;
  &lt;li&gt;Metrics reporting - Quantifind&lt;/li&gt;
  &lt;li&gt;Fair scheduling and code generation optimization - Intel&lt;/li&gt;
  &lt;li&gt;New RDD operators&lt;/li&gt;
  &lt;li&gt;scala 2.10 support  (finally!)&lt;/li&gt;
  &lt;li&gt;Master HA&lt;/li&gt;
  &lt;li&gt;External hashing and sorting (0.9 release)&lt;/li&gt;
  &lt;li&gt;Better support for large number of tasks&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;current-priorities&quot;&gt;Current priorities&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Standardise libraries&lt;/li&gt;
  &lt;li&gt;Deployment ease/automation&lt;/li&gt;
  &lt;li&gt;Out of the box usability - better defaults and configuration system&lt;/li&gt;
  &lt;li&gt;Enterprise support provided by Cloudera &amp;amp; Databrix&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Spark Streaming and Shark will be optimised for 24/7 operation and will get other performance imporvements&lt;/p&gt;

&lt;p&gt;SIMR - Will be released soon: Provides a seamless way to run spark as a regular hadoop job (it’s not production ready just yet)
  * Recommended to upgrade to hadoop 2.2&lt;/p&gt;

&lt;p&gt;In terms of raw performance Spark/Shark is comparable to Apache Impala&lt;/p&gt;

&lt;p&gt;Time spent is generally as follows&lt;/p&gt;

&lt;p&gt;90% time is spent just reading and writing in Hadoop&lt;/p&gt;

&lt;p&gt;Int spark and other in memory systems, the data is loaded just once and all subsequent operations are performed on it&lt;/p&gt;

&lt;p&gt;What happens when data does not fit in memory?
  * Spark manages swapping data as it is needed
Scale up vs scale out?
  *Depends on application and requires looking at the workload but given the ability to use spot instances, it is preferable to scale out and increase parallelism.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Value from Data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Questions:&lt;/strong&gt;
     * Insights, diagnosis
          - Why is X happening?
     * Decision support
          - How do I do X?
          - What do I do to make X better?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solutions:&lt;/strong&gt;
     * Interactive queries
     * Streaming queries
     * Sophisticated data processing (in time)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenge #1&lt;/strong&gt;: need to maintain 3 stacks - expensive and difficult to make consistent&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenge #2&lt;/strong&gt;: hard/slow to share data and code&lt;/p&gt;

&lt;p&gt;Spark helps in both areas by allowing for the same effort to be utilised for both batch and streaming with minimal change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Analogy:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unification of technologies&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;* Step 1: first cellular phone                        --- hadoop/batch processing
* Step 2: specialized devices (mp3 player, gps, pda)  --- storm, mahout, specialised systems
* Step 3: unification (iphone or smartphones)         --- spark (others also there but not as mature)
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
  &lt;li&gt;Unified realtime and historical data analysis&lt;/li&gt;
  &lt;li&gt;Unified streaming, historical &amp;amp; predictive analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why streaming ML?
  * fraud detection
  * decision support
  * trend change
  * no point in suggesting a product a day later&lt;/p&gt;

&lt;p&gt;Enterprise support by
  * Databrix
  * Cloudera
  * Wandisco
  * Tuplejump&lt;/p&gt;

&lt;p&gt;BlinkDB will soon go out of alpha and reach stability
  * Better HIVEQL operator support
  * Performance improvements
  * Interesting numbers on conviva datasets&lt;/p&gt;

&lt;p&gt;CrowdDB - SQL to Crowdsourcing answers (SIGMOD 2011)&lt;/p&gt;

&lt;h1 id=&quot;hadoop-and-spark-join-forces-at-yahoo&quot;&gt;Hadoop and Spark join forces at Yahoo&lt;/h1&gt;

&lt;p&gt;Pre-2012 - Editors’ decisions drive the yahoo homepage&lt;/p&gt;

&lt;p&gt;2012 - data driven editorial decisions for homepage&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;ML driven suggestions&lt;/li&gt;
  &lt;li&gt;Per user customisation&lt;/li&gt;
  &lt;li&gt;instantly saw 300% increase in engagement&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2013 - Personalised homepage&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;All parts are personalised, tracked, trained&lt;/li&gt;
  &lt;li&gt;Personalised mobile experience&lt;/li&gt;
  &lt;li&gt;Personalised properties = websearch + vertical content, deep search -&amp;gt; video, maps, weather when you search&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Data Science @ scale requires ability to do quick turnaround discovery&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Challenge #1: Science&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;Single model for all items in homepage stream&lt;/li&gt;
      &lt;li&gt;millions of items&lt;/li&gt;
      &lt;li&gt;thousands of item/user features
        &lt;ul&gt;
          &lt;li&gt;categories&lt;/li&gt;
          &lt;li&gt;wikipedia entity names&lt;/li&gt;
          &lt;li&gt;Objective function
            &lt;ul&gt;
              &lt;li&gt;Relevance / User engagement&lt;/li&gt;
              &lt;li&gt;Freshness / popularity&lt;/li&gt;
              &lt;li&gt;Diversity&lt;/li&gt;
              &lt;li&gt;Algorithm exploration
                &lt;ul&gt;
                  &lt;li&gt;Logistic regression&lt;/li&gt;
                  &lt;li&gt;Collaborative filtering&lt;/li&gt;
                  &lt;li&gt;Decision trees&lt;/li&gt;
                  &lt;li&gt;Hybrid&lt;/li&gt;
                &lt;/ul&gt;
              &lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Challenge#2: Speed&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;Freshness is very important
        &lt;ul&gt;
          &lt;li&gt;Surface relevant results while they are still relevant&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Challenge #3: Scale&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;150 PB of data on hadoop
        &lt;ul&gt;
          &lt;li&gt;data for model building and BI analytics&lt;/li&gt;
          &lt;li&gt;Avoid latency&lt;/li&gt;
          &lt;li&gt;hours of latency is not acceptable&lt;/li&gt;
          &lt;li&gt;35,000 baremetal hadoop cluster&lt;/li&gt;
          &lt;li&gt;Store all data on a giant netapp based nfs store&lt;/li&gt;
          &lt;li&gt;different log sources continuously ship data&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;
  - Hadoop + Spark
  - Hadoop is and will be the core for doing most of the heavy lifting
  - Spark for iterative research and queries of most of the processed data
  - Both running in the same cluster
  - YARN brings hadoop datasets and servers at scientists’ disposal&lt;/p&gt;

&lt;p&gt;Projects that are using spark:
  - Collaborative filtering
  - Ecommerce 
    - viewed-also-viewed
    - bought-also-bought
    - bought-after-bought&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Huge speedup = 14 minutes vs 106 minutes&lt;/li&gt;
  &lt;li&gt;Stream Ads&lt;/li&gt;
  &lt;li&gt;Logistic regression algorithm implements
    &lt;ul&gt;
      &lt;li&gt;120 LOC in scala/spark - much easier to manage vowpal/wabbi&lt;/li&gt;
      &lt;li&gt;30 mins for 100M samples with 13K features and 30 iterations&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;0 to production experiments - 2 hours turnaround - Big win for experimentation and hypothesis validation.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Slides have diagrams of the architecture used by Yahoo teams
- Standalone mode
  - YARN manages master and workers
- Client mode
  - YARN manages only workers&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Future contributions
    &lt;ul&gt;
      &lt;li&gt;Dynamic resource allocation&lt;/li&gt;
      &lt;li&gt;Generic history server&lt;/li&gt;
      &lt;li&gt;Preemption&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Old Architecture&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Logs collection to huge NFS storage&lt;/li&gt;
  &lt;li&gt;Logs moved to hdfs&lt;/li&gt;
  &lt;li&gt;PIG/MR ETL processes - massive joins&lt;/li&gt;
  &lt;li&gt;Aggregations and pre-determined reports&lt;/li&gt;
  &lt;li&gt;Load data into DBMS&lt;/li&gt;
  &lt;li&gt;UI/API on top&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Problems:&lt;/strong&gt;
  - massive data volumes - many TBs
  - Pure hadoop throughput
  - Report latency is high
  - Culprit:
    - Row data processing through MR is slow (IO)
  - Many chained stages - IO 
  - massive joins
  - lack of interactive dsl
  - expressibility of business logic as MR is difficult&lt;/p&gt;

&lt;p&gt;Aggregates pre-computation problems
  - Pre-calculated reports
  - counting distincts
  - Number of reports along dimensions
    - datacubes are just huge&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;hadoop is not built for this&lt;/strong&gt;
  - No way to do data discovery
  - need a data workbench for BI&lt;/p&gt;

&lt;p&gt;Most spark clusters are “small” and hand managed
  - 9.2 TB of addressable RAM
  - 96GB/192GB RAM per machine
  - Tableau interface to shark (OLAP)
  - overlap analysis
  - time series analysis
  - construct cubes offline and use them for fast analysis (MOLAP and HOLAP)
  - column pruning (in shark)
  - map side joins (in shark)
  - cached table compression (in shark)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Satellite cluster pattern or per-team cluster on the same underlying data&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;making-spark-fly-creating-an-elastic-spark-cluster-on-amazon-emr&quot;&gt;Making Spark Fly: Creating an elastic Spark cluster on Amazon EMR&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;EMR integrates directly with all other amazon services seamlessly (*kinesis)&lt;/li&gt;
  &lt;li&gt;Aggressively use spot instances to get all the processing done with the excess capacity when prices drop.&lt;/li&gt;
  &lt;li&gt;Task nodes can be added and removed whereas core nodes can only be added.
    &lt;ul&gt;
      &lt;li&gt;Use task nodes as spot instances (scalable workers) and use core nodes for a basic set of available workers at all times&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Spark installed as a part of a bootstrap script&lt;/li&gt;
  &lt;li&gt;1 TB memory cluster using spot prices can be very cheap.
    &lt;ul&gt;
      &lt;li&gt;63 x m1.xlarge = $4.44/hr vs $30/hr on demand&lt;/li&gt;
      &lt;li&gt;6 x  cc2.8xlarge = $4.64/hr&lt;/li&gt;
      &lt;li&gt;15 x m2.4xlarge - $2.25/hr&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Use ssd+ram for extra credit&lt;/li&gt;
  &lt;li&gt;Autoscaling spark
    &lt;ul&gt;
      &lt;li&gt;Using cloudwatch metrics
        &lt;ul&gt;
          &lt;li&gt;define metrics as&lt;/li&gt;
          &lt;li&gt;CPU and memory (probably scale up/down on both)&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Pick a good set of thresholds for “TotalLoad”&lt;/li&gt;
      &lt;li&gt;Spark 0.8.1 will provide cluster metrics that can also be used for scaling&lt;/li&gt;
      &lt;li&gt;Look up CloudwatchMetricsSink&lt;/li&gt;
      &lt;li&gt;When new nodes join the cluster the data is not eagerly rebalanced, but if tasks would get scheduled to them and they will eventually get used.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Kinesis integration with sparkstreaming
    &lt;ul&gt;
      &lt;li&gt;Kinesis is just like kafka&lt;/li&gt;
      &lt;li&gt;Upcoming KinesisReceiver using NetworkReceivers ( where to get this?)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;C3 and i2 instance will be awesome!&lt;/li&gt;
  &lt;li&gt;Use placement groups and fetch data from S3 to local hdfs when working with it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;simr&quot;&gt;SIMR&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Wraps spark as a normal hadoop job so that you can run it on an existing cluster&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;flint---deploying-bdas-on-aws-adobe&quot;&gt;FLINT - Deploying BDAs on AWS (Adobe)&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Shared nothing management&lt;/li&gt;
  &lt;li&gt;Use simpleDB and S3 to manage all state&lt;/li&gt;
  &lt;li&gt;Efficient and scalable&lt;/li&gt;
  &lt;li&gt;Access to all tools&lt;/li&gt;
  &lt;li&gt;Pending open source&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;adatao---r-and-python-with-nlp-over-spark&quot;&gt;ADATAO - R and Python with NLP over spark&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Use R and Python with spark&lt;/li&gt;
  &lt;li&gt;Seamlessly translates R to spark&lt;/li&gt;
  &lt;li&gt;Use Cases
    &lt;ul&gt;
      &lt;li&gt;BI&lt;/li&gt;
      &lt;li&gt;Adhoc business query&lt;/li&gt;
      &lt;li&gt;Sensor network analytics&lt;/li&gt;
      &lt;li&gt;Ad networks&lt;/li&gt;
      &lt;li&gt;MLLib + Rest API&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;tuplejump&quot;&gt;TupleJump&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Ubercube - distributed olap cube over spark and cassandra&lt;/li&gt;
  &lt;li&gt;Indexes for cassandra&lt;/li&gt;
  &lt;li&gt;Analytics s/w using spark&lt;/li&gt;
  &lt;li&gt;SnapFS&lt;/li&gt;
  &lt;li&gt;Calliope
    &lt;ul&gt;
      &lt;li&gt;R/W data with cassandra&lt;/li&gt;
      &lt;li&gt;Shark + calliope
        &lt;ul&gt;
          &lt;li&gt;builtin indexing (clustered)&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Stargate&lt;/li&gt;
      &lt;li&gt;Hydra: Common bus for messages&lt;/li&gt;
      &lt;li&gt;Ops center&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;realtime-analytics-processing---intel&quot;&gt;Realtime analytics processing - Intel&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Alibaba, youku, baidu&lt;/li&gt;
  &lt;li&gt;Value ?
    &lt;ul&gt;
      &lt;li&gt;descriptive analytics - SQL&lt;/li&gt;
      &lt;li&gt;predictive analytics - non-SQL&lt;/li&gt;
      &lt;li&gt;interactive&lt;/li&gt;
      &lt;li&gt;streaming/online&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;A series of mini batch jobs that flush aggregations to rdbms at regular intervals&lt;/li&gt;
  &lt;li&gt;colocate kafka and a spark worker
    &lt;ul&gt;
      &lt;li&gt;log collection is bottlenecked by n/w&lt;/li&gt;
      &lt;li&gt;processing is bottlenecked by cpu and mem
        &lt;ul&gt;
          &lt;li&gt;use memory_only_ser2
            &lt;ul&gt;
              &lt;li&gt;tune spark.cleaner.ttl [ throughput*spark.cleaner.ttl &amp;lt; memory ]&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Don’t be scared to add columns, let shark worry about that&lt;/li&gt;
      &lt;li&gt;Complex machine learning
        &lt;ul&gt;
          &lt;li&gt;mostly matrix/graph analysis&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;sparrow---next-gen-spark-scheduling&quot;&gt;Sparrow - Next-Gen spark scheduling&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Current scheduler is not so good when jobs are very short
    &lt;ul&gt;
      &lt;li&gt;most of the time spent waiting in queue to be assigned to a worker.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Current scheduler bottlenecked at about 1500 tasks/sec
    &lt;ul&gt;
      &lt;li&gt;bad for big clusters with small tasks&lt;/li&gt;
      &lt;li&gt;Scheduler delay gives an estimate of amount of time spent in scheduler queue&lt;/li&gt;
      &lt;li&gt;Use: Batch sampling + Late binding&lt;/li&gt;
      &lt;li&gt;https://www.github.com/radlab/sparrow&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;spark-as-a-service---ooyala&quot;&gt;Spark as a Service - OOYALA&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;raw events in cassandra&lt;/li&gt;
  &lt;li&gt;spark job server&lt;/li&gt;
  &lt;li&gt;anyone can submit a job&lt;/li&gt;
  &lt;li&gt;available as a service to avoid rebuilding the universe over and over
    &lt;ul&gt;
      &lt;li&gt;REST API
        &lt;ul&gt;
          &lt;li&gt;contexts
            &lt;ul&gt;
              &lt;li&gt;allows the user to create a context and keep it alive for later use&lt;/li&gt;
              &lt;li&gt;low latency query now possible&lt;/li&gt;
              &lt;li&gt;submit subsequent querries with &lt;code&gt;&amp;amp;context=&amp;lt;id&amp;gt;&lt;/code&gt; to run in an existing context&lt;/li&gt;
              &lt;li&gt;async and sync requests also possible&lt;/li&gt;
              &lt;li&gt;challenges/lessons
                &lt;ul&gt;
                  &lt;li&gt;spark is based on contexts&lt;/li&gt;
                  &lt;li&gt;we need a manager ( as contexts may take multiple seconds to come up and allocate lots of threads)&lt;/li&gt;
                &lt;/ul&gt;
              &lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Opensource and Currently a pull request&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;spark-streaming&quot;&gt;Spark streaming&lt;/h1&gt;
&lt;ul&gt;
  &lt;li&gt;Many environments require processing same data in live and as batch
    &lt;ul&gt;
      &lt;li&gt;no single framework does this&lt;/li&gt;
      &lt;li&gt;Traditionally, stateful event processing
        &lt;ul&gt;
          &lt;li&gt;each node has mutable state that is synchronized regularly with others&lt;/li&gt;
          &lt;li&gt;prone to loss of data when node is lost&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Storm
    &lt;ul&gt;
      &lt;li&gt;atleast once&lt;/li&gt;
      &lt;li&gt;gets slow&lt;/li&gt;
      &lt;li&gt;Trident - adds transactions by using external db (slows down further and adds external dependency/hell)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Built on RDDs
    &lt;ul&gt;
      &lt;li&gt;divides stream into small deterministic batches (up to 0.5 sec each) with lineage&lt;/li&gt;
      &lt;li&gt;code looks and feels same as the batch system code&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Window based transformations
    &lt;ul&gt;
      &lt;li&gt;window ( length of window, frequency)&lt;/li&gt;
      &lt;li&gt;updateByKey( updateFunction, Key)&lt;/li&gt;
      &lt;li&gt;transform
        &lt;ul&gt;
          &lt;li&gt;allows us to combine historical/regular RDDs with streaming&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Applications
        &lt;ul&gt;
          &lt;li&gt;online ML&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;combine live and historical data&lt;/li&gt;
      &lt;li&gt;CEP style processing (http://en.wikipedia.org/wiki/Event-driven_architecture)&lt;/li&gt;
      &lt;li&gt;Data sources
        &lt;ul&gt;
          &lt;li&gt;kafk, hdfs, flume, akka actors, raw tcp&lt;/li&gt;
          &lt;li&gt;easy to write new receiver&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Fault tolerance
        &lt;ul&gt;
          &lt;li&gt;Batches of input data are replicated&lt;/li&gt;
          &lt;li&gt;data lost due to worker is recomputed from lineage
            &lt;ul&gt;
              &lt;li&gt;how long is the data kept? - uses LRU (0.9 - active throwaway)&lt;/li&gt;
              &lt;li&gt;spark 0.9 will have&lt;/li&gt;
              &lt;li&gt;automated master failure recovery&lt;/li&gt;
              &lt;li&gt;perf improvement&lt;/li&gt;
              &lt;li&gt;better monitoring/UI for streaming specifically&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Long term goals
        &lt;ul&gt;
          &lt;li&gt;MLlib for streaming&lt;/li&gt;
          &lt;li&gt;shark for streaming&lt;/li&gt;
          &lt;li&gt;python api&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Slides: &lt;a href=&quot;http://spark-summit.org/agenda/&quot;&gt;http://spark-summit.org/agenda/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hand notes: &lt;a href=&quot;http://www.flickr.com/photos/ankurc/sets/72157638371848076/&quot;&gt;Flickr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note 1:&lt;/strong&gt; As it goes without saying, all the information in this post is what &lt;strong&gt;I&lt;/strong&gt; understood during the conference and whatever i could remember while writing stuff down.
There is a possibility that I got something wrong, if that is the case please let me know and I’ll be happy to make the changes.&lt;/p&gt;
</description>
        <pubDate>Sun, 12 May 2013 00:00:00 +0000</pubDate>
        <link>https://ankurcha.github.io/malloc64/malloc64/spark/summit/conference/notes/2013/05/12/spark-summit-2013-notes/</link>
        <guid isPermaLink="true">https://ankurcha.github.io/malloc64/malloc64/spark/summit/conference/notes/2013/05/12/spark-summit-2013-notes/</guid>
      </item>
    
      <item>
        <title>Virtualised Brian - A thought experiment</title>
        <description>&lt;p&gt;What would it mean if we could combine the concepts of &lt;a href=&quot;http://en.wikipedia.org/wiki/Virtualization&quot;&gt;Virtualisation&lt;/a&gt; and the &lt;a href=&quot;http://en.wikipedia.org/wiki/Human_brain&quot;&gt;Brain&lt;/a&gt;? What would be the possible? A couple of days ago at lunch with &lt;strong&gt;&lt;a href=&quot;http://www.linkedin.com/in/philion&quot;&gt;Paul&lt;/a&gt;&lt;/strong&gt;, I thought about this and lets see where we ended up.&lt;/p&gt;

&lt;h2 id=&quot;assumptions&quot;&gt;Assumptions&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;The scene is set in a distant future.&lt;/li&gt;
  &lt;li&gt;Evolution has not imparted increased brain utilization.&lt;/li&gt;
  &lt;li&gt;During sleep or people who are not using their brains or people with death sentence or life imprisonment or other long term imprisonment (Ethical issues aside) may be put into a “base functions only” state.&lt;/li&gt;
  &lt;li&gt;The “suspended” brain only needs a fraction of its total capacity (in addition to the brain stem and the spine) to manage life supporting body functions.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Important&lt;/strong&gt;: Humans have found a way to “install” a Xen/KVM like virtualization layer into brains.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;basics&quot;&gt;Basics&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Brain&lt;/strong&gt;, is the key organ of every human being. Although the human brain represents only 2% of the body weight, it receives 15% of the cardiac output, 20% of total body oxygen consumption, and 25% of total body glucose utilization. This complex organ is responsible for all the advancements we see today.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtualisation&lt;/strong&gt; technoloies such as KVM and Xen have revolutionized computing and are a cornerstone to cloud computing. There are different forms of virtualization(complete, partial or para virtualization) but in any form it is a big step forward.&lt;/p&gt;

&lt;p&gt;Given the current virtualisation architectures (such as the ones used by Amazon, Google and other opensource project such as KVM and XEN), there is a host systems which is Dom0 and is the one that provides the guest consciousness(maybe multiple) with access to the underlying wetware. This is an important bit, we want the host to have some elevated access level in terms of being able to manage the other brain instances (referred to as “instances” from now on). This way in case we have a requirement of having to shutdown/revoke access/bill brain power the Dom0 instance is the one which does this.&lt;/p&gt;

&lt;h2 id=&quot;details&quot;&gt;Details&lt;/h2&gt;
&lt;p&gt;The Dom0 here is pretty thing and is the instance which is closest to the the wetware. It provides the other instances with networking (ability to connect to the wet-ware internet), on demand computing resource (how much of the brain capacity are we allocating to this instance), billing subsystem (if we are doing this I suppose we want to do some form of accounting on the usage).&lt;/p&gt;

&lt;h2 id=&quot;networking&quot;&gt;Networking&lt;/h2&gt;
&lt;p&gt;I propose that the host body is connected to a sort of an internet via some non-surgically attached means. Something like some sort of headgear which allows for high bandwidth connection to the outside world. From what I understand (and I am not a neurosurgeon), this may require a one time interface implant. Which can be controlled via thought and a physical hardware switch - You always want a big red button on the back of your head which shuts down the virtualized brains.&lt;/p&gt;

&lt;p&gt;The different instances within the brain would communicate over the different neurological pathways already existing inside the brain. The only thing which I can see as the bottle neck is the &lt;a href=&quot;http://en.wikipedia.org/wiki/Corpus_callosum&quot;&gt;corpus callosum&lt;/a&gt;. This is a part which is like a narrow bridge inside each of our brains. My point is, the inter-hemisphere communication would be slower than the intra-hemisphere communication and the slowest one would be inter-brain communication.&lt;/p&gt;

&lt;h2 id=&quot;compute-resources&quot;&gt;Compute resources&lt;/h2&gt;
&lt;p&gt;This is the real thing that we are supporting, having virtually unlimited amount of brain power for on-demand use is the biggest thing. It would let the human race jump atleast 2-3 orders of magnitude in terms of innovation ability. My assumption is that, the current rate of scientific or progress in other fields limited by the amount of “thinking” which people in these fields can do at a time. If a brain virtualization was available and if we tought ourselves to package and construct thoughts in a way such that they can be run a compute jobs or more like programs, scientists could potentially think continuously and work out hundreds or millions of thoughts in parallel, eliminate the bad ones in a single day which would otherwise take years.&lt;/p&gt;

&lt;h3 id=&quot;types-of-compute-resources&quot;&gt;Types of compute resources&lt;/h3&gt;
&lt;p&gt;As far as I know/understand the human brain’s parts are fundamentally different in terms of the kind of work/computation that they can perform. Hence, we could serve two kinds of resource types.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Left brain instances&lt;/strong&gt;: numerical computation (exact calculation, numerical comparison, estimation), direct fact retrieval, grammar/vocabulary and literal functions.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Right brian instances&lt;/strong&gt;: numerical computation (approximate calculation, numerical comparison, estimation), intonation/accentuation, prosody, pragmatic and contextual functions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In adddition to the basic brain functions, there may also be somehigher level specialized brian “abilities”. Certain brains are proficient in certain abilities. Let’s say a brain  which provides “Calculus abilities” so that calculus is a basic and high performant capability so that if a scientist needs to perform some complex math, she/he could get a specialized “calculus brain” which would be able to perform integral/differential calculus with much higher efficiency when compared to a “basic brain”. This does not mean that a the “basic brain” is any less capable of performing calculation but just that the neural pathways for doing these functions would be slower and less performant by an order of magnitude.&lt;/p&gt;

&lt;p&gt;This means, there is an absolute incentive to learning more and diverse things, at the same time, specializing in certain fields would make certain attributes a basic capability of your brain. I draw these assumption from personal experience, ater years of math and computer science, I can solve certain thoughts almost natively i.e. I don’t have to think much when I look at an algorithm and try to figure out the algorithmic complexity or maybe when I need to calculate powers of 2 or a simple/medium level calculus problem.&lt;/p&gt;

&lt;h3 id=&quot;thinking-workflow-reimagined&quot;&gt;Thinking workflow reimagined&lt;/h3&gt;
&lt;p&gt;The new thought process would probably be something like this:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Think of a big new idea.&lt;/li&gt;
  &lt;li&gt;Figure out different parts of the idea, the different thought components involved.&lt;/li&gt;
  &lt;li&gt;Reserve instances of the instances that you may need to reason each of these thoughts.&lt;/li&gt;
  &lt;li&gt;Send thought “jobs” to these remote instances over some wetware communcation media/network for processing and contemplation.&lt;/li&gt;
  &lt;li&gt;Watch the brain cluster for failures and re-initiate thoughts for which the brain instances got terminated.&lt;/li&gt;
  &lt;li&gt;Get processed results back from instances as they complete.&lt;/li&gt;
  &lt;li&gt;Repeat till desired result is obtained or you give up.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now where does this take us, we have at our disposal, unlimited brain power. Now given that you can yourself virtualize your own brain in case your original brain gets tired, you could background your thoughts, send them to another instance, sleep or get some down time and later retrieve your calculated/processed thoughts.&lt;/p&gt;

&lt;p&gt;With such technology humans would stop being isolated beings and would become more like hive consciousness beings.&lt;/p&gt;

&lt;p&gt;What does this mean to people who give out resources? When you sleep or are just not using your brain you can “rent out” your brain, wake up and continue where you left off. In case you need more computation resources, terminate the guest instances and reclaim some more local resources.&lt;/p&gt;

&lt;h2 id=&quot;brain-resource-management-and-billing&quot;&gt;Brain Resource management and billing&lt;/h2&gt;
&lt;p&gt;The natural question here is what about the usual management of your own brain resources. Maybe you just feel tired or want to go on vacation and not have anything running in your brain except you. Being Dom0 or the host consciousness you have additional control over the capabilities of your resources. This allows you to suspend or maybe completely disconnect the brain from external entities and hence run in isolation.&lt;/p&gt;

&lt;p&gt;The host may find that some instance has gone astray and misbehaving. This is something that should be caught by either the virtualization layer or something like a monitor process available to the host. This way it can be terminated or in extreme cases, banned completely - I am thinking of API token based access control if OAuth is too heavy-weight. :)&lt;/p&gt;

&lt;p&gt;The other aspect of doing all this may be purely financial. We just want to “sell” brain compute power. Billed by the second or minute or hour, whatever is appropriate. This might be the economy of the real “&lt;em&gt;information age&lt;/em&gt;”.&lt;/p&gt;

&lt;h2 id=&quot;brain-storage&quot;&gt;Brain Storage&lt;/h2&gt;
&lt;p&gt;Now that we have got around to performing computation, we need some way storing the exabytes of thoughts and memories that we would generate, even if they are transient thoughts.&lt;/p&gt;

&lt;p&gt;The virtualization layer may provide access to “brain storage”, which may let a user store and process thoughts which are not constrained by the brian of the person initiating the thought. This is really important if we want the compute resources to be of any use, my hypothesis is that the original thought is probably really small thought so the network utilization for transferring thought is probably very small (A picture or phrase or some other brain wave chatter) but the scratch space requirement to build the thought tree and work through the all different things involved may be really large. Maybe even span beyond the capabilities of a single brain, needing &lt;em&gt;sharding of the thought&lt;/em&gt; across different brians.&lt;/p&gt;

&lt;p&gt;The basic requirement of this storage platform is complete isolation of thoughts. It has to be impossible for any other brain instance or even the host to look at the information/ideas stored by a different user. Something like encrypting the thoughts with some for of encryption and signing it for integrity.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Where are we at the end of this? I believe we are making huge amount of progress in the fields of science and technology and I think this might be just a pipe dream but then so was flying and handheld computers. Having unlimited brain power would change the world in a fundamental way. It would not only push the human race years forward but also make us much closer to each other. The concept of political boundaries would essentially cease to exist. Internet would be a thing of the past (or just a minor subset of the &lt;strong&gt;Cognitive-Net or Cognet&lt;/strong&gt;). Peace would be just a thought that would become natural (I hope) to every human and essential to the continued survival.&lt;/p&gt;
</description>
        <pubDate>Tue, 10 Jul 2012 00:00:00 +0000</pubDate>
        <link>https://ankurcha.github.io/malloc64/malloc64/2012/07/10/thought-experiment-virtualised-brian/</link>
        <guid isPermaLink="true">https://ankurcha.github.io/malloc64/malloc64/2012/07/10/thought-experiment-virtualised-brian/</guid>
      </item>
    
  </channel>
</rss>
