Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache Block Location to save memory #16953

Merged
merged 3 commits into from
Mar 7, 2023

Conversation

elega
Copy link
Contributor

@elega elega commented Feb 27, 2023

What changes are proposed in this pull request?

Cache block location object to reduce memory consumption

Why are the changes needed?

Number of possible Block location value is limited, up to 9 * number of workers. By caching it, memory consumption can be saved.

Does this PR introduce any user facing changes?

N/A

@maobaolong
Copy link
Contributor

@elega Is this the improvement of #16763 ? As this is better than my PR, Shall I close #16763 ?

@elega
Copy link
Contributor Author

elega commented Feb 28, 2023

@maobaolong yup thanks

Copy link
Contributor

@jiacheliu3 jiacheliu3 left a comment

Choose a reason for hiding this comment

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

LGTM with a minor comment, thanks!

@elega elega force-pushed the yimin/cache-block-location branch from 48086a9 to a5b6082 Compare March 3, 2023 06:28
Copy link
Contributor

@maobaolong maobaolong left a comment

Choose a reason for hiding this comment

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

This PR can help to reduce heap cost extremely, but there are hard code about MediumType and tier alias.

private static final IndexDefinition<BlockLocation, Long> WORKER_ID_INDEX =
IndexDefinition.ofNonUnique(BlockLocation::getWorkerId);

// TODO(maobaolong): Add a metric to monitor the size of mLocationCacheMap
Copy link
Contributor

Choose a reason for hiding this comment

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

As mLocationCacheMap renamed to BLOCK_LOCATION_CACHE , please update the comment together

Copy link
Contributor Author

@elega elega Mar 6, 2023

Choose a reason for hiding this comment

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

sure

private static final IndexedSet<BlockLocation> BLOCK_LOCATION_CACHE =
new IndexedSet<>(OBJECT_INDEX, WORKER_ID_INDEX);

private static final Set<String> VALID_MEDIUM_TYPE_VALUES =
Copy link
Contributor

Choose a reason for hiding this comment

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

Athough MEM, SSD, HDD is the default value of MASTER_TIERED_STORE_GLOBAL_MEDIUMTYPE, but how to handle it when MASTER_TIERED_STORE_GLOBAL_MEDIUMTYPE configured to other value?

How about get the set from MASTER_TIERED_STORE_GLOBAL_MEDIUMTYPE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll add a comment for this one

Preconditions.checkState(VALID_MEDIUM_TYPE_VALUES.contains(blockLocation.getTier()),
"TierAlias must be one of {MEM, HDD and SSD} but got %s",
blockLocation.getTier());
Preconditions.checkState(VALID_MEDIUM_TYPE_VALUES.contains(blockLocation.getMediumType()),
Copy link
Contributor

Choose a reason for hiding this comment

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

The supported mediumTypes are read from configuration too.

  PropertyKey tierDirMediumConf =
        PropertyKey.Template.WORKER_TIERED_STORE_LEVEL_DIRS_MEDIUMTYPE.format(mTierOrdinal);
    List<String> dirMedium = Configuration.getList(tierDirMediumConf);

@jiacheliu3
Copy link
Contributor

alluxio-bot, merge this please

@alluxio-bot alluxio-bot merged commit 0645ea8 into Alluxio:master Mar 7, 2023
alluxio-bot pushed a commit that referenced this pull request Mar 17, 2023
Finish the todo task after #16953

pr-link: #17056
change-id: cid-e6ddc03b08e7a8a18cd53d77fa9a2f0edf4e1f57
@Xenorith Xenorith added the area-master Alluxio master label Mar 22, 2023
jiacheliu3 pushed a commit to jiacheliu3/alluxio that referenced this pull request May 19, 2023
…memory

Cache block location object to reduce memory consumption

Number of possible Block location value is limited, up to 9 * number of
workers. By caching it, memory consumption can be saved.

N/A

pr-link: Alluxio#16953
change-id: cid-9464ad2e70284b50d4c8a05dd5138f35e78bcb2d
jiacheliu3 pushed a commit to jiacheliu3/alluxio that referenced this pull request May 19, 2023
Finish the todo task after Alluxio#16953

pr-link: Alluxio#17056
change-id: cid-e6ddc03b08e7a8a18cd53d77fa9a2f0edf4e1f57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-master Alluxio master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants