Showing posts with label management. Show all posts
Showing posts with label management. Show all posts

Tuesday, October 15, 2024

Math: Convolution for RSU vestings

 Probably pretty late, but I just realized that when computing compensation per year based on stock vests, you are essentially running a convolution of two lists. 

L1 = Vesting schedule

E.g. if the vesting schedule per year is 10% for Y1 and Y2 followed by 40% for Y3 and Y4, we could represent L1 = [0.1, 0.1, 0.4, 0.4]

L2 = RSUs allocated per year. Consider an example where you get 500 for Y1, 300, 400, 200 for the remaining years respectively.

Running the convolution across these lists:

Vesting schedule

Grants       [500 300 400 200]

Plan [0.4, 0.4, 0.1, 0.1]

$(Y1) = 500 * 0.1 = 50


Yr2

Vesting schedule

Grants       [500 300 400 200]

Plan [0.4, 0.4, 0.1, 0.1]

$(Y2) = 500*.1 + 300*.1 = 80


Yr3

Grants               [500 300 400 200]

Plan [0.4, 0.4, 0.1, 0.1]

$(Y3) = 500*.4 + 300*.1 + 400*.1 = 270

And so on.. 

A simple blob of python code to compute:

import numpy as np

schedule = [0.1, 0.1, 0.4, 0.4]

rsus = [500, 300, 400, 200]

print("Your yearly vesting is: ")

result = np.convolve(schedule,rsus)

print(result)

The result is:

Your yearly vesting is: 

[ 50.  80. 270. 380. 300. 240.  80.] 

References

  • GDB2024-001 PDF of this post 


Sunday, May 19, 2019

Linux: When to use kmalloc vs kmem_cache_alloc vs Vmalloc?

Read the quick comparison here: 
Linux Memory Management API Quick Primer  [Download PDF]
Gautam Bhanage | www.Bhanage.com | Pub2: GDB2019-001 June 2019

At a high level:
1. kmalloc for all generic memory allocation
2. kmem_cache_alloc for repeatetive structs that need allocations. These structures typically need to be accessed frequently (and are L1 & L2 cache aligned by the kernel).This is done much more efficiently through the slab allocator.
3. vmalloc() - allocates virtually contiguous memory. Not really useful from a linux kernel driver perspective.