In a 32-bit vector length image – as in standard vpp – vectors are limited to 
4g elements. That includes the main heap, which is a u8 * vector.

You’ll never manage to allocate a single vector larger than a significant 
fraction of 4gb.

Of course, you can mmap private memory of some arbitrary size and use it as you 
like. If you want to use normal vector functions (setting _vec_len, using 
vec_len / vec_add1/2, etc) on an arbitrary chunk of memory, you can use a 
variant of the following:

/*
* Hand-craft a static vector w/ length 1, so vec_len(vlib_mains) =1
* and vlib_mains[0] = &vlib_global_main from the beginning of time.
*
* The only place which should ever expand vlib_mains is start_workers()
* in threads.c. It knows about the bootstrap vector.
*/
/* *INDENT-OFF* */
static struct
{
  vec_header_t h;
  vlib_main_t *vm;
} __attribute__ ((packed)) __bootstrap_vlib_main_vector
  __attribute__ ((aligned (CLIB_CACHE_LINE_BYTES))) =
{
  .h.len = 1,
  .vm = &vlib_global_main,
};
/* *INDENT-ON* */

vlib_main_t **vlib_mains = &__bootstrap_vlib_main_vector.vm;

You can also build a vpp image w/ -DCLIB_VEC64=1, in which the main heap can be 
as large as you like and by implication an individual vector can be huge.

The standard technique for preallocating vectors is easy: vec_validate (vector, 
projected_max_size – 1); _vec_len(vector) = 0.

HTH... Dave


From: [email protected] <[email protected]> On Behalf Of 
[email protected]
Sent: Monday, June 18, 2018 3:50 AM
To: [email protected]
Subject: [vpp-dev] vec_validate Long Delay #vpp

Hi,

I have a problem when using vec_validate to allocate large memory size ( more 
than 5G ) , I am sure that i have enough memory on my system,
but vec_validate take so long time to allocate memory how can i decrease this 
delay time for allocate memory and how can calculate memory size
before allocate by vec_validate to ensure that system never get Core dump for 
loss of memory .

Thanks in advance



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#9636): https://lists.fd.io/g/vpp-dev/message/9636
Mute This Topic: https://lists.fd.io/mt/22400853/21656
Mute #vpp: https://lists.fd.io/mk?hashtag=vpp&subid=1480452
Group Owner: [email protected]
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to