Snappy running really slow

I’m trying to run the following operations in snappy: Calibration > Speckle-Filter > Terrain-Correction in Snappy, but it is taking way too long. In the SNAP application it takes about 45 secs to process, but in Snappy it takes an upward of 30 mins. Below is my code. Before, I was running into the Java Error: Cannot construct databuffer, but I managed to fix it (I think?) based on existing threads from this forum. I’ve also increased the java-max-mem in the snappy.ini file to 6G from 4G. I have 8 GB of memory.

def CalibOp(p):
    parameters = HashMap()

    parameters.put('auxFile','Latest Auxiliary File')
    parameters.put('oututSigmaBand', True)
    parameters.put('sourceBands','Intensity_HH,Intensity_VV')
    parameters.put('selectedPolarisations', 'HH,VV')

    result = GPF.createProduct("Calibration", parameters, p)
    return result

def SpeckFilter(Calibrated):
    parameters = HashMap()
    
    parameters.put('sourceBands', 'Sigma0_HH,Sigma0_VV')
    parameters.put('filter','Boxcar')
    parameters.put('filterSizeX', 5)
    parameters.put('filterSizeY', 5)
    
    result = GPF.createProduct("Speckle-Filter", parameters, Calibrated)

    return result

def TCorrection(SpeckFiltered):
    parameters = HashMap()

    parameters.put('demName','SRTM 1Sec HGT')
    parameters.put('demResamplingMethod','BILINEAR_INTERPOLATION')
    parameters.put('imgResamplingMethod','BILINEAR_INTERPOLATION')
    parameters.put('pixelSpacingInMeter',13.23)
    parameters.put('mapProjection','WGS84(DD)')
    parameters.put('saveIncidenceAngleFromEllipsoid', True)

    result = GPF.createProduct("Terrain-Correction", parameters, SpeckFiltered)

    return result


speckS = 'C:\\Users\\ammar\\Desktop\\test-folder\\test1.dim'
speckP = ProductIO.readProduct(speckS)
terrainCSave = 'C:\\Users\\ammar\\Desktop\\test-folder\\tCorrection.dim'
bands = TCorrection(speckP).getBandNames()
print list(bands)
ProductIO.writeProduct(TCorrection(SpeckFilter(CalibOp(p))),terrainCSave,'BEAM-DIMAP')

I had a similar issue. The problem seems to be with the writeProduct function being slow.
I went from about 6 minutes writing time (on a monster machine) to 10-30 second by following the advice given here: