Changeset 12080


Ignore:
Timestamp:
07/31/09 19:58:50 (14 years ago)
Author:
ehuelsmann
Message:

Move stack sampling to the scheduling thread.

Note: This commit removes the need for checks in the

main thread whether or not the sampling interval
has expired, i.e. a penalty for all those cases
where we don't actually are profiling.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/LispThread.java

    r12077 r12080  
    554554    }
    555555
    556     private void doProfiling()
    557         throws ConditionThrowable
    558     {
    559         if (sampleNow)
    560             Profiler.sample(this);
    561     }
    562 
    563556    public final void pushStackFrame(LispObject operator)
    564557        throws ConditionThrowable
    565558    {
    566559        stack = new StackFrame(operator, stack);
    567         doProfiling();
    568560    }
    569561
     
    572564    {
    573565        stack = new StackFrame(operator, arg, stack);
    574         doProfiling();
    575566    }
    576567
     
    580571    {
    581572        stack = new StackFrame(operator, first, second, stack);
    582         doProfiling();
    583573    }
    584574
     
    588578    {
    589579        stack = new StackFrame(operator, first, second, third, stack);
    590         doProfiling();
    591580    }
    592581
     
    595584    {
    596585        stack = new StackFrame(operator, args, stack);
    597         doProfiling();
    598586    }
    599587
     
    620608        }
    621609        finally {
    622             doProfiling();
    623610            popStackFrame();
    624611        }
     
    637624        }
    638625        finally {
    639             doProfiling();
    640626            popStackFrame();
    641627        }
     
    655641        }
    656642        finally {
    657             doProfiling();
    658643            popStackFrame();
    659644        }
     
    673658        }
    674659        finally {
    675             doProfiling();
    676660            popStackFrame();
    677661        }
     
    692676        }
    693677        finally {
    694             doProfiling();
    695678            popStackFrame();
    696679        }
     
    711694        }
    712695        finally {
    713             doProfiling();
    714696            popStackFrame();
    715697        }
     
    731713        }
    732714        finally {
    733             doProfiling();
    734715            popStackFrame();
    735716        }
     
    754735        }
    755736        finally {
    756             doProfiling();
    757737            popStackFrame();
    758738        }
     
    777757        }
    778758        finally {
    779             doProfiling();
    780759            popStackFrame();
    781760        }
     
    793772        }
    794773        finally {
    795             doProfiling();
    796774            popStackFrame();
    797775        }
  • trunk/abcl/src/org/armedbear/lisp/Profiler.java

    r12076 r12080  
    3737{
    3838    private static int sleep = 1;
    39 
    40     public static final void sample(LispThread thread)
    41         throws ConditionThrowable
    42     {
    43         sampleNow = false;
    44         thread.incrementCallCounts();
    45     }
    46 
    47     private static final Runnable profilerRunnable = new Runnable() {
    48         public void run()
    49         {
    50             profiling = true; // make sure we don't fall through on the first iteration
    51             while (profiling) {
    52                 sampleNow = true;
    53                 try {
    54                     Thread.sleep(sleep);
    55                 }
    56                 catch (InterruptedException e) {
    57                     Debug.trace(e);
    58                 }
    59             }
    60         }
    61     };
    6239
    6340    // ### %start-profiler
     
    10683                if (sampling) {
    10784                    sleep = Fixnum.getValue(second);
    108                     thread.resetStack();
     85                    Runnable profilerRunnable = new Runnable() {
     86                        public void run()
     87                        {
     88                            profiling = true; // make sure we don't fall through on the first iteration
     89                            while (profiling) {
     90                                try {
     91                                    thread.incrementCallCounts();
     92                                    Thread.sleep(sleep);
     93                                }
     94                                catch (InterruptedException e) {
     95                                    Debug.trace(e);
     96                                }
     97                                catch (ConditionThrowable e) {
     98                                    break;
     99                                }
     100                            }
     101                        }
     102                    };
    109103                    Thread t = new Thread(profilerRunnable);
    110104                    // Maximum priority doesn't hurt:
Note: See TracChangeset for help on using the changeset viewer.