Boost logo

Boost :

Subject: Re: [boost] [afio] Formal review of Boost.AFIO
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2015-08-28 05:30:13


On 08/28/2015 11:12 AM, Asbjørn wrote:
> On 28.08.2015 07:47, Thomas Heller wrote:
>> Now, on to your example about a 100 parallel reads, so let's
>> encapsulate it a
>> bit to concentrate on the important part:
>>
>> future<void> read_items(handle const & h)
>> {
>> vector<future<vector<char>>> reads;
>> reads.reserve(100);
>> for(std::size_t i = 0; i != 100; ++i)
>> {
>> reads.push_back(async_read(h, 4096, i * 4096));
>> }
>> // handle reads in some form ... for simplicity, just wait on all
>> //of them ...
>> return when_all(std::move(reads));
>> }
>>
>> No continuations, cool, eh?
>
> How would this affect performance?
>
> From what I can gather, with the current AFIO I should be able to issue
> the entire batch of async read/write's to copy a file, using a single
> buffer (by making a dependency chain using the preconditions).
>
> In your API, won't those read/write calls have to take the trip into
> user land for each step?
>
> Sorry if I misunderstood something and this is just noise.

It's actually 100% equivalent to what Niall posted. The performance
should increase as you avoid synchronization with the shared state of
the future holding the handle when attaching a continuation. The code in
question actually does not make a dependency chain but generates a
dependency tree with a depth of 2 where the future to the handle is at
the root and the future to the reads are direct children to this root.
What I've shown should actually make this clearer. read_items is
attached as the continuation to the asynchronously opened handle.

>
> Cheers
> - Asbjørn
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost

-- 
Thomas Heller
Friedrich-Alexander-Universität Erlangen-Nürnberg
Department Informatik - Lehrstuhl Rechnerarchitektur
Martensstr. 3
91058 Erlangen
Tel.: 09131/85-27018
Fax:  09131/85-27912
Email: thomas.heller_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk