New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What goes in to defining the "per thread" memory calculation #481
Comments
I have been looking at this because of the huge difference in maximum memory consumption per thread between two otherwise similar servers (Same mariadb version, more or less stock config). |
Well... that's not strictly true though... max_allowed_packet doesn't get allocated entirely on every thread but instead, it is progressively increased as needed up to that maximum. So strictly speaking, you are not over-provisioning that much except if you always use for every connection the entire max_allowed_packet which is unlikely. What MySQLTuner shows is a worst-case-scenario but you need to apply your own judgment to estimate really how much memory it will use. One way is to see the actual max memory used since the server started minus global buffers and divide it by the max number of concurrent connections and then multiply that result to the max number of connections you will allow and add the global buffers again. MySQLTuner could help in that regard so maybe this issue could be taken as an enhancement idea. |
@ibaldonl I think that you idea to use the actual max memory since the server started minus global buffers, divided by max number of used connections is quite good. This could be displayed as a different metric, showing how much memory will mysql probably use if all of the connections are used. |
Thanks for the replies. Can I ask nicely that someone posts to this thread when a new version with this change is published? |
@ibaldonl did you already have something in mind on how to get the actually reached max memory usage of the mysql? |
Yeah, we shouldn't trust the virtual memory requested by applications and also that wouldn't work in a server without ssh access like for example cloud providers, etc. |
I tried to find this value you mentioned which would let me know how much memory did the MySQL actually request from the OS, but it doesn't appear to be there.
And here is how the max_total_per_thread_buffers is calculated: |
Doh! My bad! I thought there was a variable for that, didn't expect MySQLTunner to calculate it that way, sorry. |
Yes, but as you mentioned, this won't work on servers without SSH access, not to even mention the cross platform incompatibilities. |
Total buffers per thread wrong calculation major#628 Difference memory usage between versions major#546 Incorrect suggestion given by MYSQL Tuner - max_connections conf param major#506 MariaDb per thread wrong value major#502 Maximum possible memory usage: mysqlx_max_connections? major#489 Fix for the following issues: Incorrect values / figures major#487 What goes in to defining the "per thread" memory calculation major#481 calculation bug? major#475
Issue fixed with last PR: Fixing wrong calculation in memory usage (regression found) #679 Thanks for your patience and reporting this issue |
Hello!
Sorry, I'm relatively new to MySQL tuning and I've been looking in a couple of places to work out how exactly to optimize my db config.
Are you able to confirm what goes in to the "per thread" memory calculation?
Total buffers: 248.0M global + 17.1M per thread (75 max threads)
The "obvious" items I can see are:
(the script used to generate this is:
MEM_PER_CONN=VAR["read_buffer_size"] + VAR["read_rnd_buffer_size"] + VAR["sort_buffer_size"] + VAR["join_buffer_size"] + VAR["binlog_cache_size"] + VAR["thread_stack"] + VAR["tmp_table_size"]
)Is there something I'm missing, because this calc only comes out to 9.1MB, 8MB shy of the calculation being shown by MySQLTuner
The text was updated successfully, but these errors were encountered: