Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ColdFusion 9 optimization

New Here ,
Aug 13, 2012 Aug 13, 2012

ColdFusion 9 has giant bottlenecks, we made it more than 100% faster with the following fixes. In other words, for some requests, instead of taking 5 seconds, they takes 2 seconds.

That's the kind of improvement ColdFusion get by having a real developer around 😉

package com.onassignment.optimization;

import java.util.concurrent.ConcurrentMap;

import java.util.concurrent.ConcurrentHashMap;

import coldfusion.compiler.NeoTranslator;

import coldfusion.vfs.VFSFileFactory;

import coldfusion.runtime.CfJspPage;

import com.onassignment.hibernate.Initializer;

import com.onassignment.Configuration;

public aspect ColdFusion {

 

          private static Configuration configuration = (Configuration)Initializer.getApplicationContext().getBean("Configuration");

           

          /////////// First fix

 

          private static ConcurrentMap<String,Timestamps> pathToTimestamp = new ConcurrentHashMap<String,Timestamps>();

          private static long FIVE_SECOND_IN_MILLI = 5000;

 

          pointcut getLastModifiedTime(String canonicalPagePath):

                execution(public long NeoTranslator.getLastModifiedTime(..)) && args( canonicalPagePath );

          

          long around(String canonicalPagePath): getLastModifiedTime( canonicalPagePath) {

 

                    Long current = System.currentTimeMillis();

                    Timestamps timestamps = pathToTimestamp.get(canonicalPagePath);

 

                    if (           ( timestamps == null ) ||

                                        ( !configuration.isEnableLastModifiedTimeOptimization() ) ||

                                        ( (timestamps.lastLookup + FIVE_SECOND_IN_MILLI) < current )

                                        ){

                              long currentFileTime = proceed(canonicalPagePath);

                              timestamps = new Timestamps(current,currentFileTime);

                              pathToTimestamp.put(canonicalPagePath, timestamps);

                              return currentFileTime;

                    } else {

                              return timestamps.fileModifiedTime;

                    }

 

          }

 

          //////////// Second fix

          static ConcurrentMap<String,Boolean> urlToBoolean = new ConcurrentHashMap<String,Boolean>();

 

          pointcut checkIfVFile(String url):

                    execution(public static boolean VFSFileFactory.checkIfVFile(..)) && args( url );

 

          boolean around(String url): checkIfVFile( url) {

                    if (url == null){

                              return false;

                    }

 

                    Boolean isIt = urlToBoolean.get(url);

                    if (isIt != null){

                              return isIt;

                    }

 

                    isIt = proceed( url );

 

                    urlToBoolean.put( url, isIt );

 

                    return isIt;

          }

 

          //////////// Third fix

          public String CfJspPage.pagePath;

 

          pointcut getPagePath(CfJspPage called):

                    execution(public String getPagePath(..)) && target(called);

 

          String around(CfJspPage called): getPagePath( called) {

                    if (called.pagePath == null ){

                              called.pagePath = proceed(called);

                    }

 

                    return called.pagePath;

          }

 

}

615
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2012 Sep 19, 2012
LATEST

Hi,

I got here, because i have this code, of which almost all time is used up by the functions: getLastModifiedTime and coldfusion.key.hashCode.

The time for each is about equal,

so it seems that hashCode is using getlastmodifiedtime.

Would your code make this faster?

Can you maybe explain why it would be used in hashCode, i cant get the complete function call stack.

Could you send me the complete code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources