VirtualBox

Changeset 72383 in vbox


Ignore:
Timestamp:
May 29, 2018 2:45:53 PM (7 years ago)
Author:
vboxsync
Message:

VMM/Guru: Speed up stderr output by explicit buffering. Makes a big difference on Windows. :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/VMMGuruMeditation.cpp

    r70948 r72383  
    7070    bool        fRecSummary;
    7171    /** Buffer for the summary. */
    72     char        szSummary[4096-2];
     72    char        szSummary[4096 - 2];
    7373    /** The current summary offset. */
    7474    size_t      offSummary;
     75    /** Standard error buffer.   */
     76    char        achStdErrBuf[4096 - 8];
     77    /** Standard error buffer offset. */
     78    size_t      offStdErrBuf;
    7579} VMMR3FATALDUMPINFOHLP, *PVMMR3FATALDUMPINFOHLP;
    7680/** Pointer to a VMMR3FATALDUMPINFOHLP structure. */
    7781typedef const VMMR3FATALDUMPINFOHLP *PCVMMR3FATALDUMPINFOHLP;
     82
     83
     84/**
     85 * Flushes the content of achStdErrBuf, setting offStdErrBuf to zero.
     86 *
     87 * @param   pHlp        The instance to flush.
     88 */
     89static void vmmR3FatalDumpInfoHlp_FlushStdErr(PVMMR3FATALDUMPINFOHLP pHlp)
     90{
     91    size_t cch = pHlp->offStdErrBuf;
     92    if (cch)
     93    {
     94        RTStrmWrite(g_pStdErr, pHlp->achStdErrBuf, cch);
     95        pHlp->offStdErrBuf = 0;
     96    }
     97}
     98
     99/**
     100 * @callback_method_impl{FNRTSTROUTPUT, For buffering stderr output.}
     101 */
     102static DECLCALLBACK(size_t) vmmR3FatalDumpInfoHlp_BufferedStdErrOutput(void *pvArg, const char *pachChars, size_t cbChars)
     103{
     104    PVMMR3FATALDUMPINFOHLP pHlp = (PVMMR3FATALDUMPINFOHLP)pvArg;
     105    if (cbChars)
     106    {
     107        size_t offBuf = pHlp->offStdErrBuf;
     108        if (cbChars < sizeof(pHlp->achStdErrBuf) - offBuf)
     109        { /* likely */ }
     110        else
     111        {
     112            vmmR3FatalDumpInfoHlp_FlushStdErr(pHlp);
     113            if (cbChars < sizeof(pHlp->achStdErrBuf))
     114                offBuf = 0;
     115            else
     116            {
     117                RTStrmWrite(g_pStdErr, pachChars, cbChars);
     118                return cbChars;
     119            }
     120        }
     121        memcpy(&pHlp->achStdErrBuf[offBuf], pachChars, cbChars);
     122        pHlp->offStdErrBuf = offBuf + cbChars;
     123    }
     124    return cbChars;
     125}
    78126
    79127
     
    93141}
    94142
    95 
    96143/**
    97144 * Print formatted string.
     
    123170        va_list args2;
    124171        va_copy(args2, args);
    125         RTStrmPrintfV(g_pStdErr, pszFormat, args);
     172        RTStrFormatV(vmmR3FatalDumpInfoHlp_BufferedStdErrOutput, pMyHlp, NULL, NULL, pszFormat, args2);
     173        //RTStrmPrintfV(g_pStdErr, pszFormat, args2);
    126174        va_end(args2);
    127175    }
     
    193241    pHlp->fStdErr = false; /* takes too long to display here */
    194242#endif
     243    pHlp->offStdErrBuf = 0;
    195244
    196245    /*
     
    222271        pHlp->pLogger->fDestFlags = pHlp->fLoggerDestFlags;
    223272    }
     273
     274    if (pHlp->fStdErr)
     275        vmmR3FatalDumpInfoHlp_FlushStdErr(pHlp);
    224276}
    225277
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette