thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mayan Moudgill <ma...@bestweb.net>
Subject Latest version of cthrift
Date Mon, 19 Apr 2010 14:03:41 GMT

I've got the latest version of cthrift, and added a couple of tweaks to 
the server that may be worth considering for thrift.

1. The memory allocated by the deserialization process will 
automatically be cleaned up after the server-side RPC is called, unless 
some specific parts are being marked as "keep". The interesting twist is 
that not only will that part be kept, but so will any substructures of it.

  For example, assume that we had a list of structures that contained 
strings. This would have several allocation points:
- the list
- each structure within the list
- each strings containted within each structure.
Without user-intervention, after the RPC function is invoked, all of 
these would get freed. However, if we marked a specific structure as 
being "keep", then that structure _and_ the strings contained in it will 
not be freed.

It's relatively straight-forward to implement. Since thrift structures 
are trees, if we keep a pointer (to a structure), we must also keep all 
pointers to substructures. Treating the pointers as a node in the thrift 
type tree, if we keep a pointer, we must keep all pointers in the 
sub-tree rooted at that pointer. By keeping track of the pre-order and 
post-order numbers of the memory allocated in the tree, we can identify 
the descendants of a keep node and not free them. The pre-order is the 
same as the order in which memory is allocated. The post-order is a 
little more complicated; in the cthrift implementation, we have a parse 
stack, and can keep track of the post-order number that way.

2. A cleanup function is introduced. This is a function that is called 
after the server-side RPC call is finished and the result has been 
written to the socket. It is possible for the call to setup cookies that 
can be passed from the RPC call to the cleanup.

I haven't paid too much attention to the thrift server side 
implementation; does equivalent function exist? Perhaps it can be 
modeled as a destructor or finalizer?



Mime
View raw message