Merge lp:~laurynas-biveinis/percona-server/bug1083058-5.1 into lp:percona-server/5.1

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 523
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1083058-5.1
Merge into: lp:percona-server/5.1
Diff against target: 72 lines (+10/-8)
1 file modified
Percona-Server/storage/innodb_plugin/srv/srv0srv.c (+10/-8)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1083058-5.1
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Sergei Glushchenko (community) g2 Needs Information
Stewart Smith (community) Approve
Review via email: mp+142298@code.launchpad.net

This proposal supersedes a proposal from 2013-01-06.

Description of the change

Fix bug 1083058 for 5.1.
http://jenkins.percona.com/job/percona-server-5.1-param/484/
No BT or ST, but blocking BT 16274 QA work.

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Lost part of the fix in the merge :(

review: Needs Fixing
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

...and made the previous comment on the wrong MP.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) :
review: Abstain
Revision history for this message
Stewart Smith (stewart) :
review: Approve
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Laurynas,

I'm not clearly understand why the loop (bpage != NULL) is needed in block @@ -3154,28 +3154,24 @@
And it seems to me that your change gives not the same result as the code before the change.
Before we tried to find page with same space and offset as stored in prev_flush_info.
Depending on was page found or not, we had as output:

found:
  blocks_num == length of flush_list before we started scan
  new_blocks_num == the number of flush_list entries we scanned by going all the way from beginning to the end (list length after we finished scan?)

not found:
  blocks_num == new_blocks_num == length of flush_list before we started scan

It seems to me that if we take flush_list_mutex new_blocks_num should always be equal to blocks_num and

flushed_blocks_num = prev_flush_info.count

and loop above is just burning CPU cycles with no reason for it.

You changed the meaning of new_blocks_num to number of items we scanned before found the match. Was it intentional?

Also there are only few lines between releasing flush_list_mutex and grabbing it again in lines 3174 and 3182 and they are should be executed very quickly (just simple math), so dealing with mutex is much more expensive than that lines.

review: Needs Information (g2)
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Sorry, didn't notice that the break in the loop was there before this MP :) So the only notice is why not to remove mutex_exit(&flush_list_mutex); before flushed_blocks_num and mutex_enter few lines further.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

It gives a chance for other threads to grab the flush list mutex and run.

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

OK, but code in lines 3182-3190 again is the few assignments which should be done very fast. Does it make sense to release and grab mutex again to execute very this piece of code?

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Indeed.

review: Needs Fixing
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Too late, the 5.5 branch has been merged. I'll file a bug.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/storage/innodb_plugin/srv/srv0srv.c'
2--- Percona-Server/storage/innodb_plugin/srv/srv0srv.c 2012-12-14 22:29:39 +0000
3+++ Percona-Server/storage/innodb_plugin/srv/srv0srv.c 2013-01-08 12:04:26 +0000
4@@ -3154,28 +3154,24 @@
5
6 /* prev_flush_info should be the previous loop's */
7 {
8- lint blocks_num, new_blocks_num, flushed_blocks_num;
9- ibool found;
10+ lint blocks_num, new_blocks_num = 0;
11+ lint flushed_blocks_num;
12
13+ mutex_enter(&flush_list_mutex);
14 blocks_num = UT_LIST_GET_LEN(buf_pool->flush_list);
15 bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
16- new_blocks_num = 0;
17
18- found = FALSE;
19 while (bpage != NULL) {
20 if (prev_flush_info.space == bpage->space
21 && prev_flush_info.offset == bpage->offset
22 && prev_flush_info.oldest_modification
23 == bpage->oldest_modification) {
24- found = TRUE;
25 break;
26 }
27 bpage = UT_LIST_GET_NEXT(flush_list, bpage);
28 new_blocks_num++;
29 }
30- if (!found) {
31- new_blocks_num = blocks_num;
32- }
33+ mutex_exit(&flush_list_mutex);
34
35 flushed_blocks_num = new_blocks_num + prev_flush_info.count
36 - blocks_num;
37@@ -3183,6 +3179,7 @@
38 flushed_blocks_num = 0;
39 }
40
41+ mutex_enter(&flush_list_mutex);
42 bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
43
44 prev_flush_info.count = UT_LIST_GET_LEN(buf_pool->flush_list);
45@@ -3190,7 +3187,9 @@
46 prev_flush_info.space = bpage->space;
47 prev_flush_info.offset = bpage->offset;
48 prev_flush_info.oldest_modification = bpage->oldest_modification;
49+ mutex_exit(&flush_list_mutex);
50 } else {
51+ mutex_exit(&flush_list_mutex);
52 prev_flush_info.space = 0;
53 prev_flush_info.offset = 0;
54 prev_flush_info.oldest_modification = 0;
55@@ -3216,6 +3215,7 @@
56 } else {
57 /* store previous first pages of the flush_list */
58 {
59+ mutex_enter(&flush_list_mutex);
60 bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
61
62 prev_flush_info.count = UT_LIST_GET_LEN(buf_pool->flush_list);
63@@ -3223,7 +3223,9 @@
64 prev_flush_info.space = bpage->space;
65 prev_flush_info.offset = bpage->offset;
66 prev_flush_info.oldest_modification = bpage->oldest_modification;
67+ mutex_exit(&flush_list_mutex);
68 } else {
69+ mutex_exit(&flush_list_mutex);
70 prev_flush_info.space = 0;
71 prev_flush_info.offset = 0;
72 prev_flush_info.oldest_modification = 0;

Subscribers

People subscribed via source and target branches