Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 56148 invoked from network); 2 Aug 2010 22:00:07 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Aug 2010 22:00:07 -0000 Received: (qmail 95580 invoked by uid 500); 2 Aug 2010 22:00:07 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 95498 invoked by uid 500); 2 Aug 2010 22:00:06 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 95490 invoked by uid 99); 2 Aug 2010 22:00:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Aug 2010 22:00:06 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mikeal.rogers@gmail.com designates 209.85.214.180 as permitted sender) Received: from [209.85.214.180] (HELO mail-iw0-f180.google.com) (209.85.214.180) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Aug 2010 22:00:01 +0000 Received: by iwn8 with SMTP id 8so6063848iwn.11 for ; Mon, 02 Aug 2010 14:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=Cw5AwfXOyLTcvX6V4Fv2TghJCa4RJR0g+j/JF81lISQ=; b=NMEOvptVay/lZZU8p65GPwJn4jaOg5fhfaoQEaknVQNK+99RAyKQvsOtWu+XKeT8NP Rmp77jG3x2dF5ZG73DfdM9UuyOBmHMIhkyqv6T4fiYl2+TIW+kEXZQE6thri6WwcgA09 9kN6Bn22w6JkJvc+Y7OOnMv1NChMmI83Q5iQk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=L/WhqMC0uJFbixBfo8JhCzveIwZeSFI6ewuuCywuW0Bt5PteMeEoGxQvLIN94khCQk ByJ0ceW+g+VUH3HQzObA4rrLxHaMHc3foLf0cYFMeYfc4g4azGblcl4U/+lP4+O9JtkL SNWT5V2zaxbWsWZYS3emrRQNHVDqBVWZkhxx8= MIME-Version: 1.0 Received: by 10.231.184.16 with SMTP id ci16mr7805825ibb.23.1280786380670; Mon, 02 Aug 2010 14:59:40 -0700 (PDT) Received: by 10.231.186.202 with HTTP; Mon, 2 Aug 2010 14:59:40 -0700 (PDT) In-Reply-To: References: Date: Mon, 2 Aug 2010 14:59:40 -0700 Message-ID: Subject: Re: Proposal for changes in view server/protocol From: Mikeal Rogers To: dev@couchdb.apache.org Content-Type: multipart/alternative; boundary=0016367d6be24186cd048cde512f --0016367d6be24186cd048cde512f Content-Type: text/plain; charset=ISO-8859-1 On Mon, Aug 2, 2010 at 1:11 PM, Paul Davis wrote: > On Mon, Aug 2, 2010 at 2:49 PM, Mikeal Rogers > wrote: > > Back up a few steps. > > > > The view server line protocol while being terribly defined and taking > > breaking changes in almost every release has still maintained a fair > amount > > of alternate implementations in languages other than JavaScript. I > seriously > > doubt that we would see this kind of diverse additions to CouchDB if the > > barrier to integrating was writing erlang. We shouldn't fix fundamental > > problems with the view server protocol and architecture solely by moving > it > > in to erlang. > > Even if we moved to a JS NIF runtime, we should still support the line > protocol so that other languages can be used. Internally it would > require some refactoring, but I think this is completely reasonable. > And the refactoring probably needs to happen regardless. > This makes we far less worried. Thanks for clarifying Paul. > > > I'm also *highly* skeptical of the perceived performance benefits of > moving > > the js in to erlang compared to moving away from full JSON parsing and > just > > doing selective parsing/validation and storing the JSON string as opposed > to > > the native erlang representation. I can write this idea up in greater > detail > > in another thread but the native JSON parser in *any* language is likely > to > > be faster than something that parses the native erlang terms so it's only > > faster on the erlang side to not hit the serialization again which we > would > > get if we stored the string+parsed underscore properties instead of the > full > > native erlang terms. > > I'm also *highly* skeptical that storing the string and selective > parsing is going to do anything but complicate things even further. :D > > I'm not sure what you're comparing the native JSON parser too, but I > can say that parsing Erlang terms is much easier and faster than JSON. > Although, what's even *more* faster, is not using JSON at all. In the > code that runs the NIF stuff I translate directly from Erlang terms to > Spidermonkey objects programattically, so there's zero > serialization/deserialization overhead. I haven't timed this code > against couchjs yet, but I did a similar thing in passing Erlang terms > to the view server and going from the external format to JavaScript > objects directly which gave a noticeable speed up IIRC. It just > happened to add about 1K lines of code that didn't seem like something > I could require of other view implementations. > Definitely, passing Erlang terms will serialize and parse faster than JSON. But selective JSON parsing on write and storing the string means that the amount of times we currently do serialization whatsoever drops. Every time we do a read or send something to the view server we just send that string, pre-serialized strings are faster than JSON or erlang terms :) Although this wasn't clear in my previous email, the selective JSON parsing and js in NIF aren't mutually exclusive. > > > Not to mention the security and durability considerations of moving the > view > > server in to erlang. There is a reason erlang views aren't enable by > > default. > > > > The reason that Erlang isn't enabled by default is because its not > sandbox-able. Or, more specifically, I couldn't figure out how to > sandbox it. JS as a NIF is so sandboxed I still can't figure out how > to make it communicate at all with Erlang without returning to the top > of the stack. > > -Mikeal > > > > > > On Mon, Aug 2, 2010 at 11:39 AM, Jason Smith wrote: > > > >> On Tue, Aug 3, 2010 at 01:35, Randall Leeds > >> wrote: > >> > >> > Either way we're waiting for a response from couch to call back into > >> > JS, it's just whether we're calling the original function or the > >> > continuation. > >> > I don't have a strong preference either way, but I do slightly favor > >> > the callback continuation as a mild style preference. > >> > > >> > >> I have to say, callback style is way nicer. I have not thought about how > >> that would look from non-Javascript query servers though. > >> > >> > >> > In either case, do we have to add some new response format so the > >> > query server can say "Hey call me again and tell me what to do with > >> > this result?" > >> > In other words, both of our suggestions can work on top of the same > >> > change that needs to happen to the view server line protocol, so you > >> > can code up either one and we can settle on what it should look like > >> > to people writing update handlers later, no? > >> > > >> > >> I suppose so. But I am unclear because earlier in the thread I posted > >> working code that allows me to handle save conflicts (or validation > >> failures) from within javascript, with no change to the line protocol. > >> (That > >> is about all it has going for it in fact!) > >> > >> -- > >> Jason Smith > >> Couchio Hosting > >> > > > --0016367d6be24186cd048cde512f--