Jump to content

llGetNotecardLineSync()


Cain Maven
 Share

You are about to reply to a thread that has been inactive for 68 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Is it actually widely available, though?

I have scripter friends that say their scripts using llGetNotecardLineSync() refuse to compile...

 

EDIT: Yup, does not compile for me. And I'm on RC LeTigre region.

Edited by primerib1
  • Thanks 1
Link to comment
Share on other sites

 I'm on Bluesteel.  The server version the new notecard is included in went out to Blue Steel 2 weeks ago, but there was an issue that was revealed (I don't think it was with the notecard function) that forced a delay.  An updated server version went out again to Blue Steel last Wed.  providing nothing else broke it should roll on out to the main channel tomorrow (maybe).

  • Thanks 2
Link to comment
Share on other sites

From the Server Users Group meeting today:  the server version that has the new note card sync function should move the rest of the RC regions tomorrow and possibly to the main grid next week.  I guessed wrong, or remembered wrong.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

1 minute ago, Anna Salyx said:

From the Server Users Group meeting today:  the server version that has the new note card sync function should move the rest of the RC regions tomorrow and possibly to the main grid next week.  I guessed wrong, or remembered wrong.

Thanks again!

 

Link to comment
Share on other sites

14 hours ago, Anna Salyx said:

From the Server Users Group meeting today:  the server version that has the new note card sync function should move the rest of the RC regions tomorrow and possibly to the main grid next week.  I guessed wrong, or remembered wrong.

Thanks for the update!

If LeTigre has it after today's restart, I can start testing my scripts for faster notecards.

  • Like 2
Link to comment
Share on other sites

I have some code I wrote that might help some understand how to use llGetNotecardLineSync Please feel free to comment.

/////
//  Generic llGetNotecardLineSync Notecard reader by Jenwen Walpole
//  Given freely  
// 
//  This will read a notecard and insure notecard line read happens succesfuly 
//  no matter if the notecard is cached or not.
//  The code will make use of cache reads for as long as the notecard is cached and use llGetNotecardLine when not.
/////

integer iNoteCardLine;
string sNotecardName = "mynotecard";
key kCurrentDataRequest;

default
{
    state_entry()
    {
    }
    touch_start(integer total_number)
    {
     iNoteCardLine = 0; // reset back to zero in case there was a prior read
     // first line read is conventional llGetNotecardLine read to make the server cache the notoecard.
     kCurrentDataRequest = llGetNotecardLine( sNotecardName, iNoteCardLine );   
    }
    
  dataserver( key kQuery, string sData )
    { 
    if (kCurrentDataRequest == kQuery)
        { 
        if(  sData != EOF ) 
            {
            llOwnerSay(sData);
            }
        else 
            {
            llOwnerSay("EOF"); 
            return;
            }
        iNoteCardLine++;
        while (TRUE)
            {
            sData=llGetNotecardLineSync(sNotecardName, iNoteCardLine);
                if (sData == NAK)
                    {
                    // on a NAK  reread  using llGetNoteardLine
                    // this will both re-cache and succsesully read the line
                    llOwnerSay("NAK");
                    kCurrentDataRequest = llGetNotecardLine( sNotecardName, iNoteCardLine );
                    return;
                    }
                 if (sData == EOF)
                    {
                    llOwnerSay("EOF");
                    return;
                    }
                else
                    {                   
                    llOwnerSay(sData);
                    iNoteCardLine++;
                    }
             } 
        } 
    }       
}

 

  • Like 5
Link to comment
Share on other sites

For me, the issue is more about simplicity (or lack of) in code structure as much as speed of reading NC lines.  This is rarely a time critical task (and if it is perhaps its the wrong tool).  We seem to have half a loaf in that a DS event of some sort has to be raised in order to ensure the NC is cached, or we need some exception handling etc. 
In coding remember  SSSS - Simple Structure Saves Sanity   😀 

I have an alternative suggestion, but I fear this ship has sailed as it were.

string llGetNotecardLineAmbiguous(string name, integer index, integer wait)

If the NC is cached the result (data or EOF) is returned right away;
if it is NOT cached then,
- if wait == TRUE the server pulls the NC into cache and then returns the requested line (or EOF; or NAK if the NC does not exist)
  so yes there may be a delay (as there would be for the DS event to be raised)
- if wait == FALSE the server returns NAK immediately

(yes NAK is overloaded, better to have different constants for "NC doesnt exist" and "NC not cached")

What do people think?

PS:  small prize for coming up with a better name!!  My first try was using Ambivalent but i realised that is literally inappropriate!

 

 

Edited by JoyofRLC Acker
Link to comment
Share on other sites

2 hours ago, JoyofRLC Acker said:

Another question about cacheing - and apologies if this is a silly question.

The cache is server specific?  Even for an attached HUD?  So if an agent moves to another sim then the NC has to be cahced all over again?

Yes, the caching is done per-sim.

  • Like 1
Link to comment
Share on other sites

51 minutes ago, Love Zhaoying said:

In case I missed it - does it appear that reading a single notecard line may be enough to cause the rest of the NC to get cached? (My "ready to use" code doesn't care either way, just checking..)

It's enough to get it cached (as is asking for the count of lines) but there's no guarantee it will stay cached for any length of time. It's possible the notecard will be cached to fire the dataserver event and then the region crashes or is restarted before even a single llGetNotecardLineSync can return, or at any time thereafter, so then it'll need to be recached before any -Sync calls can proceed.

Of course it's much more probable that once cached the notecard can be synchronously read to the end, so from a performance standpoint it's a huge win. But still need to handle those NAK exceptions at any time, so the program flow can't be that simple.

  • Thanks 1
Link to comment
Share on other sites

Just tried my loader with sync finally (the code I wrote a few weeks ago when this thread finally started but llGetNotecardLineSync() was not actually supported yet) - it went from 300 seconds to 47 seconds total load time.

I am loading 2 notecards of more than 64K total into LinksetData.

Part of the reason it still takes 47 seconds is, I am writing to debug output for every "thing" I write to LSD, and I had to change to debug write delay to 0.05 seconds from 0.02 seconds since with a delay of 0.02 seconds it was throttled and stopped writing.

I'll change my script later to only write every mod 10 entries to debug, and see how much faster it goes.

So far, so good!

Link to comment
Share on other sites

6 minutes ago, RobotGirlOwnedAndControlled said:

This function still won't compile for me... Am I being stupid - is there something I need to do to make it work? Firestorm is just throwing up an error every time I try to use it.

I honestly do not know if it is grid-wide yet, or if I just got lucky and it is on my simulator now.

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, Love Zhaoying said:

Just tried my loader with sync finally (the code I wrote a few weeks ago when this thread finally started but llGetNotecardLineSync() was not actually supported yet) - it went from 300 seconds to 47 seconds total load time.

I am loading 2 notecards of more than 64K total into LinksetData.

Part of the reason it still takes 47 seconds is, I am writing to debug output for every "thing" I write to LSD, and I had to change to debug write delay to 0.05 seconds from 0.02 seconds since with a delay of 0.02 seconds it was throttled and stopped writing.

I'll change my script later to only write every mod 10 entries to debug, and see how much faster it goes.

So far, so good!

I changed my debugging to only show the LSD key I'm writing every 10 loops, changed my llSleep() delay back to 0.02, and now it loads everything in 16 seconds.

Before Sync: 300 seconds

After Sync: 16 seconds (it actually varies at lot for each test, but 16 seconds is the low so far).

My script now completes about 18X faster.

 

Link to comment
Share on other sites

3 minutes ago, RobotGirlOwnedAndControlled said:

I just tried it in the normal SL viewer too - it's not working there either - I get the same error.

It compiles and works here on my land: http://maps.secondlife.com/secondlife/Pengallen Bridge/51/221/53

Here is a test program I threw together and tested just now, to read the first line of the first notecard in inventory. 

When I tried it, the first time the notecard was not cached, and the second time it was cached.

key hNotecard;

default
{
    state_entry()
    {
        
        string sNoteName;
        sNoteName = llGetInventoryName(INVENTORY_NOTECARD, 0);
       
        llOwnerSay("Testing llGetNotecardLineSync() for Notecard: " + sNoteName);
       
        string sResponse;
        sResponse = llGetNotecardLineSync(sNoteName, 0);
        if (sResponse==NAK) {   // NAK = Notecard is not cached
            llOwnerSay("Notecard is not cached, loading normally..");
            hNotecard = llGetNotecardLine(sNoteName, 0);
            return;
        }
        else {  // Not NAK = Notecard is cached
            llOwnerSay("Read Notecard with llGetNotecardLineSync(), Data: " + sResponse);
        }
 
        
    }

    dataserver(key RequestID, string data) {
        
        if (RequestID!=hNotecard)
            return;
        llOwnerSay("Read Notecard with llGetNotecardLine(), Data: " + data);
        
    }

}

 

Link to comment
Share on other sites

18 minutes ago, RobotGirlOwnedAndControlled said:

Ah yes - it DOES work at your place!! I just visited and tried it. I hope you don't mind the intruder 😉

 

Not at all, is why I gave you the SLURL.  Glad it works for you there.

I am lucky it worked for me, otherwise I would have gone back to "waiting" - I am too lazy to hunt down someplace that new functionality works!

Link to comment
Share on other sites

key nc;
key numlines;
default
{
    state_entry()
    {
        llLinksetDataReset();
        nc=llGetInventoryKey(llGetInventoryName(INVENTORY_NOTECARD,0));
        numlines=llGetNumberOfNotecardLines(nc);
    }
    on_rez(integer s)
    {
        llResetScript();
    }
    dataserver(key id, string m)
    {
        if(id==numlines)
        {
            integer ncl=(integer)m;
            llOwnerSay(m);
            integer i;
            for(i=0;i<ncl;i++)
            {
                string in=llGetNotecardLineSync(nc,i);
                llLinksetDataWrite("nc0L"+(string)(1+i/1000000.0),in);
            }
            llOwnerSay((string)llLinksetDataAvailable());
            llOwnerSay((string)llGetFreeMemory());
            llOwnerSay(llLinksetDataRead("nc0L1.000000"));
        }
    }
    changed(integer c)
    {
        if(c&CHANGED_INVENTORY)llResetScript();
    }
}
 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 68 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...