Weston Pace created ARROW-16008:
-----------------------------------

             Summary: [C++] It is more expensive than expected to create a 
default Result<T>
                 Key: ARROW-16008
                 URL: https://issues.apache.org/jira/browse/ARROW-16008
             Project: Apache Arrow
          Issue Type: Improvement
          Components: C++
            Reporter: Weston Pace
            Assignee: Weston Pace


I had expected:

{noformat}
Result<T> my_result;
T my_value;
{noformat}

to be more or less equivalent statements (as I think of Result<T> as a "T or 
Status variant").  However, a default result initializes itself with an error 
status and the error message must be allocated and copied.  As a result, it is 
considerably more expensive (100's of ns compared to 1's of ns).

I'm not certain how much of an issue this is however.  It's possible we don't 
often create default results or their creation is optimized out.  I prototyped 
a solution but did not see much change in any benchmarks.  So perhaps it is not 
something worth changing but I figured I'd open it up to discussion.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to