<div dir="ltr">On Wed, Oct 30, 2013 at 9:26 AM, Gustavo Niemeyer <span dir="ltr"><<a href="mailto:gustavo@niemeyer.net" target="_blank">gustavo@niemeyer.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Wed, Oct 30, 2013 at 7:57 AM, John Arbash Meinel<br>
<<a href="mailto:john@arbash-meinel.com">john@arbash-meinel.com</a>> wrote:<br>
>> Where is N^2 coming from?<br>
><br>
> If you add N units one-by-one each new add triggers all existing units<br>
> to wake up and ask for the Life and CharmURL of the service again. So<br>
> first unit asks, 2nd unit asks and causes the first unit to ask again.<br>
<br>
</div>Why does it cause the first unit to ask again?  Adding a unit should<br>
not trigger watchers on the service to wake up. There are explicit<br>
watches for being notified about new units.<br></blockquote><div><br></div><div>The service watch fires on any change to the document, and adding a unit increments the service's unitcount field. The easy fix is to wrap the service watcher so that it discards irrelevant changes; the hard fix (schema change!) is to move the refcounts into their own docs, as we do elsewhere in state.</div>
</div></div></div>