List:Internals« Previous MessageNext Message »
From:Robert Milkowski Date:January 12 2010 10:15am
Subject:Re: myisam_use_mmap = 1 but still lots of [p]read()s
View as plain text  
On 11/01/2010 00:13, Michael Widenius wrote:
> Hi!
>>>>>> "Robert" == Robert Milkowski<milek@stripped>  writes:
> Robert>  Hi,
> Robert>  Solaris 10 64bit x86, MySQL 5.1.41
> Robert>  Despite having myisam_use_mmap = 1 in my.cnf there are still lots of
> Robert>  pread(), read() syscalls to myisam data files. I can see that mysql
> Robert>  detected and honored (at least to some extend) the myisam_use_mmap
> Robert>  setting as if I do: pmap PID_of_mysql I can see myisam files being
> Robert>  mmaped like:
> <cut>
> Robert>  By looking at _mi_get_block_info() i can see at the beginning of the
> Robert>  function that it is calling my_read() which in turn is calling read()
> Robert>  syscall. It's a similar story with _mi_read_rnd_dynamic_record()
> function.
> Robert>  I haven't look closely at the code but it looks like changing the
> Robert>  discussed two functions to do memcpy() from a mmaped region or even
> Robert>  better set a pointer to mmap'ed region (assuming no modifications are
> Robert>  done) shouldn't be that hard.
> Robert>  During peak hours I can see several hundreds read()/s, sometimes even
> Robert>  more, and getting rid of all these syscalls would probably improve
> Robert>  performance.
> You are right;  Currently the myisam_use_mmap is not fully
> implemented.
> Looking quickly at the mi_dynrec.c code, it looks like the following
> functions needs to be fixed to get read of the reads:
> _mi_read_cache()
> _mi_read_rnd_dynamic_record()
> _mi_get_block_info()
> Should not be that much work.
> _mi_cmp_buffer() doesn't have to be changed as this is not used
> by MySQL.
> _mi_write_part_record() doens't have to be changed as the write calls
> are only used when writing to a buffer that will be written to end of
> file.
> Regards,
> Monty
> Creator of MySQL
Thanks for reply.
If I would like to contribute the changes (assuming I would find enough 
free time) how should I go about it?

Also the comment for send_results_to_client() function is wrong as the 
return code of 1 actually means that a query was cached while 0 means 
that it wasn't. The description of return codes 0 and 1 should be swapped.

This is how it looks at 5.1.x codebase:

   Check if the query is in the cache. If it was cached, send it
   to the user.

         1       Query was not cached.
         0       The query was cached and user was sent the result.
         -1      The query was cached but we didn't have rights to use it.
                 No error is sent to the client yet.

   This method requires that sql points to allocated memory of size:
   tot_length= query_length + thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE;

Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)

Robert Milkowski

myisam_use_mmap = 1 but still lots of [p]read()sRobert Milkowski9 Jan
  • re: myisam_use_mmap = 1 but still lots of [p]read()sMichael Widenius11 Jan
    • Re: myisam_use_mmap = 1 but still lots of [p]read()sRobert Milkowski12 Jan
      • Re: myisam_use_mmap = 1 but still lots of [p]read()sMichael Widenius12 Jan