summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2011-08-20 18:43:11 -0700
committerJoshua Haberman <jhaberman@gmail.com>2011-08-20 18:43:11 -0700
commitadb6580d9728c3533faf779812bd7f4c9b27170d (patch)
tree2aa721539ed7f067e26c2d6b16c657307700150b /benchmarks
parenta5e6a7b029850f77059800d6611f406b91f87dfe (diff)
Let the JIT emit hasbit-setting code in addition to calling a callback.
This leads to a major (20-40%) improvement in the parsetoproto2 benchmark with small messages. We now are faster than proto2 in all apples-to-apples comparisons, at least given the (admittedly limited) set of benchmarks in this source tree.
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/parsetoproto2.upb.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/benchmarks/parsetoproto2.upb.cc b/benchmarks/parsetoproto2.upb.cc
index 74d0680..75cff88 100644
--- a/benchmarks/parsetoproto2.upb.cc
+++ b/benchmarks/parsetoproto2.upb.cc
@@ -42,7 +42,6 @@ PROTO2_APPEND(bool, bool)
upb_flow_t proto2_setstr(void *m, upb_value fval, upb_value val) {
assert(m != NULL);
- upb_stdmsg_sethas(m, fval);
upb_fielddef *f = upb_value_getfielddef(fval);
std::string **str = (std::string**)UPB_INDEX(m, f->offset, 1);
if (*str == f->default_ptr) *str = new std::string;
@@ -72,7 +71,6 @@ upb_sflow_t proto2_startseq(void *m, upb_value fval) {
upb_sflow_t proto2_startsubmsg(void *m, upb_value fval) {
assert(m != NULL);
upb_fielddef *f = upb_value_getfielddef(fval);
- upb_stdmsg_sethas(m, fval);
google::protobuf::Message *prototype = (google::protobuf::Message*)f->prototype;
void **subm = (void**)UPB_INDEX(m, f->offset, 1);
if (*subm == NULL || *subm == f->default_ptr)
@@ -183,8 +181,13 @@ static void layout_msgdef_from_proto2(upb_msgdef *upb_md,
uint32_t hasbit = (r->has_bits_offset_ * 8) + proto2_f->index();
// Encapsulation violation END
+ if (upb_isseq(upb_f)) {
+ // proto2 does not store hasbits for repeated fields.
+ upb_f->hasbit = -1;
+ } else {
+ upb_f->hasbit = hasbit;
+ }
upb_f->offset = data_offset;
- upb_f->hasbit = hasbit;
upb_fielddef_setaccessor(upb_f, proto2_accessor(upb_f));
if (upb_isstring(upb_f) && !upb_isseq(upb_f)) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback