Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Slow flush
Message
 
À
26/03/2002 07:42:54
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Titre:
Divers
Thread ID:
00637009
Message ID:
00637308
Vues:
20
>>I am trying to support an application written in FPW 2.6. The system uses a lot of flushs to deal with network updates, etc. Recently the user has updated his system to Windows 2000 and we have noticed a tremendous slowdown in the flush commands. Is there any way to alleviate this performance hit?
>
>For one, make sure to check whether there really are changes. FLUSH without a previous REPLACE (or equivalent) still causes a disk access! Checking for changes in memory is much faster.
>
>HTH, Hilmar.


I definitely know the values have changed. The routine is a general ledger posting routine. It receives an account and an amount to post, and then adds that amount to the account and all of its parent accounts. It does this in a loop. The flushes were put in to solve a problem we were seeing where the data would be written to an account and then not show up. We put a check in the code immediately after updating each record to make sure the updated value is there and then logged it if it wasn't. In a few locations we would occasionally get entries that didn't update. Putting in a flush after each write seemed to work, but on Win2K/XP the routine now gets fairly slow.

Sooo...
It would be nice to know some way to speed that up or some way to get the postings to work right.

FWIW, here is the section of code that actually does the posting:
DONE = 0
*
* Get month from date
* 
DIDITLOCK  = .F.
WASLCKCLRD = .F.
DO WHILE DIDITLOCK = .F.
  DIDITLOCK = FLOCK()                 && Attempt to fix novell posting problem
  IF (DIDITLOCK = .F.)
    WAIT WINDOW "Some user has locked the g/l file.  Please get them out.  Press Any Key!"
    DO WRITEMSG WITH "Problem locking glaccts in postplus.prg","" 
    WASLCKCLRD = .T.
  ENDIF
ENDDO
IF (WASLCKCLRD = .T.)
  DO WRITEMSG WITH "There was a retry on locking glaccts in postplus.prg but we got through!","" 
ENDIF

DO WHILE .T.
  IF (GLACCTS->ACCT_TYPE <> DB_OR_CR)
    TMP_TOTAL = - MTOTAL
  ENDIF
  DO CASE
    CASE THE_MONTH = 1
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
*
* Note the current value
*
        TMPSUM = GLACCTS->JAN

*
* Update the value
*
        REPLACE GLACCTS->JAN WITH GLACCTS->JAN + TMP_TOTAL

*
* This condition should never be true, but we find that for some reason some
* times it is!
*
        IF (GLACCTS->JAN <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_JAN WITH GLACCTS->NEXT_JAN + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 2
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->FEB
        REPLACE GLACCTS->FEB WITH GLACCTS->FEB + TMP_TOTAL
        IF (GLACCTS->FEB <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_FEB WITH GLACCTS->NEXT_FEB + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 3
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->MAR
        REPLACE GLACCTS->MAR WITH GLACCTS->MAR + TMP_TOTAL
        IF (GLACCTS->MAR <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_MAR WITH GLACCTS->NEXT_MAR + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 4
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->APR
        REPLACE GLACCTS->APR WITH GLACCTS->APR + TMP_TOTAL
        IF (GLACCTS->APR <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_APR WITH GLACCTS->NEXT_APR + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 5
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->MAY
        REPLACE GLACCTS->MAY WITH GLACCTS->MAY + TMP_TOTAL
        IF (GLACCTS->MAY <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_MAY WITH GLACCTS->NEXT_MAY + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 6
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->JUN
        REPLACE GLACCTS->JUN WITH GLACCTS->JUN + TMP_TOTAL
        IF (GLACCTS->JUN <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_JUN WITH GLACCTS->NEXT_JUN + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 7
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->JUL
        REPLACE GLACCTS->JUL WITH GLACCTS->JUL + TMP_TOTAL
        IF (GLACCTS->JUL <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_JUL WITH GLACCTS->NEXT_JUL + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 8
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->AUG
        REPLACE GLACCTS->AUG WITH GLACCTS->AUG + TMP_TOTAL
        IF (GLACCTS->AUG <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_AUG WITH GLACCTS->NEXT_AUG + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 9
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->SEP
        REPLACE GLACCTS->SEP WITH GLACCTS->SEP + TMP_TOTAL
        IF (GLACCTS->SEP <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_SEP WITH GLACCTS->NEXT_SEP + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 10
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->OCT
        REPLACE GLACCTS->OCT WITH GLACCTS->OCT + TMP_TOTAL
        IF (GLACCTS->OCT <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_OCT WITH GLACCTS->NEXT_OCT + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 11
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->NOV
        REPLACE GLACCTS->NOV WITH GLACCTS->NOV + TMP_TOTAL
        IF (GLACCTS->NOV <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_NOV WITH GLACCTS->NEXT_NOV + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
    CASE THE_MONTH = 12
      IF YEAR(MPOST_DATE) = MCUR_YEAR  && If posting to current year
        TMPSUM = GLACCTS->DEC
        REPLACE GLACCTS->DEC WITH GLACCTS->DEC + TMP_TOTAL
        IF (GLACCTS->DEC <> TMPSUM + TMP_TOTAL)
          DO WRITEMSG WITH "Total was wrong in postplus.prg ","" 
        ENDIF
      ELSE
        REPLACE GLACCTS->NEXT_DEC WITH GLACCTS->NEXT_DEC + TMP_TOTAL
      ENDIF
      FLUSH             && Need this for multiusers
  ENDCASE    
*
* If current month and year
*
  IF MONTH(MPOST_DATE) = MCUR_MONTH .AND. YEAR(MPOST_DATE) = MCUR_YEAR  && If posting current month and year
    REPLACE THIS_MONTH WITH THIS_MONTH + TMP_TOTAL,;
      THIS_YEAR WITH THIS_YEAR + TMP_TOTAL
      FLUSH             && Need this for multiusers
  ENDIF
  DO SETBALANCE              && Put totals into balance field
  
  IF DONE = 1
    SET INDEX TO
    DELETE FILE &FN_IDX  && Delete the temporary index
    SET INDEX TO GLACCTS  && Restore index after using temporary index
    SEEK MACCT_NBR           && Need this for manual checks postings to glpost
    UNLOCK IN GLACCTS
    RETURN
  ENDIF
*
* Update General Accounts That This Detailed Account Belongs To.
* 
  ACCT_NBR1 = INT(ACCT_NBR/100)
  ACCT_NBR1 = ACCT_NBR1*100
  IF ACCT_NBR1 = ACCT_NBR2          && We have not found the next level up yet
    ACCT_NBR1 = INT(ACCT_NBR/10000)
    ACCT_NBR1 = ACCT_NBR1*10000
    IF ACCT_NBR1 = ACCT_NBR2     && We have not found the next level up yet
      ACCT_NBR1 = INT(ACCT_NBR/1000000)
      ACCT_NBR1 = ACCT_NBR1*1000000
      IF ACCT_NBR1 = ACCT_NBR2     && We have not found the next level up yet
        ACCT_NBR1 = INT(ACCT_NBR/10000000)
        ACCT_NBR1 = ACCT_NBR1*10000000
        SEEK ACCT_NBR1
        IF (.NOT. FOUND())
          DO WRITEMSG WITH "Error 1 in postplus.prg","" 
        ENDIF
        DONE = 1
      ELSE
        SEEK ACCT_NBR1      
        IF (.NOT. FOUND())
          DO WRITEMSG WITH "Error 2 in postplus.prg","" 
        ENDIF
      ENDIF
    ELSE
      SEEK ACCT_NBR1      
      IF (.NOT. FOUND())
        DO WRITEMSG WITH "Error 3 in postplus.prg","" 
      ENDIF
    ENDIF
  ELSE
    SEEK ACCT_NBR1      
    IF (.NOT. FOUND())
      DO WRITEMSG WITH "Error 4 in postplus.prg","" 
    ENDIF
  ENDIF
  ACCT_NBR2 = ACCT_NBR1  && Setup for the next level up
ENDDO
UNLOCK IN GLACCTS
Paul R. Moon
Business Software Solutions
paul@businessoftware.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform