commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Canavan (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CONFIGURATION-496) Excessive Synchronization AbstractFileConfiguration
Date Tue, 08 May 2012 19:53:48 GMT

     [ https://issues.apache.org/jira/browse/CONFIGURATION-496?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tim Canavan updated CONFIGURATION-496:
--------------------------------------

    Description: 
We are having a problem with commons configuration 1.6 AbstractFileConfiguration 

During a stress test we are seeing that we have wait locks against this method causing this
method not to complete for up to one second.

We are using the FileReloadStrategy delegate which makes a check on the file system when now
+ interval is greater than the compare time.

Why can't we make this check before the synchronized block thus increasing throughput. I have
noticed in 1.8 that the caller to this method is synchronized. This seems like excessive synchronization.
Any ideas how to solve this. 

{code}
public void reload()
    {
        synchronized (reloadLock)
        {
            if (noReload == 0)
            {
                try
                {
                    enterNoReload(); // avoid reentrant calls

                    if (strategy.reloadingRequired())
                    {
                        if (getLogger().isInfoEnabled())
                        {
                            getLogger().info("Reloading configuration. URL is " + getURL());
                        }
                        fireEvent(EVENT_RELOAD, null, getURL(), true);
                        setDetailEvents(false);
                        boolean autoSaveBak = this.isAutoSave(); // save the current state
                        this.setAutoSave(false); // deactivate autoSave to prevent information
loss
                        try
                        {
                            clear();
                            load();
                        }
                        finally
                        {
                            this.setAutoSave(autoSaveBak); // set autoSave to previous value
                            setDetailEvents(true);
                        }
                        fireEvent(EVENT_RELOAD, null, getURL(), false);

                        // notify the strategy
                        strategy.reloadingPerformed();
                    }
                }
                catch (Exception e)
                {
                    fireError(EVENT_RELOAD, null, null, e);
                    // todo rollback the changes if the file can't be reloaded
                }
                finally
                {
                    exitNoReload();
                }
            }
        }
    }

{code}

  was:
We are having a problem with commons configuration 1.6 AbstractFileConfiguration 

During a stress test we are seeing that we have wait locks against this method causing this
method not to complete for up to one second.

We are using the FileReloadStrategy delegate which makes a check on the file system when now
+ interval is greater than the compare time.

Why can't we make this check before the synchronized block thus increasing throughput. I have
noticed in 1.8 that the caller to this method is synchronized. This seems like excessive synchronization.
Any ideas how to solve this. 

public void reload()
    {
        synchronized (reloadLock)
        {
            if (noReload == 0)
            {
                try
                {
                    enterNoReload(); // avoid reentrant calls

                    if (strategy.reloadingRequired())
                    {
                        if (getLogger().isInfoEnabled())
                        {
                            getLogger().info("Reloading configuration. URL is " + getURL());
                        }
                        fireEvent(EVENT_RELOAD, null, getURL(), true);
                        setDetailEvents(false);
                        boolean autoSaveBak = this.isAutoSave(); // save the current state
                        this.setAutoSave(false); // deactivate autoSave to prevent information
loss
                        try
                        {
                            clear();
                            load();
                        }
                        finally
                        {
                            this.setAutoSave(autoSaveBak); // set autoSave to previous value
                            setDetailEvents(true);
                        }
                        fireEvent(EVENT_RELOAD, null, getURL(), false);

                        // notify the strategy
                        strategy.reloadingPerformed();
                    }
                }
                catch (Exception e)
                {
                    fireError(EVENT_RELOAD, null, null, e);
                    // todo rollback the changes if the file can't be reloaded
                }
                finally
                {
                    exitNoReload();
                }
            }
        }
    }

    
> Excessive Synchronization AbstractFileConfiguration
> ---------------------------------------------------
>
>                 Key: CONFIGURATION-496
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-496
>             Project: Commons Configuration
>          Issue Type: Bug
>          Components: File reloading
>    Affects Versions: 1.6, 1.7, 1.8
>            Reporter: Tim Canavan
>
> We are having a problem with commons configuration 1.6 AbstractFileConfiguration 
> During a stress test we are seeing that we have wait locks against this method causing
this method not to complete for up to one second.
> We are using the FileReloadStrategy delegate which makes a check on the file system when
now + interval is greater than the compare time.
> Why can't we make this check before the synchronized block thus increasing throughput.
I have noticed in 1.8 that the caller to this method is synchronized. This seems like excessive
synchronization. Any ideas how to solve this. 
> {code}
> public void reload()
>     {
>         synchronized (reloadLock)
>         {
>             if (noReload == 0)
>             {
>                 try
>                 {
>                     enterNoReload(); // avoid reentrant calls
>                     if (strategy.reloadingRequired())
>                     {
>                         if (getLogger().isInfoEnabled())
>                         {
>                             getLogger().info("Reloading configuration. URL is " + getURL());
>                         }
>                         fireEvent(EVENT_RELOAD, null, getURL(), true);
>                         setDetailEvents(false);
>                         boolean autoSaveBak = this.isAutoSave(); // save the current
state
>                         this.setAutoSave(false); // deactivate autoSave to prevent information
loss
>                         try
>                         {
>                             clear();
>                             load();
>                         }
>                         finally
>                         {
>                             this.setAutoSave(autoSaveBak); // set autoSave to previous
value
>                             setDetailEvents(true);
>                         }
>                         fireEvent(EVENT_RELOAD, null, getURL(), false);
>                         // notify the strategy
>                         strategy.reloadingPerformed();
>                     }
>                 }
>                 catch (Exception e)
>                 {
>                     fireError(EVENT_RELOAD, null, null, e);
>                     // todo rollback the changes if the file can't be reloaded
>                 }
>                 finally
>                 {
>                     exitNoReload();
>                 }
>             }
>         }
>     }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message