Implement Liquid::ResourceLimits#64
Conversation
dylanahsmith
left a comment
There was a problem hiding this comment.
I think the performance improvement would mostly be significant within a capture tag at the moment. So you could try temporarily modifying the benchmark to wrap the benchmarked templates in a capture tag.
I expect it will also help with the assign tag and to reduce the instance variable lookup overhead on the resource limits object.
| resource_limits_t *resource_limits; | ||
|
|
||
| VALUE obj = TypedData_Make_Struct(klass, resource_limits_t, &resource_limits_data_type, resource_limits); | ||
|
|
There was a problem hiding this comment.
We can do any initialization here that doesn't depend on the initialize arguments and doesn't need to allocate any objects. In this case, we could even leverage the reset function for that purpose.
There was a problem hiding this comment.
I still think we should move resource_limits_reset(resource_limits); from the initialize method to this allocate function, which will also remove the need for having to use ResourceLimits_Get_Struct(self, resource_limits); there.
|
Thanks for the feedback @dylanahsmith! I changed the benchmark files to use capture tags, I think there is a slight improvement in performance, however the results are pretty noisy on my computer. Master: This branch: |
7b865ec to
43d77d3
Compare
|
Wow, that is a more significant difference in the benchmark than I expected. |
| resource_limits_t *resource_limits; | ||
|
|
||
| VALUE obj = TypedData_Make_Struct(klass, resource_limits_t, &resource_limits_data_type, resource_limits); | ||
|
|
There was a problem hiding this comment.
I still think we should move resource_limits_reset(resource_limits); from the initialize method to this allocate function, which will also remove the need for having to use ResourceLimits_Get_Struct(self, resource_limits); there.
dylanahsmith
left a comment
There was a problem hiding this comment.
A couple of minor things, otherwise, LGTM
|
|
||
| void resource_limits_increment_write_score(resource_limits_t *resource_limits, VALUE output) | ||
| { | ||
| Check_Type(output, T_STRING); |
There was a problem hiding this comment.
In #64 (comment) I meant that this should be done in resource_limits_increment_write_score_method to avoid doing it redundantly in the VM loop.
|
|
||
| void init_liquid_resource_limits() | ||
| { | ||
| id_bytesize = rb_intern("bytesize"); |
There was a problem hiding this comment.
This is unused, so can be removed now.
8b7dd88 to
b80f19f
Compare
Implements
Liquid::ResourceLimitsin C. It is roughly a translation of the Ruby code into C. I was not able to measure a significant speedup on the benchmarks.