Skip to content

Conversation

@s311354
Copy link

@s311354 s311354 commented Jan 22, 2025

Problem:

The current implementation of get_or_insert_entry ,and hashmap_put2 functions are called frequently but without significant overhead. Additionally, these also are critical for managing hashmaps.

However, these two functions form a cycle, indicating recursive or interdependent calls. These cycles might lead to potential inefficiencies.

Flat profile from the original code:

%   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00      205     0.00     0.00  match
  0.00      0.00     0.00      142     0.00     0.00  startswith
  0.00      0.00     0.00      127     0.00     0.00  fnv_hash
  0.00      0.00     0.00      127     0.00     0.00  get_or_insert_entry
  0.00      0.00     0.00      127     0.00     0.00  hashmap_put2
  0.00      0.00     0.00       84     0.00     0.00  new_token
  0.00      0.00     0.00       67     0.00     0.00  in_range
  0.00      0.00     0.00       59     0.00     0.00  decode_utf8
  0.00      0.00     0.00       59     0.00     0.00  is_valid_identifier_char
  0.00      0.00     0.00       47     0.00     0.00  add_macro
  0.00      0.00     0.00       47     0.00     0.00  hashmap_put
  0.00      0.00     0.00       42     0.00     0.00  add_line_numbers
  0.00      0.00     0.00       42     0.00     0.00  define_macro
  0.00      0.00     0.00       42     0.00     0.00  new_file
  0.00      0.00     0.00       42     0.00     0.00  tokenize
  0.00      0.00     0.00       32     0.00     0.00  strarray_push

Proposal: Reduced Recursive Dependencies

Flat profile from the proposed code:

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00      142     0.00     0.00  startswith
  0.00      0.00     0.00      127     0.00     0.00  fnv_hash
  0.00      0.00     0.00      108     0.00     0.00  match
  0.00      0.00     0.00       84     0.00     0.00  new_token
  0.00      0.00     0.00       67     0.00     0.00  in_range
  0.00      0.00     0.00       59     0.00     0.00  decode_utf8
  0.00      0.00     0.00       59     0.00     0.00  is_valid_identifier_char
  0.00      0.00     0.00       47     0.00     0.00  add_macro
  0.00      0.00     0.00       47     0.00     0.00  get_or_insert_entry
  0.00      0.00     0.00       47     0.00     0.00  hashmap_put
  0.00      0.00     0.00       47     0.00     0.00  hashmap_put2
  0.00      0.00     0.00       42     0.00     0.00  add_line_numbers
  0.00      0.00     0.00       42     0.00     0.00  define_macro
  0.00      0.00     0.00       42     0.00     0.00  new_file
  0.00      0.00     0.00       42     0.00     0.00  tokenize
  0.00      0.00     0.00       32     0.00     0.00  strarray_push

Observed Behavior:
• hashmap_put2 has fewer calls, indicating better interdependency management.
• match has reduced calls, showing fewer redundant comparisons.

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.

1 participant