Abyss-lord commented on code in PR #7501: URL: https://github.com/apache/gravitino/pull/7501#discussion_r2188892459
########## core/src/jmh/java/org/apache/gravitino/cache/EntityCachePutBenchmark.java: ########## @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.gravitino.cache; + +import java.util.List; +import org.apache.gravitino.Entity; +import org.apache.gravitino.HasIdentifier; +import org.apache.gravitino.SupportsRelationOperations; +import org.apache.gravitino.meta.ModelEntity; +import org.apache.gravitino.meta.RoleEntity; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Setup; + +/** + * EntityCachePutBenchmark benchmarks the performance of {@link EntityCache#put} operations for both + * standard entities and relation-based entity groups. + * + * <p>Each benchmark invocation starts with a cleared cache to ensure that measurements reflect + * fresh insertions without side effects from previous state. + * + * <p>This benchmark covers two insertion scenarios: + * + * <ul> + * <li>{@code benchmarkPut}: Inserts a batch of {@link ModelEntity} instances into the cache. + * <li>{@code benchmarkPutWithRelation}: Inserts relation mappings between {@link RoleEntity} and + * related entities (e.g., users), using a relation type as part of the cache key. + * </ul> + * + * @param <E> the type of related entity, extending {@link Entity} and implementing {@link + * HasIdentifier} + * @see org.apache.gravitino.cache.EntityCache + * @see org.openjdk.jmh.annotations.Benchmark + */ +public class EntityCachePutBenchmark<E extends Entity & HasIdentifier> + extends AbstractEntityBenchmark { + @Setup(Level.Invocation) Review Comment: Fix ########## core/src/jmh/java/org/apache/gravitino/cache/EntityCachePutBenchmark.java: ########## @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.gravitino.cache; + +import java.util.List; +import org.apache.gravitino.Entity; +import org.apache.gravitino.HasIdentifier; +import org.apache.gravitino.SupportsRelationOperations; +import org.apache.gravitino.meta.ModelEntity; +import org.apache.gravitino.meta.RoleEntity; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Setup; + +/** + * EntityCachePutBenchmark benchmarks the performance of {@link EntityCache#put} operations for both + * standard entities and relation-based entity groups. + * + * <p>Each benchmark invocation starts with a cleared cache to ensure that measurements reflect + * fresh insertions without side effects from previous state. + * + * <p>This benchmark covers two insertion scenarios: + * + * <ul> + * <li>{@code benchmarkPut}: Inserts a batch of {@link ModelEntity} instances into the cache. + * <li>{@code benchmarkPutWithRelation}: Inserts relation mappings between {@link RoleEntity} and + * related entities (e.g., users), using a relation type as part of the cache key. + * </ul> + * + * @param <E> the type of related entity, extending {@link Entity} and implementing {@link + * HasIdentifier} + * @see org.apache.gravitino.cache.EntityCache + * @see org.openjdk.jmh.annotations.Benchmark + */ +public class EntityCachePutBenchmark<E extends Entity & HasIdentifier> + extends AbstractEntityBenchmark { + @Setup(Level.Invocation) Review Comment: Fix ########## core/src/jmh/java/org/apache/gravitino/cache/EntityCacheClearBenchmark.java: ########## @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.gravitino.cache; + +import org.apache.gravitino.Entity; +import org.apache.gravitino.HasIdentifier; +import org.apache.gravitino.meta.ModelEntity; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Setup; + +/** + * EntityCacheClearBenchmark benchmarks the performance of the {@link EntityCache#clear()} operation + * under varying cache sizes. + * + * <p>This benchmark repeatedly clears the cache to evaluate the efficiency and overhead of the + * cache invalidation mechanism, especially under different entity volumes (e.g., 10, 100, 1000). + * + * <p>Before each invocation, the cache is pre-populated with a predefined list of entities to + * ensure the {@code clear()} method operates on a non-empty cache. + * + * @param <E> the entity type being tested, must extend {@link Entity} and implement {@link + * HasIdentifier} + * @see org.apache.gravitino.cache.EntityCache + * @see org.openjdk.jmh.annotations.Benchmark + */ +public class EntityCacheClearBenchmark<E extends Entity & HasIdentifier> Review Comment: Fix -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@gravitino.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org