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

use memory mapped files for the peer buffer #12

Merged
merged 4 commits into from Aug 14, 2016

Conversation

Projects
None yet
2 participants
@arvidn
Contributor

arvidn commented Aug 13, 2016

to preserve state between restarts with some simple unit tests

Show outdated Hide outdated mapped_file.hpp
@arvidn

This comment has been minimized.

Show comment
Hide comment
@arvidn

arvidn Aug 13, 2016

Contributor

one questionable thing, I think, is that the header size is not technically guaranteed to be a multiple of alignof(T) in mapped_vector. That should actually be pretty easy to fix.

Contributor

arvidn commented Aug 13, 2016

one questionable thing, I think, is that the header size is not technically guaranteed to be a multiple of alignof(T) in mapped_vector. That should actually be pretty easy to fix.

return;
}
this->threadid = threadid;

This comment has been minimized.

@arvidn

arvidn Aug 13, 2016

Contributor

I moved the thread id around a bit here, to have it be available in the constructor, in order to create unique names for the mapped files

@arvidn

arvidn Aug 13, 2016

Contributor

I moved the thread id around a bit here, to have it be available in the constructor, in order to create unique names for the mapped files

@@ -1247,12 +1259,6 @@ struct router_thread
int threadid;
};
void launch_router_thread(int threadid, std::vector<address> const& bind_addrs)

This comment has been minimized.

@arvidn

arvidn Aug 13, 2016

Contributor

I flattened this function into a lambda

@arvidn

arvidn Aug 13, 2016

Contributor

I flattened this function into a lambda

@@ -1466,15 +1489,16 @@ int main(int argc, char* argv[])
, std::ref(signals), std::ref(stats_timer), std::ref(ios)));
ios.run(ec);
for (auto& i : threads)

This comment has been minimized.

@arvidn

arvidn Aug 13, 2016

Contributor

the threads must be joined before destructed. the return below would cause a std::terminate in the thread destructors

@arvidn

arvidn Aug 13, 2016

Contributor

the threads must be joined before destructed. the return below would cause a std::terminate in the thread destructors

@ssiloti

This comment has been minimized.

Show comment
Hide comment
@ssiloti

ssiloti Aug 13, 2016

Contributor

lgtm, it would probably be a good idea to check the last modified time of the file and discard it if it is too old.

Contributor

ssiloti commented Aug 13, 2016

lgtm, it would probably be a good idea to check the last modified time of the file and discard it if it is too old.

@arvidn

This comment has been minimized.

Show comment
Hide comment
@arvidn

arvidn Aug 13, 2016

Contributor

Yeah, I was thinking about that too. I got a bit lazy and thought that the user could always just delete the file :)
maybe in another patch

Contributor

arvidn commented Aug 13, 2016

Yeah, I was thinking about that too. I got a bit lazy and thought that the user could always just delete the file :)
maybe in another patch

@arvidn

This comment has been minimized.

Show comment
Hide comment
@arvidn

arvidn Aug 13, 2016

Contributor

ok, fixed the alignment of T too

Contributor

arvidn commented Aug 13, 2016

ok, fixed the alignment of T too

Show outdated Hide outdated mapped_file.hpp
@ssiloti

This comment has been minimized.

Show comment
Hide comment
@ssiloti

ssiloti Aug 14, 2016

Contributor

lgtm

Contributor

ssiloti commented Aug 14, 2016

lgtm

@arvidn

This comment has been minimized.

Show comment
Hide comment
@arvidn

arvidn Aug 14, 2016

Contributor

rebased on top of master again

Contributor

arvidn commented Aug 14, 2016

rebased on top of master again

@arvidn arvidn merged commit dded993 into bittorrent:master Aug 14, 2016

@arvidn arvidn deleted the arvidn:memory-mapped-file branch Aug 14, 2016

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