added jit support for sproto.
Lua C
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 33 commits ahead, 134 commits behind cloudwu:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dynasm
Makefile
README.md
jit.h
jitx64.desc
lsproto.c
print_r.lua
sproto.c
sproto.h
sproto_jit.c
sproto_jit.h
sproto_type.h
sprotoparser.lua
test.lua
testall.lua

README.md

sproto-JIT

added JIT support for sproto. using dynasm.

I think this is not a good idea. Because sproto mainly to lua binding. so the preformance mainly in the callback function. Although using JIT encode/decode can reduce instruction dispatch, improve cache utilization. using jit is best only have 14% improvement. :(

you can set macro SPROTO_JIT to decide use the jit or interpreter mode at sproto.h.

require

currently only support POSIX X64.

benchmack

my cpu is i5@2.4GHz the sproto schema:

.Person {
  name 6 : string
  id 2 : integer
  email 9 : string

  .PhoneNumber {
    number 3 : string
    type 1 : integer
  }

  phone 7 : *PhoneNumber
}

.AddressBook {
  person 5 : *Person
}

Use the data:

local ab = {
  person = {
    {
      name = "Alice",
      id = 10000,
      phone = {
        { number = "123456789" , type = 1 },
        { number = "87654321" , type = 2 },
      }
    },
    {
      name = "Bob",
      id = 20000,
      phone = {
        { number = "01234567890" , type = 3 },
      }
    }
  }
}
library encode 1M times decode 1M times
sproto(no jit / nopack) 1.83s 5.96s
sproto(jit / nopack) 1.54s 5.11s

the overall increase of 14.7%