Sorry to revive a dead thread.
I have also been playing with an interpreter and found that increasing the
size of runtime.staticuint64s helps with the convT64 issue a lot.
https://github.com/golang/go/blob/aa8262d800f0cba2e4d4472a7e344eb60481b0ff/src/runtime/iface.go#L493-L526
I'm guessing that
Wow -- yes, that's pretty significant! (Though point taken about "real
workloads".) Thanks for sharing this.
On Tuesday, December 22, 2020 at 11:44:25 PM UTC+13 arn...@gmail.com wrote:
> Luckily, I have the "no scalar" version with a build tag. Here is a
> simple benchmark:
>
> func BenchmarkV
Luckily, I have the "no scalar" version with a build tag. Here is a simple
benchmark:
func BenchmarkValue(b *testing.B) {
for n := 0; n < b.N; n++ {
sv := IntValue(0)
for i := 0; i < 1000; i++ {
iv := IntValue(int64(i))
sv,
Nice! Do you have any benchmarks on how much faster the "scalar" version is
than the non-scalar?
On Tuesday, December 22, 2020 at 12:58:19 AM UTC+13 arn...@gmail.com wrote:
> Just an update (in case anyone is interested!). I went for the approach
> described below of having a Value type holdin
Just an update (in case anyone is interested!). I went for the approach
described below of having a Value type holding a scalar for quick access to
values that fit in 64 bits (ints, floats, bools) and an interface fo for
the rest.
type Value struct {
scalar uint64
iface int
Ah interesting, I guess that could mean I would need to switch to using
reflect.Value as the "value" type in the Lua runtime. I am unclear about
the performance consequences, but I guess I could try to measure that.
Also, looking at the implementation of reflect, its seems like the Value
type
FWIW, not that you *should* do it, but you *could* enact your original plan
using unsafe:
https://play.golang.org/p/W9Ntzxif_ol
I don't think it's advisable though - among other things, the compiler
might well conclude that `i` doesn't change in this code and eliminate the
repeated loads at some po
(sorry about the code formatting gone wrong, I replied in gmail it it seems
to have removed all indentation!)
On Wednesday, 16 December 2020 at 10:15:07 UTC Arnaud Delobelle wrote:
> Hi Ben, that's an interesting idea. I considered it at the start but
> didn't go for it in the end (I can't remem
Hi Ben, that's an interesting idea. I considered it at the start but
didn't go for it in the end (I can't remember why exactly, probably
because that would make it quite a big struct for Lua). There is a
possibility that I could adapt it a bit and have something like
type Value struct {
scal
Unfortunately for you, interfaces are immutable. We can't provide a means
to create an interface from a pointer, because then the user can modify the
interface using the pointer they constructed it with (as you were planning
to do).
You could use a modifiable reflect.Value for this.
var i int6
Nice project!
It's a pity Go doesn't have C-like unions for cases like this (though I
understand why). In my implementation of AWK in Go, I modelled the value
type as a pseudo-union struct, passed by value:
type value struct {
typ valueType // Type of value (Null, Str, Num, NumStr)
s
11 matches
Mail list logo