How do I slow down a process?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How do I slow down a process?
# 8  
Old 11-05-2011
Quote:
Originally Posted by Corona688
If you could link me to the source, I'd take a look.
Thank you, I don't know much about c so that'd be great.

The link is: www2.research.att.com/~gsf/download/tgz/ast-open.2011-02-08.tgz, username: "I accept www.opensource.org/licenses/cpl", password: ".". Inside the gz tar file the source is located in /src/cmd/warp.

The warp.sh file is probably written in ksh(? it doesn't have a #! thing how does it work?) but it's really easy to do manually.
Set the WARP variable to: "-b<start time> -f<time multiplier> <time offset>" where the start time is seconds from the unix epoch date and time offset is the number of seconds in the future. Then load the so file using LD_PRELOAD. I wrote a little bash script that works on my computer:

Code:
#!/usr/bin/env bash
factor="$1"
shift
offset="$1"
shift

newdate="$(date +%s --date "$offset")"
olddate="$(date +%s --date now)"
offsets="$(expr "$newdate" - "$olddate")"

sopath="<path to .so file>"

env WARP="-b$olddate -f$factor $offsets" LD_PRELOAD="$sopath" DYLD_INSERT_LIBRARIES="$sopath" _RLD_LIST="$sopath" $*

The first argument is the time multiplier. The second is the time offset in english ("-5 minutes", "now", "20:11"). The command and it's arguments follow that.

Edit: I have no idea what DYLD_INSERT_LIBRARIES and _RLD_LIST do but it sounded good.
# 9  
Old 11-06-2011
Quote:
Originally Posted by Nathan1
The warp.sh file is probably written in ksh(? it doesn't have a #! thing how does it work?)
Without that, it assumes #!/bin/sh

---------- Post updated at 10:34 PM ---------- Previous update was at 10:29 PM ----------

The makefile is broken.

I can wing it, but I have no idea if it'd work on your system. What is it?
# 10  
Old 11-06-2011
Quote:
Originally Posted by Corona688
Without that, it assumes #!/bin/sh

---------- Post updated at 10:34 PM ---------- Previous update was at 10:29 PM ----------

The makefile is broken.

I can wing it, but I have no idea if it'd work on your system. What is it?
arch returns "i686"

I saw the file "mamfile" so I looked it up and I think it's for at&t's own make program.
# 11  
Old 11-06-2011
There's also a proper Makefile, which is broken. They may have used incompatible AT&T extensions in it.

I've got a better idea, but it may not work depending on what your system is.

i686 what? Linux? BSD? Solaris? OSX? Cygwin?

Last edited by Corona688; 11-06-2011 at 04:06 PM..
# 12  
Old 11-06-2011
i686 Linux.

Last edited by Nathan1; 11-06-2011 at 06:46 PM..
# 13  
Old 11-06-2011
Good, I have something that might work, a version of libkeepalive which I modified to overload the sleep/usleep/gettimeofday calls instead of socket calls.

I modified the 'test' program to do 11 loops of 1 second each. The FRAC fraction is used to change what 'one second' means to the program by overloading the sleep/gettimeofday calls.

Code:
$ tar -zxf libspeedhack.tar.gz
$ cd libspeedhack
$ make

...

$ time LD_PRELOAD="./libspeedhack.so" FRAC="1/3" test/test
              0	         521324
              1	         521449
              2	         521524
              3	         521625
              4	         521708
              5	         521781
              6	         521825
              7	         521900
              8	         521998
              9	         522079
             10	         522191

real	0m33.008s
user	0m0.004s
sys	0m0.004s

$ time LD_PRELOAD="./libspeedhack.so" FRAC="3/1" test/test
              0	         156361
              1	         157584
              2	         158747
              3	         159628
              4	         160923
              5	         161807
              6	         162763
              7	         163935
              8	         164756
              9	         165553
             10	         166524

real	0m3.676s
user	0m0.003s
sys	0m0.006s

$

Like the AT&T program you linked, it overrides some libc calls to do so. That's what the LD_PRELOAD is for -- to make sure it gets loaded before libc does.

Last edited by Corona688; 11-06-2011 at 09:48 PM..
# 14  
Old 11-06-2011
Sounds amazing, but it appears you attached the unmodified libkeepalive, did you mean to do that?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Improve script - slow process with big files

Gents, Please can u help me to improve this script to be more faster, it works perfectly but for big files take a lot time to end the job.. I see the problem is in the step (while) and in this part the script takes a lot time.. Please if you can find a best way to do will be great. ... (13 Replies)
Discussion started by: jiam912
13 Replies

2. Solaris

Defunct process are generated after JNLP connection with a slave and the machine gets very slow

Hi everyone, I'm working on continous integration with Jenkins. I’m facing an issue while connecting a slave (solaris sparc 8) with Jenkins ver. 1.532.2 This slave is connected via the option “Launch slave via execution of command on the Master”. Connection is established with: -... (1 Reply)
Discussion started by: javaPIC
1 Replies

3. AIX

AIX 7.1 on Power 750 is very slow with no high memory or process consumption

Hi, This thread has been posted before on linuxquestions.org, but no answer, maybe because this is unix question and not linux. I'm posting the same thread here, hope I can get an answer from someone in the meantime, I wish I could post of emergency thread but it needs bits which I don't have :... (6 Replies)
Discussion started by: aLuViAn
6 Replies

4. Shell Programming and Scripting

Why is SED so slow?

I have many files which contain about two million lines. Now I want to use sed to delete the 9th line and add a new line behind the 8th line. I use the command as follows: for((i=1;i<100;i++)); do echo $i; sed -i '9d' $i.dat; sed -i '8a this is a new line' $i.dat; done But it is... (3 Replies)
Discussion started by: wxuyec
3 Replies

5. Shell Programming and Scripting

My attempt is FAR too slow

I have numerous (hundreds) of data files with various values in each file. The values are 1 per line, and identified by the fieldname in the 1st field in the line, which is delimited from the actual field value by a colon. So an example from one of the files looks like this: NAME: Bob Jones... (2 Replies)
Discussion started by: Finja
2 Replies

6. Solaris

Certain zones are slow

only the Tomcat serving ones. An oracle zone on the same global zone responds instantaneously. Running netstat results in a long wait. Cannot deploy builds with Jenkins to these web servers. Thoughts? (2 Replies)
Discussion started by: LittleLebowski
2 Replies

7. UNIX for Dummies Questions & Answers

Slow printing / CUPS - process "parallel" high cpu

Hello. I have a slackware system running cups with an HP laserJet 2100 connected via parallel port in ECP mode. Print jobs are working. Very slowly. 15K test print out of cups takes about 2 minutes to complete. When the printout is on the way to the printer, the process "parallel" uses... (0 Replies)
Discussion started by: agentrnge
0 Replies

8. HP-UX

Server become too slow

Hi, Since last week our server become too slow when we try to run application on it. When we run top command, it show as below: So it's nothing to do with heavy utilization, right? Can you give some opinion on what actually had happended? Thank you very much... :b: (4 Replies)
Discussion started by: yeazas
4 Replies

9. Post Here to Contact Site Administrators and Moderators

Slow

The site has gone slow for quite some time... Can you do somethin abt it (2 Replies)
Discussion started by: DPAI
2 Replies
Login or Register to Ask a Question