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

twoskip does a full munmap/mmap for every transaction in foreach #5

Closed
brong opened this Issue Jul 15, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@brong
Contributor

brong commented Jul 15, 2016

Discovered by Variomedia AG when they upgraded to 2.5.8 from 2.4 series and used twoskip as the default mailboxes.db.

You can trivially see this on Linux as well with an strace:

brong@wot:/src/cyrus-imapd$ /usr/cyrus/bin/cyr_dbtool -n /tmp/skiplist.db skiplist set a a
brong@wot:
/src/cyrus-imapd$ /usr/cyrus/bin/cyr_dbtool -n /tmp/skiplist.db skiplist set b b
brong@wot:/src/cyrus-imapd$ /usr/cyrus/bin/cyr_dbtool -n /tmp/skiplist.db skiplist set c c
brong@wot:
/src/cyrus-imapd$ /usr/cyrus/bin/cyr_dbtool -n /tmp/twoskip.db twoskip set a a
brong@wot:/src/cyrus-imapd$ /usr/cyrus/bin/cyr_dbtool -n /tmp/twoskip.db twoskip set b b
brong@wot:
/src/cyrus-imapd$ /usr/cyrus/bin/cyr_dbtool -n /tmp/twoskip.db twoskip set c c
brong@wot:/src/cyrus-imapd$ /usr/cyrus/bin/cyr_dbtool -n /tmp/skiplist.db skiplist show
a a
b b
c c
brong@wot:
/src/cyrus-imapd$ /usr/cyrus/bin/cyr_dbtool -n /tmp/twoskip.db twoskip show
a a
b b
c c

Here's the interesting bit of the skiplist show under strace:

mmap(NULL, 16384, PROT_READ, MAP_SHARED, 5, 0) = 0x7f37c1856000
sendto(3, "<182>Jul 15 22:54:20 025212C1/cy"..., 123, MSG_NOSIGNAL, NULL, 0) = 123
fcntl(5, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fcntl(5, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(5, {st_mode=S_IFREG|0600, st_size=232, ...}) = 0
stat("/tmp/skiplist.db", {st_mode=S_IFREG|0600, st_size=232, ...}) = 0
fcntl(5, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
writev(1, [{"a", 1}, {"\t", 1}, {"a", 1}, {"\n", 1}], 4a a
) = 4
fcntl(5, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(5, {st_mode=S_IFREG|0600, st_size=232, ...}) = 0
stat("/tmp/skiplist.db", {st_mode=S_IFREG|0600, st_size=232, ...}) = 0
fcntl(5, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
writev(1, [{"b", 1}, {"\t", 1}, {"b", 1}, {"\n", 1}], 4b b
) = 4
fcntl(5, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(5, {st_mode=S_IFREG|0600, st_size=232, ...}) = 0
stat("/tmp/skiplist.db", {st_mode=S_IFREG|0600, st_size=232, ...}) = 0
fcntl(5, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
writev(1, [{"c", 1}, {"\t", 1}, {"c", 1}, {"\n", 1}], 4c c
) = 4
fcntl(5, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(5, {st_mode=S_IFREG|0600, st_size=232, ...}) = 0
stat("/tmp/skiplist.db", {st_mode=S_IFREG|0600, st_size=232, ...}) = 0
fcntl(5, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
munmap(0x7f37c1856000, 16384) = 0

And the interesting bit of the twoskip show under strace:

mmap(NULL, 16384, PROT_READ, MAP_SHARED, 4, 0) = 0x7f1389e5f000
fcntl(4, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(4, {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
stat("/tmp/twoskip.db", {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
munmap(0x7f1389e5f000, 16384) = 0
mmap(NULL, 16384, PROT_READ, MAP_SHARED, 4, 0) = 0x7f1389e5f000
fcntl(4, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fcntl(4, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(4, {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
stat("/tmp/twoskip.db", {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
munmap(0x7f1389e5f000, 16384) = 0
mmap(NULL, 16384, PROT_READ, MAP_SHARED, 4, 0) = 0x7f1389e5f000
fcntl(4, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
writev(1, [{"a", 1}, {"\t", 1}, {"a", 1}, {"\n", 1}], 4a a
) = 4
fcntl(4, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(4, {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
stat("/tmp/twoskip.db", {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
munmap(0x7f1389e5f000, 16384) = 0
mmap(NULL, 16384, PROT_READ, MAP_SHARED, 4, 0) = 0x7f1389e5f000
fcntl(4, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
writev(1, [{"b", 1}, {"\t", 1}, {"b", 1}, {"\n", 1}], 4b b
) = 4
fcntl(4, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(4, {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
stat("/tmp/twoskip.db", {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
munmap(0x7f1389e5f000, 16384) = 0
mmap(NULL, 16384, PROT_READ, MAP_SHARED, 4, 0) = 0x7f1389e5f000
fcntl(4, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
writev(1, [{"c", 1}, {"\t", 1}, {"c", 1}, {"\n", 1}], 4c c
) = 4
fcntl(4, F_SETLKW, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(4, {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
stat("/tmp/twoskip.db", {st_mode=S_IFREG|0600, st_size=536, ...}) = 0
munmap(0x7f1389e5f000, 16384) = 0
mmap(NULL, 16384, PROT_READ, MAP_SHARED, 4, 0) = 0x7f1389e5f000
fcntl(4, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
close(4) = 0
munmap(0x7f1389e5f000, 16384) = 0

....

The fix will be to make lib/mappedfile.c less agressive about re-mmaping.

@brong

This comment has been minimized.

Show comment
Hide comment
@brong

brong Jul 15, 2016

Contributor

Fixed in 2.5 and master

Contributor

brong commented Jul 15, 2016

Fixed in 2.5 and master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment