Skip to content

Micro-optimizate memory usage in CatCacheCopyKeys #283

@tristan957

Description

@tristan957

CatCacheCopyKeys has this:


	/*
	 * XXX: memory and lookup performance could possibly be improved by
	 * storing all keys in one allocation.
	 */

That seems like a good idea. We'd like to reduce backend memory usage. This is a very small part of it, but it's also a very localized change.

Also, this function often deals with the 'name' type. 'name' is a fixed-width type, 64 bytes wide (NAMEDATALEN to be precise). However, it's always null-terminated, and the functions in catcache.c like nameeqfast and namehashfast treat it as a C string. So we don't really need to alloc and copy the whole 64 bytes, we could call strlen() here and leave out the trailing zeros.

Tasks:

  • Create a test case that shows the benefit. Something that creates a lot of catcache entries, and measure the memory usage.
  • Do the above optimizations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close