Well, it seems the Ns_Cache functions weren't what I was looking for, but I
have an idea of what might work...

To ensure locality of the linked lists (of type Y objects), I can allocate a
stack of 4k or 8k and a stack access mutex as each type X object is created,
to be used to store the type Y objects associated with the new type X
object. And then by keeping a pointer to the top of the stack I can then add
type Y objects to the stack and keep them local to each other.

Then the type X objects could be put in hashes.

How does that sound?

Cheers,
Jason


On Mon, 15 Apr 2002 08:06:31 -0700, Jim Wilcoxson <[EMAIL PROTECTED]> wrote:

>When there is ordering involved, as Jason mentions, hashes/arrays don't
>work so great.  Random access to an arbitrary element is fast, but there
>has to be another data structure to remember the order.
>
>Lots of times we combine the two: put the data in hashes/arrays with keys,
>then keep a list containing the keys in the order you want.  This lets us
>store lots of data with each key without keeping all of it in a list,
>access it randomly very fast, and also access it sequentially in order(s).
>
>Jim
>
>>
>> To answer your question, there's no way to avoid the "Tcl tax" in
>> AOLserver.  But maybe that's not a bad thing.
>>
>> The linked lists are setting off warning alarms in my head.  Linked lists
>> are terrific if most of what you do is accessing your data items in a
>> serialized stream, but if you are going to be accessing an item here or an
>> item there,  you'll waste a lot of time traversing the list getting to the
>> item you want (unless your lists are very short), as compared with using
>> something else like, say, a hash.  But you don't want to implement hashes,
>>   you say?  As it turns out, Tcl is not just an interpreter, it's a library,
>>   and you can create hashes from C and maintain them, all without ever
>> messing with any actual Tcl language stuff.  And the Tcl libraries are
>> pretty good about bucket management and garbage collection when you use
>> them to manage your hashes.  Since you haven't told us much about your
>> underlying problem, I can't really say that linked lists are inappropriate
>> as a solution, but you should take a look at the functions in the Tcl
>> libraries related to hashes and see if they might serve your needs better.
>>    Also, I think AOLserver has C-based cache functions which allow you to
>> dedicate a chunk of memory to a hash-based cache, which might be even more
>> stuff you can use.
>>
>> (No idea about ColdStore, sorry.)
>>
>> Pete.
>>
>> On Sunday, April 14, 2002, at 10:32 PM, Jason Saunders wrote:
>>
>> > I'm designing a site written entirely in C-based modules - much of the
>> > work
>> > the modules do involves storing and reading small items of data (in the
>> > order of 40 bytes) in linked lists. The data will also stored in a
>> > database
>> > for backup, and for more general access. The reason to store it in linked
>> > lists is that it will be faster to store it in sorted form and then read
>> > directly from main memory, rather than read it from a database, sort it,
>> > build a linked list, manipulate the data, write to the database and then
>> > free the list.
>>

Reply via email to