1. Passing sequences to functions & procedures / Memory limits in openEuphoria?

1) Are sequences passed by reference or by value in functions/procedures?

2) Is there a limit to the size of sequences (apart from the obvious physical limitation; RAM)?

ZNorQ aka. Kenneth

new topic     » topic index » view message » categorize

2. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

ZNorQ said...

1) Are sequences passed by reference or by value in functions/procedures?

Pass by value semantics is used, although this is implemented by passing pointers and doing copy-on-write.

ZNorQ said...

2) Is there a limit to the size of sequences (apart from the obvious physical limitation; RAM)?

ZNorQ aka. Kenneth

On 32bit, a sequence may have a maximum of 2^31 elements (though each of those items may be a sequence with its own 2^31 limit on elements, and so on). On 64bit, the maximum is 2^63 elements.

edit: I made a mistake. It's still 2^31 elements on a 64bit system.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

ZNorQ said...

1) Are sequences passed by reference or by value in functions/procedures?

As a technical matter, they are passed by reference. However, they are reference counted, and a sequence passed as a parameter will have a reference count of at least 2, meaning that any modifications will trigger a copy on write. This means that if you do not intend to modify the sequence, passing even large amounts of data is very cheap.

Of course, this also means that if you're modifying sequence parameters a lot, this can be a significant bottleneck. There are ways around this, and things that can be done to reduce the burden. In std/map.e, for instance, we go to a lot of effort to avoid copy on writes, as they would really drag down map performance.

ZNorQ said...

2) Is there a limit to the size of sequences (apart from the obvious physical limitation; RAM)?

The number of elements in a sequence is tracked by a signed 32-bit integer. Theoretically, a 64-bit machine and euphoria binary could have enough memory to store a sequence with more than 231 elements, but always on a 32-bit implementation, and in most practical cases under 64 bits, you'll run out of memory before you hit that barrier.

Matt

new topic     » goto parent     » topic index » view message » categorize

4. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

mattlewis said...

In std/map.e, for instance, we go to a lot of effort to avoid copy on writes, as they would really drag down map performance.

I think it should also be pointed out that std/map.e is based on std/eumem.e of which, "one use is to emulate PBR [pass-by-reference], such as Euphoria's map and stack types."

One can use std/eumem.e for a great and many thing! smile

-Greg

new topic     » goto parent     » topic index » view message » categorize

5. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

PBR; Thanks, this is very good news as I *usually* just perform read on large sequences; I was under the impression that passing any object was done by value. However, I would like to see the possibility to use pass-by-reference and having the ability to write on it without the copy. Is that something you are considering (I'm sorry if the question has been addressed a multitude of times before..)?

Memory usage; So, if I understand this correctly; I can have a sequence with an arbitrary collection of sequences and atoms that can amount to 2,147,483,648 items (2^31), and each of these "cells" can have a sequence with the same amount of objects, and this can go on on for each level..? If so, this is certainly good news, and I know now how to solve some of my memory-problems when handling big loads of data.

Signed integer; Why is the integer tracking the size of a sequence signed?

Last; I've been studying C plusplus for some time now, and absolutely love it, but guess what; I ALWAYS fall back to good'ol Euphoria. I have to give credit to all you guys that are keeping the language afloat. I lack the technical knowledge to be able to contribute, but I do promote the language every way I can in the business-environment I work in. If I create an application for business-purposes, I always include an about that gives reference to openEuphoria webpage. I would love to see Euphoria as a main-stream language.

Again, thanks for the feedback, and keep it up.

ZNorQ aka Kenneth.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

ZNorQ said...

PBR; Thanks, this is very good news as I *usually* just perform read on large sequences; I was under the impression that passing any object was done by value. However, I would like to see the possibility to use pass-by-reference and having the ability to write on it without the copy. Is that something you are considering (I'm sorry if the question has been addressed a multitude of times before..)?

It has certainly been talked about and thought about. I experimented a bit with this in my ooeu experiments. There are some tricky issues involved in implementation.

ZNorQ said...

Signed integer; Why is the integer tracking the size of a sequence signed?

This was how Rob implemented it. I'd guess that he figured it was big enough. And practically speaking, it should be.

Matt

new topic     » goto parent     » topic index » view message » categorize

7. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

PBR; Thanks, this is very good news as I *usually* just perform read on large sequences; I was under the impression that passing any object was done by value. However, I would like to see the possibility to use pass-by-reference and having the ability to write on it without the copy. Is that something you are considering (I'm sorry if the question has been addressed a multitude of times before..)?

mattlewis said...

It has certainly been talked about and thought about. I experimented a bit with this in my ooeu experiments. There are some tricky issues involved in implementation.

I can only imagine. The way it's implemented today should be sufficient for me in most cases.

Signed integer; Why is the integer tracking the size of a sequence signed?

mattlewis said...

This was how Rob implemented it. I'd guess that he figured it was big enough. And practically speaking, it should be.

I agree, just found it a bit strange, that's all (a conclusion based on ignorance on my part).

ZNorQ aka Kenneth

new topic     » goto parent     » topic index » view message » categorize

8. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

In a 32 bit OS the practical limit to how large a sequence you can use is imposed by the size of virtual address space that can be allocated. The size of the private virtual address space is 2 GB, independent of RAM size. The largest block that can be allocated will be substantially less than that, possible much less. The usage patterns of the sequence and RAM size will determine performance.

To exceed these limits you would need to use a 64 bit OS and 64 bit version of Euphoria.

In practice these limits are unlikely to be a problem.

new topic     » goto parent     » topic index » view message » categorize

9. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

LarryMiller said...

The size of the private virtual address space is 2 GB, independent of RAM size.

This varies by OS. It's 3GB in Linux/GNU for example: http://users.nccs.gov/fwang2/linux/lk_addressing.txt

It's possible to get a 4GB/4GB split and use up almost all of 4GB of ram in a single userspace program: http://lwn.net/Articles/39283/ http://stackoverflow.com/questions/6947261/4gb-4gb-kernel-vm-split (of course an Euphoria sequence couldn't use the full 4GB anyways as some space is taken up by libc et al).

LarryMiller said...

In a 32 bit OS the practical limit to how large a sequence you can use is imposed by the size of virtual address space that can be allocated. The largest block that can be allocated will be substantially less than that, possible much less. The usage patterns of the sequence and RAM size will determine performance.

To exceed these limits you would need to use a 64 bit OS and 64 bit version of Euphoria.

In practice these limits are unlikely to be a problem.

Agreed in full.

new topic     » goto parent     » topic index » view message » categorize

10. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

LarryMiller said...

In a 32 bit OS the practical limit to how large a sequence you can use is imposed by the size of virtual address space that can be allocated. The size of the private virtual address space is 2 GB, independent of RAM size. The largest block that can be allocated will be substantially less than that, possible much less. The usage patterns of the sequence and RAM size will determine performance.

To exceed these limits you would need to use a 64 bit OS and 64 bit version of Euphoria.

In practice these limits are unlikely to be a problem.

Yes. There's a lot of memory involved. Let's say you wanted to create a 3 billion element sequence of integers with 64-bit euphoria. Firstly, you have 24-bytes of overhead information stored by the sequence structure. This is pretty much nothing compared to where we're going, of course. Next, you'd have 24,000,000,008 bytes allocated to store your integers (one extra element is allocated as an end marker).

There are certainly machines that have a lot more RAM than these, but if you're throwing that much at a single data structure, I will say that you're doing it wrong and should look for a better way, because it's going to be painful.

Matt

new topic     » goto parent     » topic index » view message » categorize

11. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

In short, for Windows:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa366796%28v=vs.85%29.aspx

new topic     » goto parent     » topic index » view message » categorize

12. Re: Passing sequences to functions & procedures / Memory limits in openEuphoria?

Not really. Euphoria doesn't support using AWE to store its variables, so it's still limited to the virtual address space size.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu