List:Internals« Previous MessageNext Message »
From:xiaobing jiang Date:March 23 2010 1:49pm
Subject:Re: Is that intentional or my configure error?
View as plain text  
code in include/my_pthread.h
/*
  statistics_xxx functions are for non critical statistic,
  maintained in global variables.
  When compiling with SAFE_STATISTICS:
  - race conditions can not occur.
  - some locking occurs, which may cause performance degradation.

  When compiling without SAFE_STATISTICS:
  - race conditions can occur, making the result slightly inaccurate.
  - the lock given is not honored.
*/
#ifdef SAFE_STATISTICS
#define statistic_increment(V,L) thread_safe_increment((V),(L))
#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
#define statistic_add(V,C,L)     thread_safe_add((V),(C),(L))
#define statistic_sub(V,C,L)     thread_safe_sub((V),(C),(L))
#else
#define statistic_decrement(V,L) (V)--
#define statistic_increment(V,L) (V)++
#define statistic_add(V,C,L)     (V)+=(C)
#define statistic_sub(V,C,L)     (V)-=(C)
#endif /* SAFE_STATISTICS */


On Tue, Mar 23, 2010 at 9:41 PM, Tianwei <tianwei.sheng@stripped> wrote:
> Hi, all,
>   I use the following configuration for mysql 5.0:
> CFLAGS="-O0 -g3" CC=gcc CXX=g++ CXXFLAGS="-O0  -g3
> -felide-constructors   -fno-exceptions -fno-rtti" ./configure
> --prefix=/home/tianwei/mysql-server/bin/ --enable-assembler
> I develop a tool which can detect lock usage, It gives the warning as:
>
> Mem: 0x32bf7c0 current lockset is: () previous lockset is: ()
> the thread id are: 7984 8140
> the ip and source files are: 0x006ada00
> /home/tianwei/mysql-server/5.0/sql/ha_myisam.cc:1605
> 0x006ad9f5 /home/tianwei/mysql-server/5.0/sql/ha_myisam.cc:1605
> the stack trace are:
> previous call stack is:
> current call stack is:
>
> I check ha_myisam.cc, it looks like:
> 1604   statistic_increment(table->in_use->status_var.ha_read_next_count,
> 1605                      
> &LOCK_status);
>
> the assembly code for this is:
>   6ad9f5:       48 8b 90 d0 0a 00 00    mov  
>  0xad0(%rax),%rdx
>   6ad9fc:       48 83 c2 01        
>     add    $0x1,%rdx
>   6ada00:       48 89 90 d0 0a 00 00    mov  
>  %rdx,0xad0(%rax)
>
> I check the .ii file which seems that the statistic actually do not
> use lock or atomic_inc,
> int ha_myisam::index_next(byte * buf)
> {
>   ;
>   (table->in_use->status_var.ha_read_next_count)++;
>   int error=mi_rnext(file,buf,active_index);
>   table->status=error ? 2: 0;
>   return error;
> }
>
> I am new for mysqld, I think there should be some configuration flag
> which can enable this, such as not define "HAVE_ATOMIC_ADD" to enable
> pthread lock/unlock pair, or We just tolerate the race here because of
> the performance issue and we are OK because it's only statistic as the
> function name indicated?
> Can you give me some suggestions? I build mysqld with gcc/g++ 4.4.1 on
> Ubuntu 9.10(X86_64)
>
> Thanks so much.
>
> Tianwei
> --
> Sheng, Tianwei
> Inst. of High Performance Computing
> Dept. of Computer Sci. & Tech.
> Tsinghua Univ.
>
> --
> MySQL Internals Mailing List
> For list archives: http://lists.mysql.com/internals
> To unsubscribe:    http://lists.mysql.com/internals?unsub=1
>
>
Thread
Is that intentional or my configure error?Tianwei23 Mar
  • Re: Is that intentional or my configure error?xiaobing jiang23 Mar
    • Re: Is that intentional or my configure error?Tianwei23 Mar
  • Re: Is that intentional or my configure error?Sergey Vojtovich23 Mar
    • Re: Is that intentional or my configure error?Tianwei23 Mar
      • Re: Is that intentional or my configure error?Tianwei23 Mar
        • Re: Is that intentional or my configure error?Sergey Vojtovich23 Mar
        • Re: Is that intentional or my configure error?Konstantin Osipov23 Mar
Re: Is that intentional or my configure error?Tianwei24 Mar