Changeset 797

Show
Ignore:
Timestamp:
01/01/08 12:24:37 (14 years ago)
Author:
ppalmers
Message:

parameters for better latency performance

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/config.h.in

    r796 r797  
    3636#define SHAREDIR "$sharedir" 
    3737 
    38 #define MINIMUM_INTERRUPTS_PER_PERIOD   4
    39 #define MAX_ISO_XMIT_BUFFER_FILL_PCT    7
     38#define MINIMUM_INTERRUPTS_PER_PERIOD   2
     39#define MAX_ISO_XMIT_BUFFER_FILL_PCT    5
    4040 
    4141#define ISOHANDLER_PER_HANDLER_THREAD   0 
     
    5858#define STREAMPROCESSORMANAGER_NB_ALIGN_TRIES               40 
    5959 
     60#define STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY           0 
    6061 
    6162// FIXME: note that it will probably be better to use a DLL bandwidth that is  
  • trunk/libffado/src/libieee1394/IsoHandlerManager.cpp

    r796 r797  
    337337        unsigned int page_size = getpagesize() - 2; // for one reason or another this is necessary 
    338338 
    339         // hardware interrupts can only occur when one DMA descriptor is full,  
    340         // and the size of one DMA descriptor in bufferfill mode is PAGE_SIZE. 
    341         // the number of packets that fits into this descriptor is dependent on 
    342         // the max_packet_size parameter:  
    343         // packets_per_descriptor = PAGE_SIZE / max_packet_size 
    344         // 
    345         // Hence if we want N hardware IRQ's in one period, we have to ensure that 
    346         // there are at least N descriptors for one period worth of packets 
    347         // hence: 
    348         // packets_per_interrupt = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD 
    349         // packets_per_descriptor <= packets_per_interrupt 
    350         // 
    351         // or: 
    352         // => PAGE_SIZE / max_packet_size <= packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD 
    353         // => PAGE_SIZE * MINIMUM_INTERRUPTS_PER_PERIOD / packets_per_period <= max_packet_size 
    354  
    355         unsigned int min_max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * page_size) / packets_per_period; 
    356  
    357         if (max_packet_size < min_max_packet_size) { 
    358             debugOutput(DEBUG_LEVEL_VERBOSE, "correcting stream max packet size (%u) to (%u) to ensure enough interrupts\n", 
    359                          max_packet_size, min_max_packet_size); 
    360             max_packet_size = min_max_packet_size; 
    361         } 
    362  
    363339        // Ensure we don't request a packet size bigger than the 
    364340        // kernel-enforced maximum which is currently 1 page. 
     
    370346        unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 
    371347        if(irq_interval <= 0) irq_interval=1; 
    372 //         unsigned int irq_interval=2; // this is not the HW IRQ interval 
    373348         
    374349        // the receive buffer size doesn't matter for the latency, 
     
    391366        unsigned int packets_per_period = stream->getPacketsPerPeriod(); 
    392367        unsigned int max_packet_size = stream->getMaxPacketSize(); 
    393         unsigned int page_size = getpagesize() - 2; // for one reason or another this is necessary 
    394  
    395         // hardware interrupts can only occur when one DMA descriptor is full,  
    396         // and the size of one DMA descriptor in bufferfill mode is PAGE_SIZE. 
    397         // the number of packets that fits into this descriptor is dependent on 
    398         // the max_packet_size parameter:  
    399         // packets_per_descriptor = PAGE_SIZE / max_packet_size 
    400         // 
    401         // Hence if we want N hardware IRQ's in one period, we have to ensure that 
    402         // there are at least N descriptors for one period worth of packets 
    403         // hence: 
    404         // packets_per_interrupt = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD 
    405         // packets_per_descriptor <= packets_per_interrupt 
    406         // 
    407         // or: 
    408         // => PAGE_SIZE / max_packet_size <= packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD 
    409         // => PAGE_SIZE * MINIMUM_INTERRUPTS_PER_PERIOD / packets_per_period <= max_packet_size 
    410  
    411         unsigned int min_max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * page_size) / packets_per_period; 
    412  
    413         if (max_packet_size < min_max_packet_size) { 
    414             debugOutput(DEBUG_LEVEL_VERBOSE, "correcting stream max packet size (%u) to (%u) to ensure enough interrupts\n", 
    415                          max_packet_size, min_max_packet_size); 
    416             max_packet_size = min_max_packet_size; 
    417         } 
     368        unsigned int page_size = getpagesize(); 
    418369 
    419370        // Ensure we don't request a packet size bigger than the 
     
    424375        } 
    425376 
    426         // unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD
    427         // if(irq_interval <= 0) irq_interval=1
    428         unsigned int irq_interval=2; // this is not the HW IRQ interval 
     377        max_packet_size = page_size
     378        unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD
     379        if(irq_interval <= 0) irq_interval=1; 
    429380 
    430381        // the SP specifies how many packets to ISO-buffer 
  • trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp

    r796 r797  
    211211                        transmit_at_cycle, cycles_until_transmit, 
    212212                        presentation_time, (unsigned int)TICKS_TO_CYCLES(presentation_time) ); 
    213             debugShowBackLogLines(200); 
    214             flushDebugOutput(); 
    215             // however, if we can send this sufficiently before the presentation 
    216             // time, it could be harmless. 
    217             // NOTE: dangerous since the device has no way of reporting that it didn't get 
    218             //       this packet on time. 
    219             if(cycles_until_presentation >= min_cycles_before_presentation) 
    220             { 
    221                 // we are not that late and can still try to transmit the packet 
    222                 m_dbc += fillDataPacketHeader(packet, length, m_last_timestamp); 
    223                 return (fc < (signed)(2*m_syt_interval) ? eCRV_Defer : eCRV_Packet); 
    224             } 
    225             else   // definitely too late 
    226             { 
     213            //debugShowBackLogLines(200); 
     214//             // however, if we can send this sufficiently before the presentation 
     215//             // time, it could be harmless. 
     216//             // NOTE: dangerous since the device has no way of reporting that it didn't get 
     217//             //       this packet on time. 
     218//             if(cycles_until_presentation >= min_cycles_before_presentation) 
     219//             { 
     220//                 // we are not that late and can still try to transmit the packet 
     221//                 m_dbc += fillDataPacketHeader(packet, length, m_last_timestamp); 
     222//                 return (fc < (signed)(2*m_syt_interval) ? eCRV_Defer : eCRV_Packet); 
     223//             } 
     224//             else   // definitely too late 
     225//             { 
    227226                return eCRV_XRun; 
    228             } 
     227//             } 
    229228        } 
    230229        else if(cycles_until_transmit <= max_cycles_to_transmit_early) 
  • trunk/libffado/src/libstreaming/generic/StreamProcessor.cpp

    r796 r797  
    127127                                     packets_to_prebuffer); 
    128128     
    129     // only queue a part (70%) of the theoretical max in order not to have too much 'not ready' cycles 
     129    // only queue a part of the theoretical max in order not to have too much 'not ready' cycles 
    130130    packets_to_prebuffer = (packets_to_prebuffer * MAX_ISO_XMIT_BUFFER_FILL_PCT * 1000) / 100000; 
    131131    debugOutput(DEBUG_LEVEL_VERBOSE, " reduce to %d%%: %u\n", 
     
    490490    int cycle_diff = diffCycles(cycle, now_cycles); 
    491491 
    492     #ifdef DEBUG 
    493492    if(cycle_diff < 0 && (m_state == ePS_Running || m_state == ePS_DryRunning)) { 
    494493        debugWarning("Requesting packet for cycle %04d which is in the past (now=%04dcy)\n", 
     
    498497//             flushDebugOutput(); 
    499498//             assert(0); 
    500         } 
    501     } 
    502     #endif 
     499            debugWarning("generatePacketData xrun\n"); 
     500            m_in_xrun = true; 
     501            debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to data xrun\n"); 
     502            m_next_state = ePS_WaitingForStreamDisable; 
     503            // execute the requested change 
     504            if (!updateState()) { // we are allowed to change the state directly 
     505                debugError("Could not update state!\n"); 
     506                return RAW1394_ISO_ERROR; 
     507            } 
     508            goto send_empty_packet; 
     509        } 
     510    } 
    503511 
    504512    // store the previous timestamp 
     
    604612            m_in_xrun = true; 
    605613            debugOutput(DEBUG_LEVEL_VERBOSE, "Should update state to WaitingForStreamDisable due to header xrun\n"); 
    606             m_cycle_to_switch_state = cycle+1; // switch in the next cycle 
    607614            m_next_state = ePS_WaitingForStreamDisable; 
    608615            // execute the requested change 
  • trunk/libffado/src/libstreaming/StreamProcessorManager.cpp

    r796 r797  
    712712    // check if xruns occurred on the Iso side. 
    713713    // also check if xruns will occur should we transfer() now 
     714#if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 
    714715    #ifdef DEBUG 
    715716    int waited = 0; 
    716717    #endif 
     718#endif 
    717719    bool ready_for_transfer = false; 
    718720    bool ready; 
     
    735737            xrun_occurred |= (*it)->xrunOccurred(); 
    736738        } 
     739#if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 
    737740        if (!ready_for_transfer) { 
    738741             
     
    751754            #endif 
    752755        } 
     756#endif 
    753757    } // we are either ready or an xrun occurred 
    754758 
     759#if STREAMPROCESSORMANAGER_DYNAMIC_SYNC_DELAY 
    755760    // in order to avoid a runaway value of the sync delay, we gradually decrease 
    756761    // it. It will be increased by a 'too early' event (cfr some lines higher) 
     
    765770    } 
    766771    #endif 
     772#endif 
    767773 
    768774    // this is to notify the client of the delay that we introduced by waiting