Sunday, February 11, 2007

Of Prims and Sims, I

Written 1 February, 2007

Of Prims and Sims

Part I

Of Sims

A Second Life simulator, or sim, consists of a server somewhere on the Linden Lab properties, running a portion of SL.

Forsaken, my sim, runs on its own processor on its own mother board in its own case, stacked amidst and sandwiched between, thousands, and maybe tens of thousands, of identical servers.

While the hardware is identical and the three-dimensional virtual arrays generated by the servers are the same, the data that fill those arrays are highly individualized, creating the wondrous complexity that is Second Life. We live, we build our homes, we position our pose balls, we walk around in those arrays.

Each simulator generates a space 255 x 255 meters in size. That’s 65,025 square meters, room enough for more than fifteen 4096 lots or more than 127 First Land-sized (512 sq m) parcels.

Pretty big, in other words— but not really. We’re talking about a space only a little more than 750 feet on a side.

The array isn’t two-dimensional, but three-dimensional, for Second Life isn’t flat. The terrain has not only length and breadth, but height, allowing Avatars to move vertically as well as along N/S and E/W lines.

Adding a third dimension to an array is a big memory eater. Consider:

255 x 255 grid = 65025

255 x 255 x 100 grid: 6,502,500

That assumes that one meter is a single unit. In actuality, there are an almost infinite number of sub-positions within each cubic meter of Second Life— as best I can figure, 1000 locations in each of the three directions, or 10,000,000 in all.

So if it would take 6.5 million units to make an SL sim with a maximum height, how many units would it take to map a grid 15,000,00 meters high?

Sit down for this one.

Oh, crap. Overflow error code on my three dollar calculator.

You mean I have to calculate it by HAND?

Carry the one, dah dah da de dum, dum, total it all...


Nearly a billion units. No, no, I meant a trillion!

Now multiply that by the 10,000,000 sub-positions within each cubic meter, and you get.

A really big number.

9.75 x 10 ^17, if I counted my zeros correctly.



Of Prims

One of the biggest difficulties in SL—to me, at least—is the limitations on primitives.

A primitive, or prim, is a single object in SL, one of a half-dozen basic shapes. Prims can be as large as 10x10x10 meters in size, and they can be twisted, tapered, sheared and bent, textured and colored, turned phantom, temporary, or physical, and made to give off light. Best of all, they can be linked with other prims to make complex objects. Everything you see in SL is made of prims.

Prims are limited in size. This is frustrating because to make large things like walls or floors you must use multiple prims to make an object you could otherwise make with a single prim. And it’s made even more frustrating because Linden Lab has set a cap to the number of prims allowed on any particular piece of land.

It’s not, IMO, a reasonable limit.

Each 512 sq. meter plot of land is allotted 117 prims. That doesn’t go very far. With careful planning, it’s a house, a bed, a couch, and a few trees or pieces of art. With poor planning, it’s a single basket of fruit or one chaise lounge.

The sim servers must make a number of calculations for each prim, including size, location, rotation, the amount they’re twisted or otherwise warped, the material of which they’re made, their surface roughness, their color and texture, their shininess, and, if they’re part of a linked set, their relationship to other objects. And then the severs must map each of the 15,000 or so prins in each simulator and rez them within that huge to-the-seventeenth-power array—and then move them about smoothy and immediately when you grab and drag them.

That’s a lot of calculations. And a lot of memory. And that's for only one sim. There are tens of thousands of sims!

By far, or so it would seem, the biggest drain on sim resources is that ceiling, which surpasses 15,000,000 meters.

Why did Linden Lab make the grid more than 15,000,000 meters high? Why generate such a huge, memory-eating array? Why not limit the maximum height to something reasonable—750 meters, say?

Maybe they did.

My friend Mordecai Scaggs reports that building is difficult above 750 meters. I’m not sure what happens, but I’ve been curious to find out. Sounds like a matter for the Icarus Society to investigate.

Here’s what I suspect.

I suspect the grid only does go to 750 meters. Above that, I imagine, the simulators temporarily create and erase space on the fly for high-flying avatars. Or maybe there’s just a single space and it jumps along with the avatar as height increases or decreases.

Not being in the confidence of Linden Lab, most likely I’ll never know. But it makes sense.


Of Sims and Prims

I had a further thought.

Suppose NONE of the spaces in Linden Lab actually exist in a permanent array.

That’s not a metaphorical question.

I mean, what if space is generated on as-needed basis. Perhaps space in SL, and the objects that occupy that space, are generated only when they are within the field of vision of an avatar. When no one is looking, they are derezzed, the array taken down.

Perhaps there’s no real grid at all, just pieces of it which constantly come and go.

The algorhym for this on-the-fly calculating might be difficult, but it would save a lot of processor horsepower.

I may be on the track of the answer to “If a tree falls and no one is around to hear it, does it make a sound?”

Prim Exchange

All of this ties in with an idea I had a while back.

Why not start a prim exchange?

Why doesn’t Linden Lab write routines to let an overtaxed sim borrow from the prim (processor power) resources of an underused sim?

If that were to happen, one could buy and sell prims as if they were Lindens.

Just an idea.

Just foolish speculation.

Just my nerdiness manifesting itself.

Or maybe it’s brain damage caused by the thin atmosphere at 15,00,000 meters.



Anonymous said...

To correct your understanding: Second Life doesn't have some massive 3D array for every millimeter of the world. That would be prohibitively expensive. Instead, SL tracks the position of each prim as a single, 3D vector (three integers, in fact). Empty space is totally free. A thousand miles of flat, empty desert is cheaper than your house.

I have no idea why Linden Labs charges for physical space -- there's no technical reason for it. In a server, all that counts is memory, time, and bandwidth. That SL charges for volume indicates the LL has issues

Anonymous said...

...and as for your idea (borrowing prim resources from under-utilized sims), that's a well-known and often-used technique called "load balencing".

I've no idea why they're not doing it.