> On Nov. 20, 2014, 5:09 p.m., Maxim Khutornenko wrote:
> > src/main/java/org/apache/aurora/scheduler/storage/log/EntrySerializer.java, 
> > line 92
> > <https://reviews.apache.org/r/28306/diff/1/?file=771713#file771713line92>
> >
> >     Mind commenting on the algorithm here? Why the magic "-2"?
> 
> Kevin Sweeney wrote:
>     Not sure what I'd say there that doesn't risk contradicting the code 
> below - we don't usually comment loop variables and the old version had the 
> same amount of commenting.
> 
> Maxim Khutornenko wrote:
>     I just find it harder to follow when I see anything less than -1 as the 
> initial condition. Why not starting with -1 (to account for the header) and 
> then increment i at the end of computeNext()?

Each branch short-circuits so I'd have to have a result intermediate value. I 
don't find that more readable

```java
byte[] result;
if (i == -1) {
  result = header;
} else if (...) {
  result = encode(...);
} else {
  return endOfFile();
}

i++;
return result;
```


- Kevin


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/28306/#review62481
-----------------------------------------------------------


On Nov. 20, 2014, 5:10 p.m., Kevin Sweeney wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/28306/
> -----------------------------------------------------------
> 
> (Updated Nov. 20, 2014, 5:10 p.m.)
> 
> 
> Review request for Aurora, David McLaughlin and Bill Farner.
> 
> 
> Bugs: AURORA-930
>     https://issues.apache.org/jira/browse/AURORA-930
> 
> 
> Repository: aurora
> 
> 
> Description
> -------
> 
> Stream frame chunks instead of preallocating them.
> 
> This avoids allocating an entire additional snapshot worth of heap during 
> entry serialization, reducing overall heap impact of the serializer from 
> 2*sizeof(serialized-entry) to sizeof(serialized-entry)+chunkSize.
> 
> Further optimizations out-of-scope for this change:
> 
> * Make the returned iterator mutate a fixed-size buffer (for GC pressure 
> avoidance).
> * Change the log format so that FrameHeader doesn't need to know the size and 
> checksum of the serialized data ahead-of-time (maybe write it as a trailer).
> 
> 
> Diffs
> -----
> 
>   src/main/java/org/apache/aurora/scheduler/storage/log/EntrySerializer.java 
> f4fa1cb740633ced529c1b5fd9f18abba8944571 
>   
> src/main/java/org/apache/aurora/scheduler/storage/log/StreamManagerImpl.java 
> cb95d8996a934751745f423b79279266d73b7722 
>   src/test/java/org/apache/aurora/scheduler/app/SchedulerIT.java 
> c90389433d81dd72756c659736e38fd9f66fcb35 
> 
> Diff: https://reviews.apache.org/r/28306/diff/
> 
> 
> Testing
> -------
> 
> ./gradlew -Pq build
> 
> 
> Thanks,
> 
> Kevin Sweeney
> 
>

Reply via email to