[ 
https://issues.apache.org/jira/browse/OAK-1828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15027079#comment-15027079
 ] 

Michael Dürig commented on OAK-1828:
------------------------------------

I just committed a pretty comprehensive refactoring of the {{SegmentWriter}}: 
http://svn.apache.org/r1716466 Encapsulate the state of the segment being 
written and its coordination wrt. concurrent access in a separate class
http://svn.apache.org/r1716467 Better encapsulate records cache
http://svn.apache.org/r1716468 Simplify flushing of segments
http://svn.apache.org/r1716469 Factor out duplicate align methods
http://svn.apache.org/r1716470 Eliminate passing the SegmentTracker into the 
SegmentWriter
http://svn.apache.org/r1716471 Remove SegmentWriter.getTracker
http://svn.apache.org/r1716472 Move anonymous record writers to top level
http://svn.apache.org/r1716473 Some JavaDoc

As an immediate follow up we should come up with a better name for 
{{SegmentBuilder}}. [~frm] came up with {{SegmentBufferWriter}} and I like the 
idea as it writes segments and buffer implies the low level aspects it actually 
handles. [~alex.parvulescu] WDYT?


> Improved SegmentWriter
> ----------------------
>
>                 Key: OAK-1828
>                 URL: https://issues.apache.org/jira/browse/OAK-1828
>             Project: Jackrabbit Oak
>          Issue Type: Sub-task
>          Components: segmentmk
>            Reporter: Jukka Zitting
>            Assignee: Alex Parvulescu
>            Priority: Minor
>              Labels: technical_debt
>             Fix For: 1.3.12
>
>         Attachments: record-writers-v0.patch, record-writers-v1.patch, 
> record-writers-v2.patch
>
>
> At about 1kLOC and dozens of methods, the SegmentWriter class currently a bit 
> too complex for one of the key components of the TarMK. It also uses a 
> somewhat non-obvious mix of synchronized and unsynchronized code to 
> coordinate multiple concurrent threads that may be writing content at the 
> same time. The synchronization blocks are also broader than what really would 
> be needed, which in some cases causes unnecessary lock contention in 
> concurrent write loads.
> To improve the readability and maintainability of the code, and to increase 
> performance of concurrent writes, it would be useful to split part of the 
> SegmentWriter functionality to a separate RecordWriter class that would be 
> responsible for writing individual records into a segment. The 
> SegmentWriter.prepare() method would return a new RecordWriter instance, and 
> the higher-level SegmentWriter methods would use the returned instance for 
> all the work that's currently guarded in synchronization blocks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to