Question: **WHAT I WANT**

Call an action and see it succeed at the first execution.

**WHAT IS NOT WORKING**

The function, which I am executing, the first time fails with error:

> 
> Error 3080006: Transaction took too long
> 
> 
> Error Details:
> deadline exceeded
> 
> 
> pending console output:
> 
> 
> 

**WHAT IS WORKING**

The second time the transaction **completes** in 7784 us!!!

**CLEOS**

`cleos push action mycontract action1 '[]' -p mycontract@active`

Answer: 
The execution time is based on many factors in each execution. 

It could be the cache missing or process management could blocks the nodeos process and makes the execution time exceeds the `max-transaction-time`.

The `max-transaction-time` set by nodeos on startup or in the config file controls the time to throw the Error 3080006. The default value is `30ms`. Trying to set a greater value on `max-transaction-time` would help.
Due to its subjective nature, transaction execution time is likely to vary each time it is executed. It would take longer time to execute on a slower machine while short time to execute on a faster machine. However, the maximum time a transaction is allowed to execute is 30ms. So if a node can't execute your transaction within 30ms, your transaction is considered failed and will not be broadcast to the network. You can either:

1. Push the same transaction multiple times, hoping somehow it can be finished within 30ms.
2. (recommended) Optimize your code, given the fact that EOS transfer action can be done in around 0.1ms.