Skip to content

Conversation

@BretasArthur1
Copy link
Contributor

Problem

Our currently implementation of holds profile results in a hashmap that keeps growing forever, slowing down the svm more and more.

Solution

Implementing a new type that have a fixed size and holds the elements in the order they enter on the map. Whenever we add a element that should overflow the capacity we pop the first element and add to the last spot the new one(FIFO behavior)

}

#[derive(Debug, Clone)]
pub struct ProfilingMap<K, V, const CAPACITY: usize> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've made this map generic so that it can accept any type as the key + value (which is cool!!), but you've given it a specific name - ProfilingMap limits this to just store profiles, though the implementation can store anything.

We should either:

  1. Remove generics and keep the name OR
  2. Keep generics and make a more generic name like FifoMap (preferred IMO)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, this CAPACITY being passed in as a generic will make it difficult to pass in the capacity at runtime. I think the new function should receive the capacity instead.

@BretasArthur1 BretasArthur1 changed the title feat: implement a new type ProfilingMap with FIFO eviction and associated tests feat: implement a new type FifoMap and associated tests Sep 8, 2025
@BretasArthur1 BretasArthur1 marked this pull request as ready for review September 8, 2025 19:48
profile_tag_map: HashMap::new(),
simulated_transaction_profiles: HashMap::new(),
executed_transaction_profiles: HashMap::new(),
simulated_transaction_profiles: FifoMap::default(), // With DEFAULT_PROFILING_MAP_CAPACITY capacity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense for us to be passing in the CLI param to this new function instead of having a default, then changing it later in initialize?

Copy link
Member

@lgalabru lgalabru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks @BretasArthur1 !

@BretasArthur1 BretasArthur1 merged commit 0d07b9a into main Sep 12, 2025
3 checks passed
@lgalabru lgalabru deleted the refactor/configurable-map branch October 16, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants