Getcwd performance issues


 
Thread Tools Search this Thread
Operating Systems Solaris Getcwd performance issues
# 1  
Old 06-15-2013
Getcwd performance issues

Hello everyone,
recently we have been experiencing performance issues with chmod. We managed to narrow it down to getcwd.

Code:
The following folder exists:
 /Folder1/subfol1/subfol2/subfol3

cd /Folder1/subfol1/subfol2/subfol3 

truss -D pwd 2>&1 | grep getcwd
 0.0001 getcwd("/folder1/subfol1/subfol2/subfol3", 1025) = 0

-- rename subfol3 to subfol4
cd ..
mv subfol3 subfol4

-enter new folder and analyze pwd

cd subfol4
truss -D pwd 2>&1 | grep getcwd
 0.2789 getcwd("/folder1/subfol1/subfol2/subfol4", 1025) = 0

-- rename to the original name
cd ..
mv subfol4 subfol3
cd subfol3

-- analyze pwd
truss -D pwd 2>&1 | grep getcwd
 0.0001 getcwd("/folder1/subfol1/subfol2/subfol3", 1025) = 0

Question: why is there a difference in a response time after renaming the folder ?

Code:
uname -a
SunOS algenib 5.10 Generic_147440-19 sun4u sparc SUNW,SPARC-Enterprise


Last edited by Scott; 06-15-2013 at 10:30 AM.. Reason: Please use code tags
# 2  
Old 06-15-2013
Note that the cd utility is a shell built-in; so the results of a test like this could vary widely from shell to shell.

Most shells will need to set the variable PWD when they start. Some shells will remember some number of directories they have seen in calls to cd and if they have seen a target direcotry path before, they can change the value of PWD (a side effect of calling cd) by looking at an in memory cache of previously visited directories. When you renamed subfol3 to subfol4, the shell's cache didn't contain an entry for subfol4 and had to make at least one system call to determine if subfol4 was a real directory or a symbolic link to a directory.

When you renamed subfol4 back to subfol3, the shell's cache could have contained an entry for subfol3, so it may have assumed that its cache was still valid.

If you look at the truss output (instead of just looking at the getcwd line in the output) you might be able to glean what is going on under the covers. You haven't said whether either of the subfol3 or subfol4 directories had been visited before the output you showed. My guess would be that you had visited subfol3 before, to get the results you showed, but without a lot more details this is purely speculation.
# 3  
Old 06-15-2013
thanks for the suggestion but I can also reproduce it with a newly created folder:

Code:
>> mkdir test
>> cd test
>> truss -D pwd 2>&1 | grep getcwd
0.0001 getcwd("/opt_local/product/test", 1025) = 0
>> cd ..
>> mv test test1
>> cd test1
>> truss -D pwd 2>&1 | grep getcwd
0.2130 getcwd("/opt_local/product/test1", 1025) = 0
>> cd ..
>> mv test1 test
>> cd test
>> truss -D pwd 2>&1 | grep getcwd
 0.0001 getcwd("/opt_local/product/test", 1025) = 0

As soon as I rename it back to test1 it becomes slow again.
Session or shell change has no effect on it.


The same does not happen on a similar server with a different OS level
SunOS 5.10 Generic_147147-26 sun4u sparc SUNW,SPARC-Enterprise
# 4  
Old 06-16-2013
Quote:
Originally Posted by KotekBury
thanks for the suggestion but I can also reproduce it with a newly created folder:

Code:
>> mkdir test
>> cd test
>> truss -D pwd 2>&1 | grep getcwd
0.0001 getcwd("/opt_local/product/test", 1025) = 0
>> cd ..
>> mv test test1
>> cd test1
>> truss -D pwd 2>&1 | grep getcwd
0.2130 getcwd("/opt_local/product/test1", 1025) = 0
>> cd ..
>> mv test1 test
>> cd test
>> truss -D pwd 2>&1 | grep getcwd
 0.0001 getcwd("/opt_local/product/test", 1025) = 0

As soon as I rename it back to test1 it becomes slow again.
Session or shell change has no effect on it.
Of course. Renaming a directory or creating a new directory is exactly the same condition for this discussion; the shell is seeing a directory name that is not in its cache.
Quote:
Originally Posted by KotekBury
The same does not happen on a similar server with a different OS level
SunOS 5.10 Generic_147147-26 sun4u sparc SUNW,SPARC-Enterprise
As I said before, different shells may show different results. Even if the pathname of the shell you're using on the two servers is the same, there is no guarantee that the shell's processing remains the same from release to release. Changes in the OS itself or the filesystem type underlying the directories involved could also have a profound effect.
# 5  
Old 06-16-2013
I'm still not convienced about your argumentation. If the shell cache played a role then I would expect the exactly oposite results. How can you explain the fact that a newly created folder yields better results than a renamed one?
As you can see above I visited the 2 folders the same way and only once after the creation.
The issue does not seem to occour for new folders.

Moreover, the real directory under a question is an existing application folder, which have been visited hundreds of times over the last few years. We have noticed the drop in the response time only recently.
The above Code was just a demonstration of how we manged to reproduce the issue.

No changes were made to shell, OS or hardware that would explain any of this.

any other suggestions or am I missing something here ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Baiduspider and Forum Performance Issues

For years we blocked Baiduspider due to the fact their bots do not obey the robots.txt directive and can really hurt site performance when they unleash 100 bots on the site each pulling pages many times per second. Last year, I unblocked Baiduspider's IP addresses, and now the problem is back. ... (1 Reply)
Discussion started by: Neo
1 Replies

2. UNIX for Dummies Questions & Answers

Hard Disk Performance issues Suse 11 SP1

hi guys right now I have 6 Virtual Machines (VMs) running on Vmware ESXi 5.1 and attached to Storage SAN. All these run Suse Linux 11 SP1 x64. All of a sudden 1 of these VMs is running very slow making high CPU usage and I see al wait % kinda high 40-50%. Apparently since I don't own this... (5 Replies)
Discussion started by: karlochacon
5 Replies

3. AIX

AIX 6.1 Memory Performance issues

Good Day Everyone, Just wonder anyone has encounter AIX 6.1 Memory Performance issues ? What I have in my current scenario is we have 3 datastage servers (Segregate server and EE jobs - for those who know Datastage achitect) and 2 db servers(running HA to load balance 4 nodes partitions for... (3 Replies)
Discussion started by: ckwan
3 Replies

4. Solaris

zfs send receive performance issues

I 'm trying to clone a zfs file system pool/u01 to a new file system called newpool/u01 using following commands zfs list zfs snapshot pool/u01@new zfs send pool/u01@new | zfs -F receive newpool/u01 Its a 100G file system snapshot and copied to same server on different pool and... (9 Replies)
Discussion started by: fugitive
9 Replies

5. AIX

Performance issues for LPAR with GPFS 3.4

Hi, We have GPFS 3.4 Installed on two AIX 6.1 Nodes. We have 3 GPFS Mount points: /abc01 4TB (Comprises of 14 x 300GB disks from XIV SAN) /abc02 4TB (Comprises of 14 x 300GB disks from XIV SAN) /abc03 1TB ((Comprises of Multiple 300GB disks from XIV SAN) Now these 40... (1 Reply)
Discussion started by: aixromeo
1 Replies

6. Solaris

Solaris 11 Express NAT performance issues

Hi all, I decided to replace my linux router/firewall with Solaris 11 express. This is a pppoe connection directly to my server...no router boxes. I got everything setup, but the performance is terrible on the NAT....really slow. A web page that loads on the server instantly will take... (3 Replies)
Discussion started by: vectox
3 Replies

7. Programming

performance issues of calling a function in if condition

Hi, I have written a program in C and have to test the return value of the functions. So the normal way of doin this wud b int rc rc=myfunction(input); if(rc=TRUE){ } else{ } But instead of doing this I have called the function in the if() condition. Does this have any... (2 Replies)
Discussion started by: sidmania
2 Replies

8. UNIX for Dummies Questions & Answers

Awk Performance Issues

Hi All, I'm facing an issue in my awk script. The script is processing a large text file having the details of a number of persons, each person's details being written from 100 to 250 tags as given below: 100 START| 101klklk| ... 245 opr| 246 55| 250 END| 100 START| ... 245 pp| 246... (4 Replies)
Discussion started by: pgp_acc1
4 Replies

9. Solaris

raidctl performance issues

using the internal 2 drives mirror was created using raidctl on 100's of our servers . sometime when one drive fails we dont face any issue & we replace the drive with out any problem . but sometimes when one drive fails , system becomes unresponsive and doesnot allow us to login , the only way to... (1 Reply)
Discussion started by: skamal4u
1 Replies

10. Shell Programming and Scripting

shell script performance issues --Urgent

I need help in awk please help immediatly. This below function is taking lot of time Please help me to fine tune it so that it runs faster. The file count is around 3million records # Process Body processbody() { #set -x while read line do ... (18 Replies)
Discussion started by: icefish
18 Replies
Login or Register to Ask a Question