-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
WiredTiger isn't aligning mutex and log structures.
Here's a test program:
$ cat t.c
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
__attribute__((aligned(64))) struct xx {
int a;
};
typedef struct xx XX;
struct __attribute__((aligned(64))) yy {
int a;
};
typedef struct yy YY;
int
main(void)
{
XX *a;
YY *b;
printf("sizeof XX: %zu\n", sizeof(XX));
a = malloc(10 * sizeof(XX));
printf("XX array element size: %zu\n",
(char *)&a[1] - (char *)&a[0]);
printf("sizeof YY: %zu\n", sizeof(YY));
b = malloc(10 * sizeof(YY));
printf("YY array element size: %zu\n",
(char *)&b[1] - (char *)&b[0]);
return (0);
}
$ gcc48 t.c; ./a.out
sizeof XX: 4
XX array element size: 4
sizeof YY: 64
YY array element size: 64
$ gcc5 t.c; ./a.out
sizeof XX: 4
XX array element size: 4
sizeof YY: 64
YY array element size: 64
$ clang t.c; ./a.out
t.c:5:16: warning: attribute 'aligned' is ignored,
place it after "struct" to apply attribute to type
declaration [-Wignored-attributes]
__attribute__((aligned(64))) struct xx {
^
1 warning generated.
sizeof XX: 4
XX array element size: 4
sizeof YY: 64
YY array element size: 64
Note clang complains; however, if you precede the struct declaration with a typedef:
typedef __attribute__((aligned(64))) struct xx {
int a;
} XX;
typedef struct __attribute__((aligned(64))) yy {
int a;
} YY;
then clang no longer detects the problem.
$ clang t.c; ./a.out sizeof XX: 4 XX array element size: 4 sizeof YY: 64 YY array element size: 64
WiredTiger's page-locks and log slots are not being aligned to 64B boundaries because of this problem.
- is depended on by
-
SERVER-20060 WiredTiger changes for MongoDB 3.1.8
-
- Closed
-
- links to