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

ASF GitHub Bot commented on OMID-50:
------------------------------------

Github user francisco-perez-sorrosal commented on a diff in the pull request:

    https://github.com/apache/incubator-omid/pull/3#discussion_r73977366
  
    --- Diff: 
tso-server/src/main/java/org/apache/omid/tso/PersistenceProcessorImpl.java ---
    @@ -83,7 +86,9 @@
             ThreadFactoryBuilder threadFactory = new 
ThreadFactoryBuilder().setNameFormat("persist-%d");
             this.disruptorExec = 
Executors.newFixedThreadPool(config.getNumConcurrentCTWriters(), 
threadFactory.build());
     
    -        this.disruptor = new Disruptor<>(EVENT_FACTORY, 1 << 20, 
disruptorExec , SINGLE, new BusySpinWaitStrategy());
    +        this.disruptor = new Disruptor<>(EVENT_FACTORY, 1 << 20, 
disruptorExec , SINGLE,
    --- End diff --
    
    I think you forgot to add the first part of my comment. Instead of creating 
each strategy explicitly in each *ProcessorImpl class, we inject the 
WaitStrategy in it (that's why we add it to the `DisruptorModule` above.) So 
for this class should be:
    ```java
        @Inject
        PersistenceProcessorImpl(TSOServerConfig config,
                                 @Named("PersistenceStrategy") WaitStrategy 
strategy,  // <-- Strategy is injected here
                                 CommitTable commitTable,
                                 ObjectPool<Batch> batchPool,
                                 Panicker panicker,
                                 PersistenceProcessorHandler[] handlers,
                                 MetricsRegistry metrics)
                throws Exception {
    
            // 
------------------------------------------------------------------------------------------------------------
            // Disruptor initialization
            // 
------------------------------------------------------------------------------------------------------------
    
            ThreadFactoryBuilder threadFactory = new 
ThreadFactoryBuilder().setNameFormat("persist-%d");
            this.disruptorExec = 
Executors.newFixedThreadPool(config.getNumConcurrentCTWriters(), 
threadFactory.build());
    
            this.disruptor = new Disruptor<>(EVENT_FACTORY, 1 << 20, 
disruptorExec , SINGLE, strategy); // <-- Use injected strategy here
            ...
    ```
    
    Please remove my comments, if you cut and paste.


> Provide an option to reduce tso-server CPU usage
> ------------------------------------------------
>
>                 Key: OMID-50
>                 URL: https://issues.apache.org/jira/browse/OMID-50
>             Project: Apache Omid
>          Issue Type: Improvement
>            Reporter: Daniel Dai
>            Assignee: Daniel Dai
>             Fix For: 0.8.2.10
>
>         Attachments: OMID-50-1.patch
>
>
> Currently tso-server use 300% cpu even at idle time. The reason for this 300% 
> cpu usage is due to the BusyWaitStrategy used in disruptor. While this is 
> good for throughput, it wastes resources in many use cases. In this ticket, I 
> provide a config to use a different wait strategy and reduce the cpu usage 
> with the option on.



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

Reply via email to